VTK  9.4.20251007
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
21
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 "vtkIdTypeArray.h" // inline GetCellPoints()
30#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
31
32#include "vtkSmartPointer.h" // for smart pointer
33
34VTK_ABI_NAMESPACE_BEGIN
35class vtkCellArray;
36class vtkIdList;
37class vtkIdTypeArray;
39class vtkIdTypeArray;
40
41class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkUnstructuredGrid
43{
44public:
50
52
56 void PrintSelf(ostream& os, vtkIndent indent) override;
58
62 int GetDataObjectType() override { return VTK_UNSTRUCTURED_GRID; }
63
73 bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
74 {
75 return this->AllocateExact(numCells, numCells * maxCellSize);
76 }
77
87 bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
88
98 void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
99 {
100 this->AllocateExact(numCells, numCells);
101 }
102
104
107 void Reset();
108 void CopyStructure(vtkDataSet* ds) override;
111 vtkCell* GetCell(vtkIdType cellId) override;
112 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
113 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
114 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
115 void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
118
122 int GetCellType(vtkIdType cellId) override;
123
128
140 void GetCellTypes(vtkCellTypes* types) override;
141
155
168 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
169 {
170 this->Connectivity->GetCellAtId(cellId, npts, pts);
171 }
172
189 vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override
190 {
191 this->Connectivity->GetCellAtId(cellId, npts, pts, ptIds);
192 }
193
195
200 void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
201 VTK_SIZEHINT(cells, ncells);
203
211
215 void Squeeze() override;
216
220 void Initialize() override;
221
225 int GetMaxCellSize() override;
226
232
238
240
243 vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
244 vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
246
254 VTK_DEPRECATED_IN_9_3_0("Use GetLinks() instead.")
256
264 void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
265
275 VTK_DEPRECATED_IN_9_4_0("Use the threadsafe GetFaceStream or GetPolyhedronFaces.")
276 void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType const*& ptIds);
277
279
289 void SetCells(int type, vtkCellArray* cells);
290 void SetCells(int* types, vtkCellArray* cells);
293 vtkCellArray* faceLocations, vtkCellArray* faces);
294 VTK_DEPRECATED_IN_9_4_0("This function is deprecated, use SetPolyhedralCells")
295 void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
296 vtkIdTypeArray* faces);
298
302 vtkCellArray* GetCells() { return this->Connectivity; }
303
305
311 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
312 {
313 this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
314 }
316 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
318
320
331 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdType& neighborCellId);
332 bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds)
333 {
334 vtkIdType neighborCellId;
335 return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId);
336 }
337 VTK_DEPRECATED_IN_9_3_0("Use the overload that doesn't take a vtkIdList instead.")
339 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* vtkNotUsed(cellIds))
340 {
341 return this->IsCellBoundary(cellId, npts, ptIds);
342 }
343
344
346
350 vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
353 void ResizeCellList(vtkIdType ptId, int size);
355
357
360 virtual int GetPiece();
361 virtual int GetNumberOfPieces();
363
367 virtual int GetGhostLevel();
368
377 unsigned long GetActualMemorySize() override;
378
380
383 void ShallowCopy(vtkDataObject* src) override;
384 void DeepCopy(vtkDataObject* src) override;
386
392 void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
393
397 int IsHomogeneous() override;
398
405
407
413
417 VTK_DEPRECATED_IN_9_4_0("Use GetPolyhedronFaces instead.")
419
424
426
430 VTK_DEPRECATED_IN_9_4_0("Use GetPolyhedronFaces instead.")
432 VTK_DEPRECATED_IN_9_4_0("Use GetPolyhedronFaceLocations instead.")
441
450
459
472 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
473 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
474
475 static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
476 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
477
490 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
491 vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
492
499 static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
500
506 static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
507
514
515 //====================== Begin Legacy Methods ================================
516
525
527
544 vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
545 void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
546 vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
548
549 //====================== End Legacy Methods ==================================
550
551protected:
554
556
557 // Points derived from vtkPointSet.
558 // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
559 // derived from vtkDataSet.
560
561 // The heart of the data representation. The points are managed by the
562 // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
563 // point ids that define the cell) and the cell type, represented by the
564 // Connectivity and Types arrays.
565 // Finally, when certain topological information is needed (e.g.,
566 // all the cells that use a point), the cell links array is built.
570
571 // Set of all cell types present in the grid. All entries are unique.
573
574 // The DistinctCellTypes is cached, so we keep track of the last time it was
575 // updated so we can compare it to the modified time of the Types array.
577
586
587 // Legacy support -- stores the old-style cell array locations.
589
590 vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
591 vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
593 int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]);
595 int type, vtkIdType npts, const vtkIdType pts[], vtkCellArray* faces) override;
596 void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
597
612
617 VTK_DEPRECATED_IN_9_4_0("This member is deprecated.")
619
632 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
633 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces);
634
635 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
636 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* facesArray);
637
638 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCell, vtkIdType& numCellPts,
639 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkCellArray* faces);
640
641 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
642 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces,
643 vtkCellArray* faceLocations);
644
645 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
646 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* faces,
647 vtkCellArray* faceLocations);
648
652 static int CopyPolyhedronToFaceStream(vtkCellArray* faceArray, vtkCellArray* faceLocationArray,
653 vtkIdTypeArray* faceStream, vtkIdTypeArray* faceLocation);
654
655private:
656 // Hide these from the user and the compiler.
658 void operator=(const vtkUnstructuredGrid&) = delete;
659
660 void Cleanup();
661};
662
663VTK_ABI_NAMESPACE_END
664#endif
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:51
general representation of visualization data
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....
Detect and break reference loops.
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:24
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition vtkIdList.h:50
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
Definition vtkIdList.h:116
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId)
Use these methods only if the dataset has been specified as Editable.
void GetCellTypes(vtkCellTypes *types) override
Get a list of types of cells in a dataset.
vtkSmartPointer< vtkIdTypeArray > LegacyFaces
Legacy support – stores the old-style Faces && FaceLocations Special support for polyhedra/cells with...
vtkIdType * GetFaces(vtkIdType cellId)
Special support for polyhedron.
vtkSmartPointer< vtkCellArray > Faces
Special support for polyhedra/cells with explicit face representations.
static int CopyPolyhedronToFaceStream(vtkCellArray *faceArray, vtkCellArray *faceLocationArray, vtkIdTypeArray *faceStream, vtkIdTypeArray *faceLocation)
Backward compatibility function to convert new polyhedron storage to legacy.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override
vtkSmartPointer< vtkIdTypeArray > CellLocations
vtkCellArray * GetCells()
Return the unstructured grid connectivity array.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts)
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids.
vtkSmartPointer< vtkCellTypes > DistinctCellTypes
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.
int GetMaxSpatialDimension() override
Get the maximum spatial dimensionality of the data which is the maximum dimension of all cells.
void Squeeze() override
Squeeze all arrays in the grid to conserve memory.
vtkIdType GetCellSize(vtkIdType cellId) override
Get the size of the cell with given cellId.
int IsHomogeneous() override
Returns whether cells are all of the same type.
void SetPolyhedralCells(vtkUnsignedCharArray *cellTypes, vtkCellArray *cells, vtkCellArray *faceLocations, vtkCellArray *faces)
Provide cell information to define the dataset.
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 GetPolyhedronFaces(vtkIdType cellId, vtkCellArray *faces)
Special support for polyhedron.
void ResizeCellList(vtkIdType ptId, int size)
Use these methods only if the dataset has been specified as Editable.
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
int InitializeFacesRepresentation(vtkIdType numPrevCells)
Special function used by vtkUnstructuredGridReader.
bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType *ptIds, vtkIdType &neighborCellId)
A topological inquiry to determine whether a topological entity (e.g., point, edge,...
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.
vtkCellArray * GetPolyhedronFaceLocations()
Get pointer to faces and facelocations.
vtkUnsignedCharArray * GetDistinctCellTypesArray()
Get a list of types of cells in a dataset.
vtkIdTypeArray * GetCellLocationsArray()
Get the array of all the starting indices of cell definitions in the cell array.
vtkSmartPointer< vtkCellArray > FaceLocations
void ReportReferences(vtkGarbageCollector *) override
bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType *ptIds)
A topological inquiry to determine whether a topological entity (e.g., point, edge,...
vtkMTimeType GetMeshMTime() override
Return the mesh (geometry/topology) modification time.
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.
bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize)
Pre-allocate memory in internal data structures.
void Reset()
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
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
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.
vtkSmartPointer< vtkCellArray > Connectivity
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,...
virtual int GetGhostLevel()
Get the ghost level.
int GetCellType(vtkIdType cellId) override
Get the type of the cell with the given cellId.
vtkSmartPointer< vtkIdTypeArray > LegacyFaceLocations
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
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.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
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.
vtkSmartPointer< vtkIdList > LegacyPointIdsBuffer
Legacy backward compatibility for GetFaceStream This member should be removed simultaneously with the...
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.
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_DEPRECATED_IN_9_4_0(reason)
int vtkIdType
Definition vtkType.h:315
#define VTK_UNSTRUCTURED_GRID
Definition vtkType.h:69
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_SIZEHINT(...)
#define VTK_MARSHALMANUAL