VTK  9.3.1
vtkUnstructuredGrid.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
22 #ifndef vtkUnstructuredGrid_h
23 #define vtkUnstructuredGrid_h
24 
25 #include "vtkAbstractCellLinks.h" // For vtkAbstractCellLinks
26 #include "vtkCellArray.h" // inline GetCellPoints()
27 #include "vtkCommonDataModelModule.h" // For export macro
28 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
29 #include "vtkIdTypeArray.h" // inline GetCellPoints()
31 
32 #include "vtkSmartPointer.h" // for smart pointer
33 
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkCellArray;
36 class vtkBezierCurve;
39 class vtkBezierTriangle;
40 class vtkBezierTetra;
41 class vtkBezierWedge;
42 class vtkConvexPointSet;
43 class vtkEmptyCell;
44 class vtkHexahedron;
45 class vtkIdList;
46 class vtkIdTypeArray;
47 class vtkLagrangeCurve;
51 class vtkLagrangeTetra;
52 class vtkLagrangeWedge;
53 class vtkLine;
54 class vtkPixel;
55 class vtkPolyLine;
56 class vtkPolyVertex;
57 class vtkPolygon;
58 class vtkPyramid;
59 class vtkPentagonalPrism;
60 class vtkHexagonalPrism;
61 class vtkQuad;
62 class vtkQuadraticEdge;
64 class vtkQuadraticWedge;
67 class vtkQuadraticQuad;
68 class vtkQuadraticTetra;
70 class vtkTetra;
71 class vtkTriangle;
72 class vtkTriangleStrip;
74 class vtkVertex;
75 class vtkVoxel;
76 class vtkWedge;
81 class vtkBiQuadraticQuad;
85 class vtkCubicLine;
86 class vtkPolyhedron;
87 class vtkIdTypeArray;
88 
89 class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGrid : public vtkUnstructuredGridBase
90 {
91 public:
95  static vtkUnstructuredGrid* New();
97 
99 
103  void PrintSelf(ostream& os, vtkIndent indent) override;
105 
109  int GetDataObjectType() override { return VTK_UNSTRUCTURED_GRID; }
110 
120  bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
121  {
122  return this->AllocateExact(numCells, numCells * maxCellSize);
123  }
124 
134  bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
135 
145  void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
146  {
147  this->AllocateExact(numCells, numCells);
148  }
149 
151 
154  void Reset();
155  void CopyStructure(vtkDataSet* ds) override;
156  vtkIdType GetNumberOfCells() override;
157  using vtkDataSet::GetCell;
158  vtkCell* GetCell(vtkIdType cellId) override;
159  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
160  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
161  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
162  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
163  vtkCellIterator* NewCellIterator() override;
165 
169  int GetCellType(vtkIdType cellId) override;
170 
174  vtkIdType GetCellSize(vtkIdType cellId) override;
175 
187  void GetCellTypes(vtkCellTypes* types) override;
188 
201  vtkUnsignedCharArray* GetDistinctCellTypesArray();
202 
215  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
216  {
217  this->Connectivity->GetCellAtId(cellId, npts, pts);
218  }
219 
236  vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override
237  {
238  this->Connectivity->GetCellAtId(cellId, npts, pts, ptIds);
239  }
240 
242 
247  void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
248  VTK_SIZEHINT(cells, ncells);
250 
257  vtkUnsignedCharArray* GetCellTypesArray();
258 
262  void Squeeze() override;
263 
267  void Initialize() override;
268 
272  int GetMaxCellSize() override;
273 
278  void BuildLinks();
279 
281 
284  vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
285  vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
287 
295  VTK_DEPRECATED_IN_9_3_0("Use GetLinks() instead.")
296  vtkAbstractCellLinks* GetCellLinks();
297 
304  void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
305 
314  void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType const*& ptIds);
315 
317 
326  void SetCells(int type, vtkCellArray* cells);
327  void SetCells(int* types, vtkCellArray* cells);
328  void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells);
329  void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
330  vtkIdTypeArray* faces);
332 
336  vtkCellArray* GetCells() { return this->Connectivity; }
337 
339 
345  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
346  {
347  this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
348  }
349  void GetCellNeighbors(
350  vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
352 
354 
364  bool IsCellBoundary(
365  vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdType& neighborCellId);
366  bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds)
367  {
368  vtkIdType neighborCellId;
369  return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId);
370  }
371  VTK_DEPRECATED_IN_9_3_0("Use the overload that doesn't take a vtkIdList instead.")
372  bool IsCellBoundary(
373  vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* vtkNotUsed(cellIds))
374  {
375  return this->IsCellBoundary(cellId, npts, ptIds);
376  }
378 
380 
384  vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
385  void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
386  void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
387  void ResizeCellList(vtkIdType ptId, int size);
389 
391 
394  virtual int GetPiece();
395  virtual int GetNumberOfPieces();
397 
401  virtual int GetGhostLevel();
402 
411  unsigned long GetActualMemorySize() override;
412 
414 
417  void ShallowCopy(vtkDataObject* src) override;
418  void DeepCopy(vtkDataObject* src) override;
420 
426  void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
427 
431  int IsHomogeneous() override;
432 
438  void RemoveGhostCells();
439 
441 
445  static vtkUnstructuredGrid* GetData(vtkInformationVector* v, int i = 0);
447 
451  vtkIdType* GetFaces(vtkIdType cellId);
452 
454 
457  vtkIdTypeArray* GetFaces();
458  vtkIdTypeArray* GetFaceLocations();
460 
468  int InitializeFacesRepresentation(vtkIdType numPrevCells);
469 
477  virtual vtkMTimeType GetMeshMTime();
478 
491  static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
492  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
493 
494  static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
495  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
496 
509  static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
510  vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
511 
518  static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
519 
525  static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
526 
527  //====================== Begin Legacy Methods ================================
528 
536  vtkIdTypeArray* GetCellLocationsArray();
537 
539 
555  void SetCells(
556  vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
557  void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
558  vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
560 
561  //====================== End Legacy Methods ==================================
562 
563 protected:
565  ~vtkUnstructuredGrid() override;
566 
567  void ReportReferences(vtkGarbageCollector*) override;
568 
569  // These are all the cells that vtkUnstructuredGrid can represent. Used by
570  // GetCell() (and similar) methods.
619 
620  // Points derived from vtkPointSet.
621  // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
622  // derived from vtkDataSet.
623 
624  // The heart of the data representation. The points are managed by the
625  // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
626  // point ids that define the cell) and the cell type, represented by the
627  // Connectivity and Types arrays.
628  // Finally, when certain topological information is needed (e.g.,
629  // all the cells that use a point), the cell links array is built.
633 
634  // Set of all cell types present in the grid. All entries are unique.
636 
637  // The DistinctCellTypes is cached, so we keep track of the last time it was
638  // updated so we can compare it to the modified time of the Types array.
640 
641  // Special support for polyhedra/cells with explicit face representations.
642  // The Faces class represents polygonal faces using a modified vtkCellArray
643  // structure. Each cell face list begins with the total number of faces in
644  // the cell, followed by a vtkCellArray data organization
645  // (n,i,j,k,n,i,j,k,...).
648 
649  // Legacy support -- stores the old-style cell array locations.
651 
652  vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
653  vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
654  vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[],
655  vtkIdType nfaces, const vtkIdType faces[]) override;
656  void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
657 
658 private:
659  // Hide these from the user and the compiler.
660  vtkUnstructuredGrid(const vtkUnstructuredGrid&) = delete;
661  void operator=(const vtkUnstructuredGrid&) = delete;
662 
663  void Cleanup();
664 };
665 
666 VTK_ABI_NAMESPACE_END
667 #endif
vtkIdType GetCellSize(vtkIdType) override
This method always returns 1, as all cells are point in a pure vtkPointSet.
Definition: vtkPointSet.h:158
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
static vtkUnstructuredGridBase * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkTriangleStrip * TriangleStrip
cell represents a parabolic, 13-node isoparametric pyramid
vtkTriQuadraticHexahedron * TriQuadraticHexahedron
vtkLagrangeTriangle * LagrangeTriangle
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
vtkLagrangeWedge * LagrangeWedge
vtkSmartPointer< vtkCellTypes > DistinctCellTypes
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
a cell that represents a 3D point
Definition: vtkVertex.h:22
a 3D cell that represents a linear pyramid
Definition: vtkPyramid.h:35
vtkQuadraticWedge * QuadraticWedge
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:26
cell represents a parabolic, 9-node isoparametric quad
vtkBezierTriangle * BezierTriangle
vtkBezierWedge * BezierWedge
A 2D cell that represents an arbitrary order Bezier triangle.
bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType *ptIds)
A topological inquiry to determine whether a topological entity (e.g., point, edge, or face) defined by the point ids (ptIds of length npts) is a boundary entity of a specified cell (indicated by cellId).
vtkBezierQuadrilateral * BezierQuadrilateral
void GetCellPoints(vtkIdType, vtkIdList *idList) override
Topological inquiry to get points defining cell.
Definition: vtkPointSet.h:139
vtkBezierHexahedron * BezierHexahedron
vtkQuadraticTriangle * QuadraticTriangle
vtkPentagonalPrism * PentagonalPrism
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:27
A 3D cell that represents an arbitrary order Bezier hex.
cell represents a parabolic, 19-node isoparametric pyramid
dynamic, self-adjusting array of vtkIdType
vtkIdType GetNumberOfCells() override
This method always returns 0, as there are no cells in a vtkPointSet.
Definition: vtkPointSet.h:123
vtkTriQuadraticPyramid * TriQuadraticPyramid
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:21
vtkQuadraticHexahedron * QuadraticHexahedron
int vtkIdType
Definition: vtkType.h:315
cell represents a set of 0D vertices
Definition: vtkPolyVertex.h:24
void Squeeze() override
Reclaim any unused memory.
A 3D cell that represents an arbitrary order Lagrange tetrahedron.
vtkQuadraticTetra * QuadraticTetra
cell represents a parabolic, 18-node isoparametric wedge
int GetCellType(vtkIdType) override
This method always returns VTK_EMPTY_CELL, as there is no cell in a vtkPointSet.
Definition: vtkPointSet.h:152
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
Detect and break reference loops.
provides thread-safe access to cells
vtkPolyhedron * Polyhedron
cell represents a biquadratic, 24-node isoparametric hexahedron
a 3D cell that represents a prism with hexagonal base
virtual vtkIdType InternalInsertNextCell(int type, vtkIdList *ptIds)=0
vtkHexagonalPrism * HexagonalPrism
cell represents a cubic , isoparametric 1D line
Definition: vtkCubicLine.h:34
vtkBiQuadraticQuad * BiQuadraticQuad
a cell that represents a triangle strip
vtkMTimeType DistinctCellTypesUpdateMTime
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:33
a 3D cell that represents a convex prism with pentagonal base
vtkBezierCurve * BezierCurve
cell represents a 1D line
Definition: vtkLine.h:22
abstract class to specify cell behavior
Definition: vtkCell.h:49
#define VTK_DEPRECATED_IN_9_3_0(reason)
A 3D cell that represents an arbitrary order Lagrange wedge.
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:30
A 2D cell that represents an arbitrary order Lagrange triangle.
cell represents a parabolic, 8-node isoparametric quad
virtual void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array)=0
Fill vtkIdTypeArray container with list of cell Ids.
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkQuadraticQuad * QuadraticQuad
vtkSmartPointer< vtkAbstractCellLinks > Links
vtkLagrangeHexahedron * LagrangeHexahedron
static vtkPointSet * New()
Standard instantiation method.
list of point or cell ids
Definition: vtkIdList.h:22
void Initialize() override
Reset to an empty state and free any memory.
A 3D cell that represents an arbitrary order Bezier tetrahedron.
dataset represents arbitrary combinations of all possible cell types
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts)
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids...
vtkBiQuadraticTriangle * BiQuadraticTriangle
vtkSmartPointer< vtkUnsignedCharArray > Types
vtkHexahedron * Hexahedron
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:31
vtkSmartPointer< vtkIdTypeArray > CellLocations
vtkLagrangeTetra * LagrangeTetra
cell represents a parabolic, isoparametric triangle
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:33
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition: vtkIdList.h:49
virtual void GetCellTypes(vtkCellTypes *types)
Get a list of types of cells in a dataset.
cell represents a parabolic, 10-node isoparametric tetrahedron
a 3D cell defined by a set of convex points
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e...
#define VTK_SIZEHINT(...)
dynamic, self-adjusting array of unsigned char
A 3D cell that represents an arbitrary order Bezier wedge.
vtkQuadraticLinearWedge * QuadraticLinearWedge
vtkLagrangeQuadrilateral * LagrangeQuadrilateral
int GetMaxCellSize() override
This method always returns 0, as there are no cells in a vtkPointSet.
Definition: vtkPointSet.h:124
static vtkPointSet * ExtendedNew()
vtkBiQuadraticQuadraticWedge * BiQuadraticQuadraticWedge
object to represent cell connectivity
Definition: vtkCellArray.h:175
vtkBiQuadraticQuadraticHexahedron * BiQuadraticQuadraticHexahedron
virtual void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[])=0
cell represents a parabolic, 27-node isoparametric hexahedron
vtkCellIterator * NewCellIterator() override
Return an iterator that traverses the cells in this data set.
a cell that represents a parabolic n-sided polygon
vtkLagrangeCurve * LagrangeCurve
cell represents a parabolic, isoparametric edge
virtual int IsHomogeneous()=0
Traverse cells and determine if cells are all of the same type.
a cell that represents a triangle
Definition: vtkTriangle.h:27
cell represents a parabolic, 20-node isoparametric hexahedron
void GetPointCells(vtkIdType, vtkIdList *idList) override
Topological inquiry to get cells using point.
Definition: vtkPointSet.h:140
int GetDataObjectType() override
Standard vtkDataSet API methods.
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
cell represents a parabolic, isoparametric triangle
vtkBezierTetra * BezierTetra
cell represents a parabolic, 15-node isoparametric wedge
vtkQuadraticLinearQuad * QuadraticLinearQuad
vtkConvexPointSet * ConvexPointSet
Store zero or more vtkInformation instances.
A 3D cell defined by a set of polygonal faces.
Efficient cell iterator for vtkDataSet topologies.
vtkPolyVertex * PolyVertex
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkCell * GetCell(vtkIdType) override
This method always return a vtkEmptyCell, as there is no cell in a vtkPointSet.
A 3D cell that represents an arbitrary order Lagrange hex.
void CopyStructure(vtkDataSet *pd) override
Copy the geometric structure of an input point set object.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts, vtkIdList *ptIds) override
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids...
general representation of visualization data
Definition: vtkDataObject.h:54
cell represents a, 12-node isoparametric wedge
void ReportReferences(vtkGarbageCollector *) override
vtkSmartPointer< vtkIdTypeArray > Faces
vtkSmartPointer< vtkCellArray > Connectivity
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:45
cell represents a quadratic-linear, 6-node isoparametric quad
vtkQuadraticPolygon * QuadraticPolygon
dataset represents arbitrary combinations of all possible cell types.
vtkQuadraticEdge * QuadraticEdge
vtkSmartPointer< vtkIdTypeArray > FaceLocations
a 3D cell that represents a linear wedge
Definition: vtkWedge.h:35
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
#define VTK_UNSTRUCTURED_GRID
Definition: vtkType.h:69
vtkQuadraticPyramid * QuadraticPyramid
cell represents a set of 1D lines
Definition: vtkPolyLine.h:29
void Allocate(vtkIdType numCells=1000, int vtkNotUsed(extSize)=1000) override
Method allocates initial storage for the cell connectivity.
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...
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
Definition: vtkIdList.h:115