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

Method ComputeCellsBounds

Common/DataModel/vtkPolyData.cxx:305–406  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This method only considers points that are used by one or more cells. Thus unused points make no contribution to the bounding box computation. This is more costly to compute than using just the points, but for rendering and historical reasons, produces preferred results.

Source from the content-addressed store, hash-verified

303// is more costly to compute than using just the points, but for rendering
304// and historical reasons, produces preferred results.
305void vtkPolyData::ComputeCellsBounds()
306{
307 if (this->GetMeshMTime() > this->CellsBoundsTime)
308 {
309 // If there are no cells, uninitialize the bounds.
310 const vtkIdType numPts = this->GetNumberOfPoints();
311 const vtkIdType numPDCells = this->GetNumberOfCells();
312 if (numPDCells <= 0)
313 {
314 vtkMath::UninitializeBounds(this->CellsBounds);
315 return;
316 }
317
318 // We are going to compute the bounds
319 this->CellsBoundsTime.Modified();
320
321 // Make sure this vtkPolyData has points.
322 if (this->Points == nullptr || numPts <= 0 || numPDCells <= 0)
323 {
324 vtkMath::UninitializeBounds(this->CellsBounds);
325 return;
326 }
327
328 // With cells available, loop over the cells of the polydata.
329 // Mark points that are used by one or more cells. Unmarked
330 // points do not contribute.
331 vtkCellArray* cellArrays[4] = { this->GetVerts(), this->GetLines(), this->GetPolys(),
332 this->GetStrips() };
333
334 // Process each cell array separately. Note that threading is only used
335 // if the model is big enough (since there is a cost to spinning up the
336 // thread pool).
337
338 // Create uses array initialized to 0
339 vtkSMPThreadLocalObject<vtkIdList> tlCellPointIds;
340 if (numPDCells > vtkSMPTools::THRESHOLD)
341 {
342 // Create uses array initialized to 0 and supporting threaded access
343 std::atomic<unsigned char>* ptUses = new std::atomic<unsigned char>[numPts]();
344 for (const auto& cellArray : cellArrays)
345 {
346 const auto numCells = cellArray->GetNumberOfCells();
347 if (numCells <= 0)
348 {
349 continue;
350 }
351 // Lambda to threaded mark used points
352 vtkSMPTools::For(0, numCells,
353 [&](vtkIdType beginCellId, vtkIdType endCellId)
354 {
355 auto cellPointIds = tlCellPointIds.Local();
356 vtkIdType npts, ptIdx;
357 const vtkIdType* pts;
358 for (vtkIdType cellId = beginCellId; cellId < endCellId; ++cellId)
359 {
360 cellArray->GetCellAtId(cellId, npts, pts, cellPointIds);
361 for (ptIdx = 0; ptIdx < npts; ++ptIdx)
362 {

Callers 1

GetCellsBoundsMethod · 0.95

Calls 14

GetMeshMTimeMethod · 0.95
GetNumberOfCellsMethod · 0.95
GetVertsMethod · 0.95
GetLinesMethod · 0.95
GetPolysMethod · 0.95
GetStripsMethod · 0.95
UninitializeBoundsFunction · 0.85
ComputeBoundsFunction · 0.70
ForFunction · 0.50
GetNumberOfPointsMethod · 0.45
ModifiedMethod · 0.45
GetNumberOfCellsMethod · 0.45

Tested by

no test coverage detected