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

Method DecimateEdges

Filters/Hybrid/vtkImageToPolyDataFilter.cxx:1307–1344  ·  view source on GitHub ↗

Remove points that are nearly co-linear to reduce the total point count

Source from the content-addressed store, hash-verified

1305// Remove points that are nearly co-linear to reduce the total point count
1306//
1307void vtkImageToPolyDataFilter::DecimateEdges(
1308 vtkPolyData* edges, vtkUnsignedCharArray* pointDescr, double tol2)
1309{
1310 vtkPoints* points = edges->GetPoints();
1311 vtkIdType numPts = points->GetNumberOfPoints(), ptId, prevId, nextId;
1312 vtkIdType npts;
1313 double x[3], xPrev[3], xNext[3];
1314 vtkIdType ncells;
1315 vtkIdType* cells;
1316 const vtkIdType* pts;
1317
1318 // Loop over all points, finding those that are connected to just two
1319 // edges. If the point is colinear to the previous and next edge point,
1320 // then mark it as deleted.
1321 for (ptId = 0; ptId < numPts; ptId++)
1322 {
1323 if (pointDescr->GetValue(ptId) == 0)
1324 {
1325 points->GetPoint(ptId, x);
1326 edges->GetPointCells(ptId, ncells, cells);
1327 if (ncells == 2)
1328 {
1329 edges->GetCellPoints(cells[0], npts, pts);
1330 prevId = (pts[0] != ptId ? pts[0] : pts[1]);
1331 points->GetPoint(prevId, xPrev);
1332
1333 edges->GetCellPoints(cells[1], npts, pts);
1334 nextId = (pts[0] != ptId ? pts[0] : pts[1]);
1335 points->GetPoint(nextId, xNext);
1336
1337 if (vtkLine::DistanceToLine(x, xPrev, xNext) <= tol2)
1338 {
1339 pointDescr->SetValue(ptId, 2); // mark deleted
1340 }
1341 }
1342 } // if manifold
1343 } // for all points
1344}
1345VTK_ABI_NAMESPACE_END

Callers 1

PolygonalizeImageMethod · 0.95

Calls 7

GetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetValueMethod · 0.45
GetPointMethod · 0.45
GetPointCellsMethod · 0.45
GetCellPointsMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected