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

Method BuildCells

Common/DataModel/vtkPolyData.cxx:792–852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790} // end anon namespace
791
792VTK_ABI_NAMESPACE_BEGIN
793//------------------------------------------------------------------------------
794// Create data structure that allows random access of cells.
795void vtkPolyData::BuildCells()
796{
797 vtkCellArray* verts = this->GetVerts();
798 vtkCellArray* lines = this->GetLines();
799 vtkCellArray* polys = this->GetPolys();
800 vtkCellArray* strips = this->GetStrips();
801
802 // here are the number of cells we have
803 const vtkIdType nVerts = verts->GetNumberOfCells();
804 const vtkIdType nLines = lines->GetNumberOfCells();
805 const vtkIdType nPolys = polys->GetNumberOfCells();
806 const vtkIdType nStrips = strips->GetNumberOfCells();
807
808 // pre-allocate the space we need
809 const vtkIdType nCells = nVerts + nLines + nPolys + nStrips;
810
811 this->Cells = vtkSmartPointer<CellMap>::New();
812 this->Cells->SetNumberOfCells(nCells);
813
814 vtkIdType beginCellId = 0;
815 if (nVerts > 0)
816 {
817 verts->Dispatch(BuildCellsImpl{}, this->Cells, beginCellId,
818 [](vtkIdType size) -> VTKCellType { return size == 1 ? VTK_VERTEX : VTK_POLY_VERTEX; });
819 beginCellId += nVerts;
820 }
821
822 if (nLines > 0)
823 {
824 lines->Dispatch(BuildCellsImpl{}, this->Cells, beginCellId,
825 [](vtkIdType size) -> VTKCellType { return size == 2 ? VTK_LINE : VTK_POLY_LINE; });
826 beginCellId += nLines;
827 }
828
829 if (nPolys > 0)
830 {
831 polys->Dispatch(BuildCellsImpl{}, this->Cells, beginCellId,
832 [](vtkIdType size) -> VTKCellType
833 {
834 switch (size)
835 {
836 case 3:
837 return VTK_TRIANGLE;
838 case 4:
839 return VTK_QUAD;
840 default:
841 return VTK_POLYGON;
842 }
843 });
844 beginCellId += nPolys;
845 }
846
847 if (nStrips > 0)
848 {
849 strips->Dispatch(BuildCellsImpl{}, this->Cells, beginCellId,

Callers 14

GetCellTypeMethod · 0.95
GetCellSizeMethod · 0.95
ReplaceCellPointMethod · 0.95
GetCellPointsMethod · 0.95
GetCellMethod · 0.95
GetCellBoundsMethod · 0.95
BuildLinksMethod · 0.95
GetCellPointsMethod · 0.95
InsertNextCellMethod · 0.95
ReverseCellMethod · 0.95
ReplaceCellMethod · 0.95

Calls 8

GetVertsMethod · 0.95
GetLinesMethod · 0.95
GetPolysMethod · 0.95
GetStripsMethod · 0.95
SetNumberOfCellsMethod · 0.80
NewFunction · 0.50
GetNumberOfCellsMethod · 0.45
DispatchMethod · 0.45

Tested by 2

TestPolyDataRemoveCellFunction · 0.36
CheckDeletedCellsFunction · 0.36