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

Function CleanOutputPoints

Filters/Modeling/vtkContourLoopExtraction.cxx:244–290  ·  view source on GitHub ↗

Discard unused points; renumber output polylines and polygons. Performs this operation in place.

Source from the content-addressed store, hash-verified

242// Discard unused points; renumber output polylines and polygons.
243// Performs this operation in place.
244void CleanOutputPoints(vtkPolyData* output)
245{
246 // Mark points used by lines or polygons, and create a point map
247 // of old point ids to new point ids.
248 vtkIdType numPts = output->GetNumberOfPoints();
249 std::vector<vtkIdType> ptMap(numPts, 0);
250 vtkPoints* pts = output->GetPoints();
251
252 // Get the connectivity of the lines and polygons. Run through them
253 // and mark points that are used.
254 vtkCellArray* lines = output->GetLines();
255 vtkIdType numLinesIds = lines->GetNumberOfConnectivityIds();
256 if (numLinesIds > 0)
257 {
258 MarkPointUses(lines, numLinesIds, ptMap);
259 }
260
261 vtkCellArray* polys = output->GetPolys();
262 vtkIdType numPolysIds = polys->GetNumberOfConnectivityIds();
263 if (numPolysIds > 0)
264 {
265 MarkPointUses(polys, numPolysIds, ptMap);
266 }
267
268 // Renumber points / build the point map
269 vtkNew<vtkPoints> newPts;
270 vtkIdType newId;
271 for (auto pId = 0; pId < numPts; ++pId)
272 {
273 if (ptMap[pId] != 0)
274 {
275 newId = newPts->InsertNextPoint(pts->GetPoint(pId));
276 ptMap[pId] = newId;
277 }
278 }
279 output->SetPoints(newPts);
280
281 // Update the point ids (in place).
282 if (numLinesIds > 0)
283 {
284 UpdatePointUses(lines, numLinesIds, ptMap);
285 }
286 if (numPolysIds > 0)
287 {
288 UpdatePointUses(polys, numPolysIds, ptMap);
289 }
290} // CleanOutputPoints
291
292} // anonymous namespace
293

Callers 1

RequestDataMethod · 0.85

Calls 10

MarkPointUsesFunction · 0.85
UpdatePointUsesFunction · 0.85
GetPolysMethod · 0.80
GetNumberOfPointsMethod · 0.45
GetPointsMethod · 0.45
GetLinesMethod · 0.45
InsertNextPointMethod · 0.45
GetPointMethod · 0.45
SetPointsMethod · 0.45

Tested by

no test coverage detected