121 const bool storePlotPoints,
122 std::vector<PlotPoint> &listOfPlotPoints,
123 const triangulationType &triangulation) {
126 std::array<std::vector<SimplexId>, 4> criticalCellsByDim;
127 this->
dcvf_.getCriticalPoints(criticalCellsByDim, triangulation);
128 int dim = this->
dcvf_.getDimensionality();
129 int numCriticalPoints = criticalCellsByDim[0].size()
130 + criticalCellsByDim[1].size()
131 + criticalCellsByDim[2].size();
132 int numSinks = criticalCellsByDim[0].size();
133 int numSources = criticalCellsByDim[2].size();
134 int orbitsAdded{0}, orbitsRemoved{0};
135 double weightThres{-1000000};
136 if(numCriticalPoints < criticalThreshold)
139 std::vector<CandidatePair> pairs;
143 pairs, criticalCellsByDim[1], triangulation);
146 pairs, criticalCellsByDim[dim - 1], triangulation);
147 }
else if(dim == 3) {
148 this->
printErr(
"This filter can not simplify for 3D yet.");
153 const auto orderPairs
155 return a.
weight > b.weight;
160 = std::priority_queue<CandidatePair, std::vector<CandidatePair>,
161 decltype(orderPairs)>;
162 pqType options{orderPairs};
163 for(
auto pair : pairs) {
168 while(!options.empty()
169 and numCriticalPoints - 2
170 >=
static_cast<int>(criticalThreshold)) {
174 if(bestOption.
type == 0) {
175 if(!this->
dcvf_.isCellCritical(1, bestOption.
death)) {
179 if(!this->
dcvf_.isCellCritical(0, bestOption.
birth)) {
183 std::vector<SimplexId> saddle{bestOption.
death};
186 pairs, saddle, triangulation);
189 pairs, saddle, triangulation);
191 for(
auto pair : pairs) {
198 }
else if(bestOption.
type == 2) {
199 if(!this->
dcvf_.isCellCritical(1, bestOption.
birth)) {
203 if(!this->
dcvf_.isCellCritical(2, bestOption.
death)) {
207 std::vector<SimplexId> saddle{bestOption.
birth};
210 pairs, saddle, triangulation);
213 pairs, saddle, triangulation);
215 for(
auto pair : pairs) {
223 std::vector<Cell> vpath;
225 if(bestOption.
type == 0) {
226 vpath.emplace_back(
Cell(1, bestOption.
death));
227 }
else if(bestOption.
type == 2) {
228 vpath.emplace_back(
Cell(1, bestOption.
birth));
232 this->
dcvf_.getDescendingPath<dataType, triangulationType>(
233 bestOption.
nextCell, vpath, triangulation,
false);
235 this->
dcvf_.getAscendingPath<dataType, triangulationType>(
236 bestOption.
nextCell, vpath, triangulation,
false);
238 if(bestOption.
type == 0) {
240 != vpath.back().id_) {
243 std::vector<SimplexId> saddle{bestOption.
death};
246 pairs, saddle, triangulation);
249 pairs, saddle, triangulation);
251 for(
auto pair : pairs) {
257 }
else if(bestOption.
type == 2) {
259 != vpath.back().id_) {
262 std::vector<SimplexId> saddle{bestOption.
birth};
265 pairs, saddle, triangulation);
268 pairs, saddle, triangulation);
270 for(
auto pair : pairs) {
283 = std::max(weightThres,
static_cast<double>(bestOption.
weight));
286 if(storePlotPoints) {
287 listOfPlotPoints.emplace_back(
288 numCriticalPoints, numSinks, numSources, weightThres);
289 listOfPlotPoints.back().orbitsAdded = orbitsAdded;
290 listOfPlotPoints.back().orbitsRemoved = orbitsRemoved;
294 if(bestOption.
type == 0) {
296 }
else if(bestOption.
type == 2) {
303 orbitsRemoved = orbitsRemoved + bestOption.
alternations;
306 if(storePlotPoints) {
307 listOfPlotPoints.emplace_back(
308 numCriticalPoints - 2, numSinks, numSources, weightThres);
309 listOfPlotPoints.back().orbitsAdded = orbitsAdded;
310 listOfPlotPoints.back().orbitsRemoved = orbitsRemoved;
316 this->
dcvf_.reverseAlternatingPath(vpath, triangulation);
318 this->
dcvf_.reverseDescendingPath(vpath, triangulation);
320 numCriticalPoints -= 2;
324 this->
dcvf_.reverseAlternatingPath(vpath, triangulation);
326 this->
dcvf_.reverseAscendingPath(vpath, triangulation);
328 numCriticalPoints -= 2;
333 this->
printMsg(
"Simplified to " + std::to_string(numCriticalPoints)
334 +
" critical point(s)",
335 1.0, tm.getElapsedTime(), this->threadNumber_);