------------------------------------------------------------------------------ Insert a cell of type VTK_VERTEX, VTK_POLY_VERTEX, VTK_LINE, VTK_POLY_LINE, VTK_TRIANGLE, VTK_QUAD, VTK_POLYGON, or VTK_TRIANGLE_STRIP. Make sure that the PolyData::Allocate() function has been called first or that vertex, line, polygon, and triangle strip arrays have been supplied. Note: will also insert VTK_PIXEL, bu
| 972 | // line, polygon, and triangle strip arrays have been supplied. |
| 973 | // Note: will also insert VTK_PIXEL, but converts it to VTK_QUAD. |
| 974 | vtkIdType vtkPolyData::InsertNextCell(int type, int npts, const vtkIdType ptsIn[]) |
| 975 | { |
| 976 | if (!this->Cells) |
| 977 | { |
| 978 | this->BuildCells(); |
| 979 | } |
| 980 | |
| 981 | const vtkIdType* pts = ptsIn; |
| 982 | vtkIdType pixPts[4]; |
| 983 | |
| 984 | // Docs say we need to handle VTK_PIXEL: |
| 985 | if (type == VTK_PIXEL) |
| 986 | { |
| 987 | // need to rearrange vertices |
| 988 | pixPts[0] = pts[0]; |
| 989 | pixPts[1] = pts[1]; |
| 990 | pixPts[2] = pts[3]; |
| 991 | pixPts[3] = pts[2]; |
| 992 | |
| 993 | type = VTK_QUAD; |
| 994 | pts = pixPts; |
| 995 | } |
| 996 | |
| 997 | // Make sure the type is supported by the dataset (and thus safe to use with |
| 998 | // the TaggedCellId): |
| 999 | if (!CellMap::ValidateCellType(VTKCellType(type))) |
| 1000 | { |
| 1001 | vtkErrorMacro("Invalid cell type: " << type); |
| 1002 | return -1; |
| 1003 | } |
| 1004 | |
| 1005 | // Insert next cell into the lookup map: |
| 1006 | TaggedCellId& tag = this->Cells->InsertNextCell(VTKCellType(type)); |
| 1007 | vtkCellArray* cells = this->GetCellArrayInternal(tag); |
| 1008 | |
| 1009 | // Validate and update the internal cell id: |
| 1010 | const vtkIdType internalCellId = cells->InsertNextCell(npts, pts); |
| 1011 | if (internalCellId < 0) |
| 1012 | { |
| 1013 | vtkErrorMacro("Internal error: Invalid cell id (" << internalCellId << ")."); |
| 1014 | return -1; |
| 1015 | } |
| 1016 | if (!CellMap::ValidateCellId(internalCellId)) |
| 1017 | { |
| 1018 | vtkErrorMacro("Internal cell array storage exceeded."); |
| 1019 | return -1; |
| 1020 | } |
| 1021 | tag.SetCellId(internalCellId); |
| 1022 | |
| 1023 | // Return the dataset cell id: |
| 1024 | return this->Cells->GetNumberOfCells() - 1; |
| 1025 | } |
| 1026 | |
| 1027 | //------------------------------------------------------------------------------ |
| 1028 | // Insert a cell of type VTK_VERTEX, VTK_POLY_VERTEX, VTK_LINE, VTK_POLY_LINE, |
no test coverage detected