VTK  9.0.1
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 "vtkIdTypeArray.h" //inline GetCellPoints()
35 
36 #include "vtkSmartPointer.h" // for smart pointer
37 
38 class vtkCellArray;
40 class vtkBezierCurve;
43 class vtkBezierTriangle;
44 class vtkBezierTetra;
45 class vtkBezierWedge;
46 class vtkConvexPointSet;
47 class vtkEmptyCell;
48 class vtkHexahedron;
49 class vtkIdList;
50 class vtkIdTypeArray;
51 class vtkLagrangeCurve;
55 class vtkLagrangeTetra;
56 class vtkLagrangeWedge;
57 class vtkLine;
58 class vtkPixel;
59 class vtkPolyLine;
60 class vtkPolyVertex;
61 class vtkPolygon;
62 class vtkPyramid;
63 class vtkPentagonalPrism;
64 class vtkHexagonalPrism;
65 class vtkQuad;
66 class vtkQuadraticEdge;
68 class vtkQuadraticWedge;
71 class vtkQuadraticQuad;
72 class vtkQuadraticTetra;
74 class vtkTetra;
75 class vtkTriangle;
76 class vtkTriangleStrip;
78 class vtkVertex;
79 class vtkVoxel;
80 class vtkWedge;
84 class vtkBiQuadraticQuad;
88 class vtkCubicLine;
89 class vtkPolyhedron;
90 class vtkIdTypeArray;
91 
92 class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGrid : public vtkUnstructuredGridBase
93 {
94 public:
98  static vtkUnstructuredGrid* New();
99 
101 
105  void PrintSelf(ostream& os, vtkIndent indent) override;
107 
111  int GetDataObjectType() override { return VTK_UNSTRUCTURED_GRID; }
112 
122  bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
123  {
124  return this->AllocateExact(numCells, numCells * maxCellSize);
125  }
126 
136  bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
137 
147  void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
148  {
149  this->AllocateExact(numCells, numCells);
150  }
151 
153 
156  void Reset();
157  void CopyStructure(vtkDataSet* ds) override;
158  vtkIdType GetNumberOfCells() override;
159  using vtkDataSet::GetCell;
160  vtkCell* GetCell(vtkIdType cellId) override;
161  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
162  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
163  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
164  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
165  vtkCellIterator* NewCellIterator() override;
167 
171  int GetCellType(vtkIdType cellId) override;
172 
184  void GetCellTypes(vtkCellTypes* types) override;
185 
196  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
197  {
198  this->Connectivity->GetCellAtId(cellId, npts, pts);
199  }
200 
202 
207  void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
208  VTK_SIZEHINT(cells, ncells);
209 #ifndef VTK_LEGACY_REMOVE
210  VTK_LEGACY(void GetPointCells(vtkIdType ptId, unsigned short& ncells, vtkIdType*& cells))
211  VTK_SIZEHINT(cells, ncells);
212 #endif
213 
214 
221  vtkUnsignedCharArray* GetCellTypesArray();
222 
226  void Squeeze() override;
227 
231  void Initialize() override;
232 
236  int GetMaxCellSize() override;
237 
242  void BuildLinks();
243 
251  vtkAbstractCellLinks* GetCellLinks();
252 
259  void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
260 
269  void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType const*& ptIds);
270 
272 
281  void SetCells(int type, vtkCellArray* cells);
282  void SetCells(int* types, vtkCellArray* cells);
283  void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells);
284  void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
285  vtkIdTypeArray* faces);
287 
291  vtkCellArray* GetCells() { return this->Connectivity; }
292 
299  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
300 
302 
306  vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
307  void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
308  void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
309  void ResizeCellList(vtkIdType ptId, int size);
311 
313 
316  virtual int GetPiece();
317  virtual int GetNumberOfPieces();
319 
323  virtual int GetGhostLevel();
324 
333  unsigned long GetActualMemorySize() override;
334 
336 
339  void ShallowCopy(vtkDataObject* src) override;
340  void DeepCopy(vtkDataObject* src) override;
342 
348  void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
349 
353  int IsHomogeneous() override;
354 
359  void RemoveGhostCells();
360 
362 
366  static vtkUnstructuredGrid* GetData(vtkInformationVector* v, int i = 0);
368 
372  vtkIdType* GetFaces(vtkIdType cellId);
373 
375 
378  vtkIdTypeArray* GetFaces();
379  vtkIdTypeArray* GetFaceLocations();
381 
389  int InitializeFacesRepresentation(vtkIdType numPrevCells);
390 
398  virtual vtkMTimeType GetMeshMTime();
399 
412  static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
413  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
414 
415  static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
416  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
417 
430  static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
431  vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
432 
439  static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
440 
446  static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
447 
448  //====================== Begin Legacy Methods ================================
449 
457  vtkIdTypeArray* GetCellLocationsArray();
458 
460 
476  void SetCells(
477  vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
478  void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
479  vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
481 
482  //====================== End Legacy Methods ==================================
483 
484 protected:
486  ~vtkUnstructuredGrid() override;
487 
488  // These are all the cells that vtkUnstructuredGrid can represent. Used by
489  // GetCell() (and similar) methods.
537 
538  // Points derived from vtkPointSet.
539  // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
540  // derived from vtkDataSet.
541 
542  // The heart of the data represention. The points are managed by the
543  // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
544  // point ids that define the cell) and the cell type, represented by the
545  // Connectivity and Types arrays.
546  // Finally, when certain topological information is needed (e.g.,
547  // all the cells that use a point), the cell links array is built.
551 
552  // Set of all cell types present in the grid. All entries are unique.
554 
555  // The DistinctCellTypes is cached, so we keep track of the last time it was
556  // updated so we can compare it to the modified time of the Types array.
558 
559  // Special support for polyhedra/cells with explicit face representations.
560  // The Faces class represents polygonal faces using a modified vtkCellArray
561  // structure. Each cell face list begins with the total number of faces in
562  // the cell, followed by a vtkCellArray data organization
563  // (n,i,j,k,n,i,j,k,...).
566 
567  // Legacy support -- stores the old-style cell array locations.
569 
570  vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
571  vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
572  vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[],
573  vtkIdType nfaces, const vtkIdType faces[]) override;
574  void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
575 
576 private:
577  // Hide these from the user and the compiler.
578  vtkUnstructuredGrid(const vtkUnstructuredGrid&) = delete;
579  void operator=(const vtkUnstructuredGrid&) = delete;
580 
581  void Cleanup();
582 };
583 
584 #endif
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.
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
Topological inquiry to get cells using point.
vtkTriangleStrip * TriangleStrip
static vtkDataObject * New()
cell represents a parabolic, 13-node isoparametric pyramid
vtkTriQuadraticHexahedron * TriQuadraticHexahedron
vtkLagrangeTriangle * LagrangeTriangle
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
vtkLagrangeWedge * LagrangeWedge
vtkSmartPointer< vtkCellTypes > DistinctCellTypes
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
a cell that represents a 3D point
Definition: vtkVertex.h:30
a 3D cell that represents a linear pyramid
Definition: vtkPyramid.h:43
vtkQuadraticWedge * QuadraticWedge
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:34
cell represents a parabolic, 9-node isoparametric quad
vtkBezierTriangle * BezierTriangle
vtkBezierWedge * BezierWedge
A 2D cell that represents an arbitrary order Bezier triangle.
vtkBezierQuadrilateral * BezierQuadrilateral
vtkBezierHexahedron * BezierHexahedron
vtkQuadraticTriangle * QuadraticTriangle
vtkPentagonalPrism * PentagonalPrism
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:35
A 3D cell that represents an arbitrary order Bezier hex.
dynamic, self-adjusting array of vtkIdType
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:29
vtkQuadraticHexahedron * QuadraticHexahedron
int vtkIdType
Definition: vtkType.h:338
cell represents a set of 0D vertices
Definition: vtkPolyVertex.h:32
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
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methdos for type information and printing.
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:42
vtkBiQuadraticQuad * BiQuadraticQuad
a cell that represents a triangle strip
vtkMTimeType DistinctCellTypesUpdateMTime
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:41
a 3D cell that represents a convex prism with pentagonal base
vtkBezierCurve * BezierCurve
cell represents a 1D line
Definition: vtkLine.h:29
abstract class to specify cell behavior
Definition: vtkCell.h:56
A 3D cell that represents an arbitrary order Lagrange wedge.
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:38
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:33
vtkQuadraticQuad * QuadraticQuad
virtual int GetMaxCellSize()=0
Convenience method returns largest cell size in dataset.
vtkSmartPointer< vtkAbstractCellLinks > Links
vtkLagrangeHexahedron * LagrangeHexahedron
list of point or cell ids
Definition: vtkIdList.h:30
void Initialize() override
Reset to an empty state and free any memory.
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
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:39
vtkSmartPointer< vtkIdTypeArray > CellLocations
vtkLagrangeTetra * LagrangeTetra
cell represents a parabolic, isoparametric triangle
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:41
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
vtkBiQuadraticQuadraticWedge * BiQuadraticQuadraticWedge
object to represent cell connectivity
Definition: vtkCellArray.h:179
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:35
cell represents a parabolic, 20-node isoparametric hexahedron
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
Definition: vtkPolyhedron.h:57
vtkCellArray * GetCells()
Return the unstructured grid connectivity array.
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.
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.
general representation of visualization data
Definition: vtkDataObject.h:59
cell represents a, 12-node isoparametric wedge
vtkSmartPointer< vtkIdTypeArray > Faces
vtkSmartPointer< vtkCellArray > Connectivity
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:47
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:43
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:89
vtkQuadraticPyramid * QuadraticPyramid
cell represents a set of 1D lines
Definition: vtkPolyLine.h:36
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
void Allocate(vtkIdType numCells=1000, int vtkNotUsed(extSize)=1000) override
Method allocates initial storage for the cell connectivity.