| 790 | } // end anon namespace |
| 791 | |
| 792 | VTK_ABI_NAMESPACE_BEGIN |
| 793 | //------------------------------------------------------------------------------ |
| 794 | // Create data structure that allows random access of cells. |
| 795 | void 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, |