VTK  9.2.6
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=========================================================================*/
43#ifndef vtkUnstructuredGrid_h
44#define vtkUnstructuredGrid_h
45
46#include "vtkAbstractCellLinks.h" // For vtkAbstractCellLinks
47#include "vtkCellArray.h" // inline GetCellPoints()
48#include "vtkCommonDataModelModule.h" // For export macro
49#include "vtkDeprecation.h" // For deprecation
50#include "vtkIdTypeArray.h" // inline GetCellPoints()
52
53#include "vtkSmartPointer.h" // for smart pointer
54
55class vtkCellArray;
57class vtkBezierCurve;
61class vtkBezierTetra;
62class vtkBezierWedge;
64class vtkEmptyCell;
65class vtkHexahedron;
66class vtkIdList;
67class vtkIdTypeArray;
74class vtkLine;
75class vtkPixel;
76class vtkPolyLine;
77class vtkPolyVertex;
78class vtkPolygon;
79class vtkPyramid;
82class vtkQuad;
91class vtkTetra;
92class vtkTriangle;
95class vtkVertex;
96class vtkVoxel;
97class vtkWedge;
106class vtkCubicLine;
107class vtkPolyhedron;
108class vtkIdTypeArray;
109
110class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGrid : public vtkUnstructuredGridBase
111{
112public:
118
120
124 void PrintSelf(ostream& os, vtkIndent indent) override;
126
130 int GetDataObjectType() override { return VTK_UNSTRUCTURED_GRID; }
131
141 bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
142 {
143 return this->AllocateExact(numCells, numCells * maxCellSize);
144 }
145
155 bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
156
166 void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
167 {
168 this->AllocateExact(numCells, numCells);
169 }
170
172
175 void Reset();
176 void CopyStructure(vtkDataSet* ds) override;
179 vtkCell* GetCell(vtkIdType cellId) override;
180 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
181 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
182 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
183 void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
186
190 int GetCellType(vtkIdType cellId) override;
191
196
208 VTK_DEPRECATED_IN_9_2_0("Please use GetDistinctCellTypesArray() instead.")
209 void GetCellTypes(vtkCellTypes* types) override;
210
223 vtkUnsignedCharArray* GetDistinctCellTypesArray();
224
237 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
238 {
239 this->Connectivity->GetCellAtId(cellId, npts, pts);
240 }
241
258 vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override
259 {
260 this->Connectivity->GetCellAtId(cellId, npts, pts, ptIds);
261 }
262
264
269 void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
270 VTK_SIZEHINT(cells, ncells);
272
280
284 void Squeeze() override;
285
289 void Initialize() override;
290
294 int GetMaxCellSize() override;
295
301
303
309
318
325 void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
326
335 void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType const*& ptIds);
336
338
347 void SetCells(int type, vtkCellArray* cells);
348 void SetCells(int* types, vtkCellArray* cells);
350 void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
351 vtkIdTypeArray* faces);
353
357 vtkCellArray* GetCells() { return this->Connectivity; }
358
360
366 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
367 {
368 this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
369 }
371 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
373
375
386 bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds);
387 bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
389
391
395 vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
398 void ResizeCellList(vtkIdType ptId, int size);
400
402
405 virtual int GetPiece();
406 virtual int GetNumberOfPieces();
408
412 virtual int GetGhostLevel();
413
422 unsigned long GetActualMemorySize() override;
423
425
428 void ShallowCopy(vtkDataObject* src) override;
429 void DeepCopy(vtkDataObject* src) override;
431
437 void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
438
442 int IsHomogeneous() override;
443
450
452
458
463
465
471
480
489
502 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
503 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
504
505 static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
506 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
507
520 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
521 vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
522
529 static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
530
536 static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
537
538 //====================== Begin Legacy Methods ================================
539
548
550
567 vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
568 void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
569 vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
571
572 //====================== End Legacy Methods ==================================
573
574protected:
577
578 // These are all the cells that vtkUnstructuredGrid can represent. Used by
579 // GetCell() (and similar) methods.
628
629 // Points derived from vtkPointSet.
630 // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
631 // derived from vtkDataSet.
632
633 // The heart of the data representation. The points are managed by the
634 // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
635 // point ids that define the cell) and the cell type, represented by the
636 // Connectivity and Types arrays.
637 // Finally, when certain topological information is needed (e.g.,
638 // all the cells that use a point), the cell links array is built.
642
643 // Set of all cell types present in the grid. All entries are unique.
645
646 // The DistinctCellTypes is cached, so we keep track of the last time it was
647 // updated so we can compare it to the modified time of the Types array.
649
650 // Special support for polyhedra/cells with explicit face representations.
651 // The Faces class represents polygonal faces using a modified vtkCellArray
652 // structure. Each cell face list begins with the total number of faces in
653 // the cell, followed by a vtkCellArray data organization
654 // (n,i,j,k,n,i,j,k,...).
657
658 // Legacy support -- stores the old-style cell array locations.
660
661 vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
662 vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
664 vtkIdType nfaces, const vtkIdType faces[]) override;
665 void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
666
667private:
668 // Hide these from the user and the compiler.
670 void operator=(const vtkUnstructuredGrid&) = delete;
671
672 void Cleanup();
673};
674
675#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
Efficient cell iterator for vtkDataSet topologies.
object provides direct access to cells in vtkCellArray and type information
abstract class to specify cell behavior
Definition vtkCell.h:70
a 3D cell defined by a set of convex points
cell represents a cubic , isoparametric 1D line
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:72
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
provides thread-safe access to cells
a 3D cell that represents a prism with hexagonal base
a cell that represents a linear 3D hexahedron
list of point or cell ids
Definition vtkIdList.h:43
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition vtkIdList.h:69
vtkIdType * GetPointer(const vtkIdType i)
Get a pointer to a particular data index.
Definition vtkIdList.h:138
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:49
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:43
a 3D cell that represents a convex prism with pentagonal base
a cell that represents an orthogonal quadrilateral
Definition vtkPixel.h:47
cell represents a set of 1D lines
Definition vtkPolyLine.h:49
cell represents a set of 0D vertices
a cell that represents an n-sided polygon
Definition vtkPolygon.h:52
a 3D cell defined by a set of polygonal faces
a 3D cell that represents a linear pyramid
Definition vtkPyramid.h:56
a cell that represents a 2D quadrilateral
Definition vtkQuad.h:48
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
Hold a reference to a vtkObjectBase instance.
a 3D cell that represents a tetrahedron
Definition vtkTetra.h:54
cell represents a parabolic, 27-node isoparametric hexahedron
cell represents a parabolic, 19-node isoparametric pyramid
a cell that represents a triangle strip
a cell that represents a triangle
Definition vtkTriangle.h:48
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.
vtkLagrangeWedge * LagrangeWedge
vtkQuadraticLinearWedge * QuadraticLinearWedge
vtkQuadraticQuad * QuadraticQuad
vtkIdType * GetFaces(vtkIdType cellId)
Special support for polyhedron.
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
vtkBezierQuadrilateral * BezierQuadrilateral
vtkSmartPointer< vtkIdTypeArray > CellLocations
vtkQuadraticLinearQuad * QuadraticLinearQuad
void GetFaceStream(vtkIdType cellId, vtkIdType &nfaces, vtkIdType const *&ptIds)
Get the number of faces and the face stream of a polyhedral cell.
vtkTriangleStrip * TriangleStrip
vtkCellArray * GetCells()
Return the unstructured grid connectivity array.
vtkBiQuadraticTriangle * BiQuadraticTriangle
vtkLagrangeQuadrilateral * LagrangeQuadrilateral
vtkBiQuadraticQuadraticWedge * BiQuadraticQuadraticWedge
vtkIdType InternalInsertNextCell(int type, vtkIdList *ptIds) override
virtual vtkMTimeType GetMeshMTime()
Return the mesh (geometry/topology) modification time.
void SetCells(vtkUnsignedCharArray *cellTypes, vtkCellArray *cells, vtkIdTypeArray *faceLocations, vtkIdTypeArray *faces)
Provide cell information to define the dataset.
vtkSmartPointer< vtkCellTypes > DistinctCellTypes
void SetCells(int *types, vtkCellArray *cells)
Provide cell information to define the dataset.
vtkQuadraticTetra * QuadraticTetra
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkMTimeType DistinctCellTypesUpdateMTime
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkSmartPointer< vtkIdTypeArray > Faces
void Squeeze() override
Squeeze all arrays in the grid to conserve memory.
vtkQuadraticPolygon * QuadraticPolygon
vtkLagrangeHexahedron * LagrangeHexahedron
vtkIdType GetCellSize(vtkIdType cellId) override
Get the size of the cell with given cellId.
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
vtkIdTypeArray * GetFaces()
Get pointer to faces and facelocations.
vtkLagrangeTriangle * LagrangeTriangle
vtkHexagonalPrism * HexagonalPrism
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
static vtkUnstructuredGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
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...
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.
void SetCells(int type, vtkCellArray *cells)
Provide cell information to define the dataset.
vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks)
Set/Get the links that you created possibly without using BuildLinks.
vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]) override
vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks)
Set/Get the links that you created possibly without using BuildLinks.
vtkIdTypeArray * GetCellLocationsArray()
Get the array of all the starting indices of cell definitions in the cell array.
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.
void GetFaceStream(vtkIdType cellId, vtkIdList *ptIds)
Get the face stream of a polyhedron cell in the following format: (numCellFaces, numFace0Pts,...
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
vtkCellIterator * NewCellIterator() override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
void GetPointCells(vtkIdType ptId, vtkIdType &ncells, vtkIdType *&cells)
Special (efficient) operation to return the list of cells using the specified point ptId.
vtkSmartPointer< vtkUnsignedCharArray > Types
vtkLagrangeCurve * LagrangeCurve
void SetCells(vtkUnsignedCharArray *cellTypes, vtkCellArray *cells)
Provide cell information to define the dataset.
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 * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
void CopyStructure(vtkDataSet *ds) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
void Initialize() override
Reset the grid to an empty state and free any memory.
int GetMaxCellSize() override
Get the size, in number of points, of the largest cell.
vtkConvexPointSet * ConvexPointSet
vtkSmartPointer< vtkCellArray > Connectivity
vtkBezierHexahedron * BezierHexahedron
~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,...
bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType *ptIds, vtkIdList *cellIds)
A topological inquiry to determine whether a topological entity (e.g., point, edge,...
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 BuildLinks()
Build topological links from points to lists of cells that use each point.
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
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.
static vtkUnstructuredGrid * ExtendedNew()
vtkIdTypeArray * GetFaceLocations()
Get pointer to faces and facelocations.
static vtkUnstructuredGrid * New()
Standard instantiation method.
vtkAbstractCellLinks * GetCellLinks()
Get the cell links.
vtkUnsignedCharArray * GetCellTypesArray()
Get the array of all cell types in the grid.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts, vtkIdList *ptIds) override
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids.
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:43
a cell that represents a 3D orthogonal parallelepiped
Definition vtkVoxel.h:51
a 3D cell that represents a linear wedge
Definition vtkWedge.h:56
#define VTK_DEPRECATED_IN_9_2_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(...)