61 if (levelSet ==
nullptr) {
63 .addWarning(
"No level set was passed to CalculateCurvatures.")
68 if (
unsigned minWidth = std::ceil((maxValue * 8) + 1);
69 levelSet->getLevelSetWidth() < minWidth) {
71 .addWarning(
"CalculateCurvatures: Level set width must be "
73 std::to_string(minWidth) +
" !")
77 std::vector<std::vector<T>> meanCurvaturesVector(
78 levelSet->getNumberOfSegments());
79 std::vector<std::vector<T>> gaussCurvaturesVector(
80 levelSet->getNumberOfSegments());
82 auto grid = levelSet->getGrid();
83 const bool calculateMean =
86 const bool calculateGauss =
91#pragma omp parallel num_threads(levelSet->getNumberOfSegments())
95 p = omp_get_thread_num();
98 auto &meanCurvatures = meanCurvaturesVector[p];
99 auto &gaussCurvatures = gaussCurvaturesVector[p];
102 meanCurvatures.reserve(
103 levelSet->getDomain().getDomainSegment(p).getNumberOfPoints());
105 if (calculateGauss) {
106 gaussCurvatures.reserve(
107 levelSet->getDomain().getDomainSegment(p).getNumberOfPoints());
110 hrleVectorType<hrleIndexType, D> startVector =
111 (p == 0) ? grid.getMinGridPoint()
112 : levelSet->getDomain().getSegmentation()[p - 1];
114 hrleVectorType<hrleIndexType, D> endVector =
115 (p !=
static_cast<int>(levelSet->getNumberOfSegments() - 1))
116 ? levelSet->getDomain().getSegmentation()[p]
117 : grid.incrementIndices(grid.getMaxGridPoint());
120 neighborIt(levelSet->getDomain(), startVector);
121 neighborIt.getIndices() < endVector; neighborIt.next()) {
123 auto ¢er = neighborIt.getCenter();
124 if (!center.isDefined()) {
126 }
else if (std::abs(center.getValue()) > maxValue) {
128 meanCurvatures.push_back(0.);
130 gaussCurvatures.push_back(0.);
138 if (calculateGauss) {
146 unsigned numberOfCurvatures = 0;
147 for (
unsigned i = 0; i < levelSet->getNumberOfSegments(); ++i) {
148 numberOfCurvatures += meanCurvaturesVector[i].size();
150 meanCurvaturesVector[0].reserve(numberOfCurvatures);
152 for (
unsigned i = 1; i < levelSet->getNumberOfSegments(); ++i) {
153 meanCurvaturesVector[0].insert(meanCurvaturesVector[0].end(),
154 meanCurvaturesVector[i].begin(),
155 meanCurvaturesVector[i].end());
159 if (calculateGauss) {
160 unsigned numberOfCurvatures = 0;
161 for (
unsigned i = 0; i < levelSet->getNumberOfSegments(); ++i) {
162 numberOfCurvatures += gaussCurvaturesVector[i].size();
164 gaussCurvaturesVector[0].reserve(numberOfCurvatures);
166 for (
unsigned i = 1; i < levelSet->getNumberOfSegments(); ++i) {
167 gaussCurvaturesVector[0].insert(gaussCurvaturesVector[0].end(),
168 gaussCurvaturesVector[i].begin(),
169 gaussCurvaturesVector[i].end());
175 auto &pointData = levelSet->getPointData();
176 auto scalarDataPointer =
179 if (scalarDataPointer ==
nullptr) {
180 pointData.insertNextScalarData(meanCurvaturesVector[0],
184 *scalarDataPointer = std::move(meanCurvaturesVector[0]);
188 if (calculateGauss) {
189 auto &pointData = levelSet->getPointData();
190 auto scalarDataPointer =
193 if (scalarDataPointer ==
nullptr) {
194 pointData.insertNextScalarData(gaussCurvaturesVector[0],
198 *scalarDataPointer = std::move(gaussCurvaturesVector[0]);