VTK  9.1.0
vtkUnstructuredGrid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkUnstructuredGrid.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
28 #ifndef vtkUnstructuredGrid_h
29 #define vtkUnstructuredGrid_h
30 
31 #include "vtkCellArray.h" //inline GetCellPoints()
32 #include "vtkCommonDataModelModule.h" // For export macro
33 #include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_0_0
34 #include "vtkIdTypeArray.h" //inline GetCellPoints()
36 
37 #include "vtkSmartPointer.h" // for smart pointer
38 
39 class vtkCellArray;
41 class vtkBezierCurve;
44 class vtkBezierTriangle;
45 class vtkBezierTetra;
46 class vtkBezierWedge;
47 class vtkConvexPointSet;
48 class vtkEmptyCell;
49 class vtkHexahedron;
50 class vtkIdList;
51 class vtkIdTypeArray;
52 class vtkLagrangeCurve;
56 class vtkLagrangeTetra;
57 class vtkLagrangeWedge;
58 class vtkLine;
59 class vtkPixel;
60 class vtkPolyLine;
61 class vtkPolyVertex;
62 class vtkPolygon;
63 class vtkPyramid;
64 class vtkPentagonalPrism;
65 class vtkHexagonalPrism;
66 class vtkQuad;
67 class vtkQuadraticEdge;
69 class vtkQuadraticWedge;
72 class vtkQuadraticQuad;
73 class vtkQuadraticTetra;
75 class vtkTetra;
76 class vtkTriangle;
77 class vtkTriangleStrip;
79 class vtkVertex;
80 class vtkVoxel;
81 class vtkWedge;
86 class vtkBiQuadraticQuad;
90 class vtkCubicLine;
91 class vtkPolyhedron;
92 class vtkIdTypeArray;
93 
94 class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGrid : public vtkUnstructuredGridBase
95 {
96 public:
102 
104 
108  void PrintSelf(ostream& os, vtkIndent indent) override;
110 
114  int GetDataObjectType() override { return VTK_UNSTRUCTURED_GRID; }
115 
125  bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
126  {
127  return this->AllocateExact(numCells, numCells * maxCellSize);
128  }
129 
139  bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
140 
150  void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
151  {
152  this->AllocateExact(numCells, numCells);
153  }
154 
156 
159  void Reset();
160  void CopyStructure(vtkDataSet* ds) override;
162  using vtkDataSet::GetCell;
163  vtkCell* GetCell(vtkIdType cellId) override;
164  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
165  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
166  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
167  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
170 
174  int GetCellType(vtkIdType cellId) override;
175 
187  void GetCellTypes(vtkCellTypes* types) override;
188 
199  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
200  {
201  this->Connectivity->GetCellAtId(cellId, npts, pts);
202  }
203 
205 
210  void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
211  VTK_SIZEHINT(cells, ncells);
213  "Use vtkUnstructuredGrid::GetPointCells::vtkIdType, vtkIdType&, vtkIdType*&)")
214  void GetPointCells(vtkIdType ptId, unsigned short& ncells, vtkIdType*& cells)
215  VTK_SIZEHINT(cells, ncells);
217 
224  vtkUnsignedCharArray* GetCellTypesArray();
225 
229  void Squeeze() override;
230 
234  void Initialize() override;
235 
239  int GetMaxCellSize() override;
240 
245  void BuildLinks();
246 
254  vtkAbstractCellLinks* GetCellLinks();
255 
262  void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
263 
272  void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType const*& ptIds);
273 
275 
284  void SetCells(int type, vtkCellArray* cells);
285  void SetCells(int* types, vtkCellArray* cells);
286  void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells);
287  void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
288  vtkIdTypeArray* faces);
290 
294  vtkCellArray* GetCells() { return this->Connectivity; }
295 
297 
303  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
304  {
305  this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
306  }
308  vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
310 
312 
322  bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds);
324 
326 
330  vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
333  void ResizeCellList(vtkIdType ptId, int size);
335 
337 
340  virtual int GetPiece();
341  virtual int GetNumberOfPieces();
343 
347  virtual int GetGhostLevel();
348 
357  unsigned long GetActualMemorySize() override;
358 
360 
363  void ShallowCopy(vtkDataObject* src) override;
364  void DeepCopy(vtkDataObject* src) override;
366 
372  void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
373 
377  int IsHomogeneous() override;
378 
385 
387 
393 
398 
400 
406 
415 
424 
437  static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
438  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
439 
440  static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
441  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
442 
455  static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
456  vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
457 
464  static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
465 
471  static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
472 
473  //====================== Begin Legacy Methods ================================
474 
483 
485 
501  void SetCells(
502  vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
503  void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
504  vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
506 
507  //====================== End Legacy Methods ==================================
508 
509 protected:
512 
513  // These are all the cells that vtkUnstructuredGrid can represent. Used by
514  // GetCell() (and similar) methods.
563 
564  // Points derived from vtkPointSet.
565  // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
566  // derived from vtkDataSet.
567 
568  // The heart of the data represention. The points are managed by the
569  // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
570  // point ids that define the cell) and the cell type, represented by the
571  // Connectivity and Types arrays.
572  // Finally, when certain topological information is needed (e.g.,
573  // all the cells that use a point), the cell links array is built.
577 
578  // Set of all cell types present in the grid. All entries are unique.
580 
581  // The DistinctCellTypes is cached, so we keep track of the last time it was
582  // updated so we can compare it to the modified time of the Types array.
584 
585  // Special support for polyhedra/cells with explicit face representations.
586  // The Faces class represents polygonal faces using a modified vtkCellArray
587  // structure. Each cell face list begins with the total number of faces in
588  // the cell, followed by a vtkCellArray data organization
589  // (n,i,j,k,n,i,j,k,...).
592 
593  // Legacy support -- stores the old-style cell array locations.
595 
596  vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
599  vtkIdType nfaces, const vtkIdType faces[]) override;
600  void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
601 
602 private:
603  // Hide these from the user and the compiler.
604  vtkUnstructuredGrid(const vtkUnstructuredGrid&) = delete;
605  void operator=(const vtkUnstructuredGrid&) = delete;
606 
607  void Cleanup();
608 };
609 
610 #endif
A 3D cell that represents an arbitrary order Bezier hex.
A 3D cell that represents an arbitrary order Bezier tetrahedron.
A 2D cell that represents an arbitrary order Bezier triangle.
A 3D cell that represents an arbitrary order Bezier wedge.
cell represents a parabolic, 9-node isoparametric quad
cell represents a biquadratic, 24-node isoparametric hexahedron
cell represents a parabolic, 18-node isoparametric wedge
cell represents a parabolic, isoparametric triangle
object to represent cell connectivity
Definition: vtkCellArray.h:181
Efficient cell iterator for vtkDataSet topologies.
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:48
abstract class to specify cell behavior
Definition: vtkCell.h:58
a 3D cell defined by a set of convex points
cell represents a cubic , isoparametric 1D line
Definition: vtkCubicLine.h:43
general representation of visualization data
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:30
provides thread-safe access to cells
a 3D cell that represents a prism with hexagonal base
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:42
list of point or cell ids
Definition: vtkIdList.h:31
vtkIdType * GetPointer(const vtkIdType i)
Get a pointer to a particular data index.
Definition: vtkIdList.h:126
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition: vtkIdList.h:57
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
A 3D cell that represents an arbitrary order Lagrange hex.
A 3D cell that represents an arbitrary order Lagrange tetrahedron.
A 2D cell that represents an arbitrary order Lagrange triangle.
A 3D cell that represents an arbitrary order Lagrange wedge.
cell represents a 1D line
Definition: vtkLine.h:31
a 3D cell that represents a convex prism with pentagonal base
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:35
cell represents a set of 1D lines
Definition: vtkPolyLine.h:37
cell represents a set of 0D vertices
Definition: vtkPolyVertex.h:33
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:40
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:58
a 3D cell that represents a linear pyramid
Definition: vtkPyramid.h:44
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:36
cell represents a parabolic, isoparametric edge
cell represents a parabolic, 20-node isoparametric hexahedron
cell represents a quadratic-linear, 6-node isoparametric quad
cell represents a, 12-node isoparametric wedge
a cell that represents a parabolic n-sided polygon
cell represents a parabolic, 13-node isoparametric pyramid
cell represents a parabolic, 8-node isoparametric quad
cell represents a parabolic, 10-node isoparametric tetrahedron
cell represents a parabolic, isoparametric triangle
cell represents a parabolic, 15-node isoparametric wedge
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:42
cell represents a parabolic, 27-node isoparametric hexahedron
cell represents a parabolic, 13-node isoparametric pyramid
a cell that represents a triangle strip
a cell that represents a triangle
Definition: vtkTriangle.h:36
dynamic, self-adjusting array of unsigned char
dataset represents arbitrary combinations of all possible cell types.
dataset represents arbitrary combinations of all possible cell types
vtkBezierCurve * BezierCurve
void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId)
Use these methods only if the dataset has been specified as Editable.
void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations, vtkCellArray *cells)
Special methods specific to vtkUnstructuredGrid for defining the cells composing the dataset.
void GetCellTypes(vtkCellTypes *types) override
Get a list of types of cells in a dataset.
vtkLagrangeWedge * LagrangeWedge
vtkQuadraticLinearWedge * QuadraticLinearWedge
vtkQuadraticQuad * QuadraticQuad
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkQuadraticTriangle * QuadraticTriangle
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkQuadraticPyramid * QuadraticPyramid
void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations, vtkCellArray *cells, vtkIdTypeArray *faceLocations, vtkIdTypeArray *faces)
Special methods specific to vtkUnstructuredGrid for defining the cells composing the dataset.
void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override
static vtkUnstructuredGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkBezierQuadrilateral * BezierQuadrilateral
vtkSmartPointer< vtkIdTypeArray > CellLocations
vtkQuadraticLinearQuad * QuadraticLinearQuad
vtkTriangleStrip * TriangleStrip
vtkBiQuadraticTriangle * BiQuadraticTriangle
vtkLagrangeQuadrilateral * LagrangeQuadrilateral
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts)
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids.
vtkBiQuadraticQuadraticWedge * BiQuadraticQuadraticWedge
vtkIdType InternalInsertNextCell(int type, vtkIdList *ptIds) override
virtual vtkMTimeType GetMeshMTime()
Return the mesh (geometry/topology) modification time.
vtkSmartPointer< vtkCellTypes > DistinctCellTypes
vtkQuadraticTetra * QuadraticTetra
vtkMTimeType DistinctCellTypesUpdateMTime
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkSmartPointer< vtkIdTypeArray > Faces
vtkPolyVertex * PolyVertex
vtkQuadraticPolygon * QuadraticPolygon
vtkLagrangeHexahedron * LagrangeHexahedron
static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType *inFaceStream, vtkIdType &nCellpts, vtkCellArray *cellArray, vtkIdTypeArray *faces)
A static method for converting an input polyhedron cell stream of format [nFace0Pts,...
vtkTriQuadraticHexahedron * TriQuadraticHexahedron
vtkLagrangeTriangle * LagrangeTriangle
vtkHexagonalPrism * HexagonalPrism
static vtkUnstructuredGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
vtkBiQuadraticQuad * BiQuadraticQuad
vtkQuadraticEdge * QuadraticEdge
int IsHomogeneous() override
Returns whether cells are all of the same type.
static void ConvertFaceStreamPointIds(vtkIdList *faceStream, vtkIdType *idMap)
Convert pid in a face stream into idMap[pid].
vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override
void GetCellNeighbors(vtkIdType cellId, vtkIdType npts, const vtkIdType *ptIds, vtkIdList *cellIds)
A topological inquiry to retrieve all of the cells using list of points exclusive of the current cell...
vtkIdTypeArray * GetFaceLocations()
Get pointer to faces and facelocations.
void ResizeCellList(vtkIdType ptId, int size)
Use these methods only if the dataset has been specified as Editable.
vtkBiQuadraticQuadraticHexahedron * BiQuadraticQuadraticHexahedron
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
int InitializeFacesRepresentation(vtkIdType numPrevCells)
Special function used by vtkUnstructuredGridReader.
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkHexahedron * Hexahedron
vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]) override
static void DecomposeAPolyhedronCell(const vtkIdType *polyhedronCellStream, vtkIdType &nCellpts, vtkIdType &nCellfaces, vtkCellArray *cellArray, vtkIdTypeArray *faces)
vtkBezierWedge * BezierWedge
bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType *ptIds)
A topological inquiry to determine whether a topological entity (e.g., point, edge,...
vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[])
Use these methods only if the dataset has been specified as Editable.
vtkSmartPointer< vtkAbstractCellLinks > Links
vtkIdType GetNumberOfCells() override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
void Allocate(vtkIdType numCells=1000, int vtkNotUsed(extSize)=1000) override
Method allocates initial storage for the cell connectivity.
vtkLagrangeTetra * LagrangeTetra
vtkQuadraticHexahedron * QuadraticHexahedron
bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize)
Pre-allocate memory in internal data structures.
void Reset()
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkSmartPointer< vtkIdTypeArray > FaceLocations
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkBezierTetra * BezierTetra
void GetPointCells(vtkIdType ptId, vtkIdType &ncells, vtkIdType *&cells)
Special (efficient) operation to return the list of cells using the specified point ptId.
vtkIdType * GetFaces(vtkIdType cellId)
Special support for polyhedron.
vtkSmartPointer< vtkUnsignedCharArray > Types
vtkLagrangeCurve * LagrangeCurve
vtkIdTypeArray * GetCellLocationsArray()
Get the array of all the starting indices of cell definitions in the cell array.
void RemoveGhostCells()
This method will remove any cell that is marked as ghost (has the vtkDataSetAttributes::DUPLICATECELL...
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
A topological inquiry to retrieve all of the cells using list of points exclusive of the current cell...
static vtkUnstructuredGrid * ExtendedNew()
void CopyStructure(vtkDataSet *ds) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkConvexPointSet * ConvexPointSet
vtkSmartPointer< vtkCellArray > Connectivity
vtkBezierHexahedron * BezierHexahedron
vtkCellIterator * NewCellIterator() override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
~vtkUnstructuredGrid() override
static void DecomposeAPolyhedronCell(vtkCellArray *polyhedronCellArray, vtkIdType &nCellpts, vtkIdType &nCellfaces, vtkCellArray *cellArray, vtkIdTypeArray *faces)
A static method for converting a polyhedron vtkCellArray of format [nCellFaces, nFace0Pts,...
vtkTriQuadraticPyramid * TriQuadraticPyramid
virtual int GetGhostLevel()
Get the ghost level.
int GetCellType(vtkIdType cellId) override
Get the type of the cell with the given cellId.
vtkQuadraticWedge * QuadraticWedge
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType *faceStream, vtkIdType *idMap)
Convert pid in a face stream into idMap[pid].
void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array) override
Fill vtkIdTypeArray container with list of cell Ids.
virtual int GetPiece()
Set / Get the piece and the number of pieces.
vtkPentagonalPrism * PentagonalPrism
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkBezierTriangle * BezierTriangle
vtkIdTypeArray * GetFaces()
Get pointer to faces and facelocations.
virtual int GetNumberOfPieces()
Set / Get the piece and the number of pieces.
void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId)
Use these methods only if the dataset has been specified as Editable.
vtkPolyhedron * Polyhedron
static vtkUnstructuredGrid * New()
Standard instantiation method.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
int GetDataObjectType() override
Standard vtkDataSet API methods.
a cell that represents a 3D point
Definition: vtkVertex.h:31
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:39
a 3D cell that represents a linear wedge
Definition: vtkWedge.h:44
@ info
Definition: vtkX3D.h:382
@ type
Definition: vtkX3D.h:522
@ size
Definition: vtkX3D.h:259
#define VTK_DEPRECATED_IN_9_0_0(reason)
int vtkIdType
Definition: vtkType.h:332
#define VTK_UNSTRUCTURED_GRID
Definition: vtkType.h:81
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)