77 if (levelSet ==
nullptr) {
79 .addWarning(
"No level set was passed to Prune.")
83 if (levelSet->getNumberOfPoints() == 0) {
87 auto &grid = levelSet->getGrid();
88 auto newlsDomain = SmartPointer<Domain<T, D>>::New(grid);
92 newDomain.initialize(domain.getNewSegmentation(), domain.getAllocation());
94 const bool updateData = updatePointData;
95 const bool removeZeros = removeStrayZeros;
98 std::vector<std::vector<unsigned>> newDataSourceIds;
102#pragma omp parallel num_threads(newDomain.getNumberOfSegments())
106 p = omp_get_thread_num();
109 auto &domainSegment = newDomain.getDomainSegment(p);
111 hrleVectorType<hrleIndexType, D> startVector =
112 (p == 0) ? grid.getMinGridPoint()
113 : newDomain.getSegmentation()[p - 1];
115 hrleVectorType<hrleIndexType, D> endVector =
117 ? newDomain.getSegmentation()[p]
118 : grid.incrementIndices(grid.getMaxGridPoint());
121 neighborIt(domain, startVector);
122 neighborIt.getIndices() < endVector; neighborIt.next()) {
123 auto ¢erIt = neighborIt.getCenter();
124 bool centerSign = isNegative(centerIt.getValue());
125 if (centerIt.isDefined()) {
126 bool keepPoint =
true;
128 if (std::abs(centerIt.getValue()) != 0.) {
131 checkNeighbourSigns(neighborIt, isSignDifferentOrZero<T>);
133 keepPoint = checkNeighbourSigns(neighborIt, isSignDifferent<T>);
141 if (std::abs(centerIt.getValue()) == 0.) {
142 bool overWritePoint =
false;
144 for (
int i = 0; i <
D; i++) {
145 const auto &negVal = neighborIt.getNeighbor(i).getValue();
146 const auto &posVal = neighborIt.getNeighbor(
D + i).getValue();
150 if (!isMonotone(negVal, posVal)) {
151 overWritePoint =
true;
153 std::abs(negVal) < std::abs(posVal) ? negVal : posVal;
157 if (overWritePoint) {
158 domainSegment.insertNextDefinedPoint(neighborIt.getIndices(),
166 domainSegment.insertNextDefinedPoint(neighborIt.getIndices(),
167 centerIt.getValue());
169 newDataSourceIds[p].push_back(centerIt.getPointId());
173 domainSegment.insertNextUndefinedPoint(
174 neighborIt.getIndices(),
178 domainSegment.insertNextUndefinedPoint(
179 neighborIt.getIndices(),
187 newlsDomain->getPointData().translateFromMultiData(
188 levelSet->getPointData(), newDataSourceIds);
195 levelSet->finalize(2);