29 SmartPointer<Domain<T, D>> levelSet =
nullptr;
33 std::vector<T> flaggedCells;
41 : levelSet(passedLevelSet) {}
44 : levelSet(passedLevelSet), flatLimit(passedLimit),
45 flatLimit2(flatLimit * flatLimit) {}
49 : levelSet(passedLevelSet), flatLimit(passedLimit),
50 flatLimit2(flatLimit * flatLimit), method(passedMethod) {}
53 flatLimit = threshold;
54 flatLimit2 = flatLimit * flatLimit;
61 method = passedMethod;
67 FeatureDetectionCurvature();
69 FeatureDetectionNormals();
73 auto &pointData = levelSet->getPointData();
76 if (vectorDataPointer ==
nullptr) {
80 *vectorDataPointer = std::move(flaggedCells);
91 void FeatureDetectionCurvature() {
94 auto grid = levelSet->getGrid();
96 std::vector<std::vector<T>> flagsReserve(levelSet->getNumberOfSegments());
98#pragma omp parallel num_threads((levelSet)->getNumberOfSegments())
102 p = omp_get_thread_num();
105 auto &flagsSegment = flagsReserve[p];
106 flagsSegment.reserve(
107 levelSet->getDomain().getDomainSegment(p).getNumberOfPoints());
109 hrleVectorType<hrleIndexType, D> startVector =
110 (p == 0) ? grid.getMinGridPoint() : domain.getSegmentation()[p - 1];
112 hrleVectorType<hrleIndexType, D> endVector =
114 ? domain.getSegmentation()[p]
115 : grid.incrementIndices(grid.getMaxGridPoint());
118 neighborIt(levelSet->getDomain(), startVector, 1);
119 neighborIt.getIndices() < endVector; neighborIt.next()) {
121 auto ¢er = neighborIt.getCenter();
122 if (!center.isDefined()) {
124 }
else if (std::abs(center.getValue()) > 0.5) {
125 flagsSegment.push_back(0);
130 if (std::abs(curve) > flatLimit) {
131 flagsSegment.push_back(1);
133 if constexpr (
D == 2) {
134 flagsSegment.push_back(0);
137 if (std::abs(curve) > flatLimit2)
138 flagsSegment.push_back(1);
140 flagsSegment.push_back(0);
146 flaggedCells.reserve(levelSet->getNumberOfPoints());
147 for (
unsigned i = 0; i < levelSet->getNumberOfSegments(); ++i)
148 flaggedCells.insert(flaggedCells.end(), flagsReserve[i].begin(),
149 flagsReserve[i].end());
155 void FeatureDetectionNormals() {
157 flaggedCells.clear();
159 auto &grid = levelSet->getGrid();
161 T cosAngleTreshold = std::cos(flatLimit);
164 Expand<T, D>(levelSet, 3).apply();
165 CalculateNormalVectors<T, D>(levelSet).apply();
166 const auto &normals = *(levelSet->getPointData().getVectorData(
169 std::vector<std::vector<T>> flagsReserve(levelSet->getNumberOfSegments());
172#pragma omp parallel num_threads((levelSet)->getNumberOfSegments())
176 p = omp_get_thread_num();
179 Vec3D<T> zeroVector{};
181 std::vector<T> &flagsSegment = flagsReserve[p];
182 flagsSegment.reserve(
183 levelSet->getDomain().getDomainSegment(p).getNumberOfPoints());
185 hrleVectorType<hrleIndexType, D> startVector =
186 (p == 0) ? grid.getMinGridPoint() : domain.getSegmentation()[p - 1];
188 hrleVectorType<hrleIndexType, D> endVector =
190 ? domain.getSegmentation()[p]
191 : grid.incrementIndices(grid.getMaxGridPoint());
194 levelSet->getDomain(), startVector, 1);
195 neighborIt.getIndices() < endVector; neighborIt.next()) {
196 if (!neighborIt.getCenter().isDefined()) {
198 }
else if (std::abs(neighborIt.getCenter().getValue()) >= 0.5) {
199 flagsSegment.push_back(0);
203 Vec3D<T> centerNormal = normals[neighborIt.getCenter().getPointId()];
207 for (
unsigned dir = 0; dir < (
D *
D *
D); dir++) {
208 Vec3D<T> currentNormal =
209 normals[neighborIt.getNeighbor(dir).getPointId()];
211 if (currentNormal != zeroVector) {
214 for (
int j = 0; j <
D; j++) {
215 skp += currentNormal[j] * centerNormal[j];
218 if ((cosAngleTreshold - skp) >= 0.) {
226 flagsSegment.push_back(1);
228 flagsSegment.push_back(0);
233 for (
unsigned i = 0; i < levelSet->getNumberOfSegments(); ++i)
234 flaggedCells.insert(flaggedCells.end(), flagsReserve[i].begin(),
235 flagsReserve[i].end());
Class containing all information about the level set, including the dimensions of the domain,...
Definition lsDomain.hpp:28
unsigned getNumberOfSegments() const
returns the number of segments, the levelset is split into. This is useful for algorithm parallelisat...
Definition lsDomain.hpp:150
hrleDomain< T, D > DomainType
Definition lsDomain.hpp:33
DomainType & getDomain()
get const reference to the underlying hrleDomain data structure
Definition lsDomain.hpp:144