MCPcopy Create free account
hub / github.com/Kitware/VTK / SimplifyBranches

Method SimplifyBranches

Common/DataModel/vtkReebGraph.cxx:1269–1527  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1267
1268//------------------------------------------------------------------------------
1269int vtkReebGraph::Implementation::SimplifyBranches(
1270 double simplificationThreshold, vtkReebGraphSimplificationMetric* simplificationMetric)
1271{
1272 static const vtkReebLabelTag RouteOld = 100;
1273 static const vtkReebLabelTag RouteNew = 200;
1274 int nstack, mstack = 0;
1275 int* stack = nullptr;
1276
1277 if (!simplificationThreshold)
1278 return 0;
1279
1280 int nsimp = 0;
1281 int cont = 0;
1282 constexpr int step = 10000;
1283 bool redo;
1284
1285 vtkDataSet* input = inputMesh;
1286
1287REDO:
1288 nstack = 0;
1289 redo = false;
1290
1291 for (int N = 1; N < this->MainNodeTable.Size; ++N)
1292 {
1293 if (this->GetNode(N)->ArcUpId == -2)
1294 continue;
1295
1296 vtkReebNode* n = this->GetNode(N);
1297
1298 // simplify atomic nodes
1299 if (!n->ArcDownId && !n->ArcUpId)
1300 {
1301 // delete the node from the graph...
1302 this->GetNode(N)->ArcUpId = -2;
1303 this->GetNode(N)->ArcDownId = this->MainNodeTable.FreeZone;
1304 this->MainNodeTable.FreeZone = (N);
1305 --(this->MainNodeTable.Number);
1306 }
1307 else if (!n->ArcDownId)
1308 {
1309 // insert into stack branches to simplify
1310 for (int A_ = n->ArcUpId; A_; A_ = this->GetArc(A_)->ArcDwId0)
1311 {
1312 vtkReebArc* a_ = this->GetArc(A_);
1313 if ((!inputMesh) || (!simplificationMetric))
1314 {
1315 if (vtkReebGraphGetArcPersistence(this, a_) < simplificationThreshold)
1316 {
1317 vtkReebGraphStackPush(A_);
1318 }
1319 }
1320 else
1321 {
1322 if (this->ComputeCustomMetric(simplificationMetric, a_) < simplificationThreshold)
1323 {
1324 vtkReebGraphStackPush(A_);
1325 }
1326 }

Callers 1

SimplifyMethod · 0.80

Calls 5

GetNodeMethod · 0.95
GetArcMethod · 0.95
ComputeCustomMetricMethod · 0.95
SimplifyLabelsMethod · 0.95
SetLabelFunction · 0.50

Tested by

no test coverage detected