VTK  9.7.20261026
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
130
131#ifndef vtkUnstructuredGrid_h
132#define vtkUnstructuredGrid_h
133
134#include "vtkAbstractCellLinks.h" // For vtkAbstractCellLinks
135#include "vtkCellArray.h" // inline GetCellPoints()
136#include "vtkCommonDataModelModule.h" // For export macro
137#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_8_0
138#include "vtkPolyhedronCellArray.h" // inline GetPolyhedronFaces()
139#include "vtkSmartPointer.h" // for smart pointer
141#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
142
143VTK_ABI_NAMESPACE_BEGIN
144class vtkIdList;
145class vtkIdTypeArray;
147
148class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkUnstructuredGrid
150{
151public:
157
159
163 void PrintSelf(ostream& os, vtkIndent indent) override;
165
169 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_UNSTRUCTURED_GRID; }
170
180 bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
181 {
182 return this->AllocateExact(numCells, numCells * maxCellSize);
183 }
184
194 bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
195
205 void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
206 {
207 this->AllocateExact(numCells, numCells);
208 }
209
211
214 void Reset();
215 void CopyStructure(vtkDataSet* ds) override;
218 vtkCell* GetCell(vtkIdType cellId) override;
219 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
220 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
221 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
222 void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
225
229 int GetCellType(vtkIdType cellId) override;
230
235
237
248 void GetDistinctCellTypes(vtkCellTypes* types) override;
250
264
277 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
278 {
279 this->Connectivity->GetCellAtId(cellId, npts, pts);
280 }
281
298 vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override
299 {
300 this->Connectivity->GetCellAtId(cellId, npts, pts, ptIds);
301 }
302
304
309 void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
310 VTK_SIZEHINT(cells, ncells);
312
317 vtkIdType cellId, unsigned char& cellType, vtkGenericCell* tempCell) override;
318
320
326 void GetCellFacePoints(vtkIdType cellId, int faceId, vtkIdList* facePtIds,
327 unsigned char& cellType, vtkIdList* tempCellPointIds, vtkGenericCell* tempCell) override;
328 void GetCellFacePointsFromCellPoints(vtkIdType cellId, int faceId, vtkIdList* facePtIds,
329 unsigned char cellType, vtkIdType cellNpts, const vtkIdType* cellPts,
330 vtkGenericCell* tempCell) override;
332
337 vtkIdType cellId, unsigned char& cellType, vtkGenericCell* tempCell) override;
338
340
348 void GetCellEdgePoints(vtkIdType cellId, int edgeId, vtkIdList* edgePtIds,
349 unsigned char& cellType, vtkIdList* tempCellPointIds, vtkGenericCell* tempCell) override;
350 void GetCellEdgePointsFromCellPoints(vtkIdType cellId, int edgeId, vtkIdList* edgePtIds,
351 unsigned char cellType, vtkIdType cellNpts, const vtkIdType* cellPts,
352 vtkGenericCell* tempCell) override;
354
361 vtkDataArray* GetCellTypes() { return this->Types; }
362
366 void Squeeze() override;
367
371 void Initialize() override;
372
376 int GetMaxCellSize() override;
377
379
386
392
394
397 vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
398 vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
400
408 void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
409
417 void SetCells(int type, vtkCellArray* cells);
418
420
431 void SetCells(int* types, vtkCellArray* cells);
432 void SetCells(vtkDataArray* cellTypes, vtkCellArray* cells);
434 vtkDataArray* cellTypes, vtkCellArray* cells, vtkCellArray* faceLocations, vtkCellArray* faces);
436 vtkDataArray* cellTypes, vtkCellArray* cells, vtkPolyhedronCellArray* polyhedra);
438
442 vtkCellArray* GetCells() { return this->Connectivity; }
443
445
451 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
452 {
453 this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
454 }
456 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
458
460
471 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdType& neighborCellId);
472 bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds)
473 {
474 vtkIdType neighborCellId;
475 return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId);
476 }
477
478
480
484 vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
487 void ResizeCellList(vtkIdType ptId, int size);
489
491
494 virtual int GetPiece();
495 virtual int GetNumberOfPieces();
497
501 virtual int GetGhostLevel();
502
511 unsigned long GetActualMemorySize() override;
512
514
517 void ShallowCopy(vtkDataObject* src) override;
518 void DeepCopy(vtkDataObject* src) override;
520
526 void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
527
531 int IsHomogeneous() override;
532
539
541
547
557 {
558 if (faces == nullptr)
559 {
560 return;
561 }
562 faces->Reset();
563 if (this->Polyhedra && cellId >= 0 && cellId < this->Polyhedra->GetNumberOfCells())
564 {
565 this->Polyhedra->GetCellFaces(cellId, faces);
566 }
567 }
568
570
584 {
585 return this->Polyhedra ? this->Polyhedra->GetFaces() : nullptr;
586 }
588 {
589 return this->Polyhedra ? this->Polyhedra->GetFaceLocations() : nullptr;
590 }
591
592
611
620
629
642 VTK_DEPRECATED_IN_9_8_0("Use vtkPolyhedronCellArray::InsertNextCell() instead")
643 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
644 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
645
646 VTK_DEPRECATED_IN_9_8_0("Use vtkPolyhedronCellArray::InsertNextCell() instead")
647 static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
648 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
649
662 VTK_DEPRECATED_IN_9_8_0("Use vtkPolyhedronCellArray::InsertNextCell() instead")
663 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
664 vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
665
672 static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
673
679 static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
680
687
688protected:
691
693
694 // Points derived from vtkPointSet.
695 // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
696 // derived from vtkDataSet.
697
698 // The heart of the data representation. The points are managed by the
699 // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
700 // point ids that define the cell) and the cell type, represented by the
701 // Connectivity and Types arrays.
702 // Finally, when certain topological information is needed (e.g.,
703 // all the cells that use a point), the cell links array is built.
707
708 // Recompute DistinctCellTypes if the Types array was modified since the last time, see
709 // GetDistinctCellTypes() and GetDistinctCellTypesArray().
711
712 // Set of all cell types present in the grid. All entries are unique.
714
715 // The DistinctCellTypes is cached, so we keep track of the last time it was
716 // updated so we can compare it to the modified time of the Types array.
718
727
733
734 vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
735 vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
737 int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]);
739 int type, vtkIdType npts, const vtkIdType pts[], vtkCellArray* faces) override;
740 void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
741
754 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
755 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces);
756
757 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
758 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* facesArray);
759
760 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCell, vtkIdType& numCellPts,
761 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkCellArray* faces);
762
763 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
764 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces,
765 vtkCellArray* faceLocations);
766
767 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
768 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* faces,
769 vtkCellArray* faceLocations);
770
771private:
772 // Hide these from the user and the compiler.
774 void operator=(const vtkUnstructuredGrid&) = delete;
775
776 void Cleanup();
777};
778
779VTK_ABI_NAMESPACE_END
780#endif
object to represent cell connectivity
void Reset()
Reuse list.
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:131
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:135
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition vtkIdList.h:185
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
Definition vtkIdList.h:259
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
object to represent the faces of polyhedral cells
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
void GetCellEdgePoints(vtkIdType cellId, int edgeId, vtkIdList *edgePtIds, unsigned char &cellType, vtkIdList *tempCellPointIds, vtkGenericCell *tempCell) override
Get the point ids of the edge edgeId of the cell cellId, and the type of the cell,...
void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId)
Use these methods only if the dataset has been specified as Editable.
void GetCellEdgePointsFromCellPoints(vtkIdType cellId, int edgeId, vtkIdList *edgePtIds, unsigned char cellType, vtkIdType cellNpts, const vtkIdType *cellPts, vtkGenericCell *tempCell) override
Get the point ids of the edge edgeId of the cell cellId, and the type of the cell,...
vtkSmartPointer< vtkCellArray > Faces
Special support for polyhedra/cells with explicit face representations.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
void GetCellFacePointsFromCellPoints(vtkIdType cellId, int faceId, vtkIdList *facePtIds, unsigned char cellType, vtkIdType cellNpts, const vtkIdType *cellPts, vtkGenericCell *tempCell) override
Get the point ids of the face faceId of the cell cellId, and the type of the cell,...
void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override
int GetDataObjectType() VTK_FUTURE_CONST override
Standard vtkDataSet API methods.
int GetCellNumberOfFaces(vtkIdType cellId, unsigned char &cellType, vtkGenericCell *tempCell) override
Get the number of faces of a cell, and its type.
void SetPolyhedralCells(vtkDataArray *cellTypes, vtkCellArray *cells, vtkCellArray *faceLocations, vtkCellArray *faces)
Provide cell information to define the dataset.
void Allocate(vtkIdType numCells=1000, int extSize=1000) override
Method allocates initial storage for the cell connectivity.
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< vtkPolyhedronCellArray > Polyhedra
Special support for polyhedra/cells with explicit face representations, see vtkPolyhedronCellArray,...
vtkSmartPointer< vtkCellTypes > DistinctCellTypes
void SetCells(int *types, vtkCellArray *cells)
Provide cell information to define the dataset.
void UpdateDistinctCellTypes()
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.
vtkCellArray * GetPolyhedronFaces()
Get pointer to faces and facelocations for polyhedron cells.
int GetMaxSpatialDimension() override
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
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.
void GetCellFacePoints(vtkIdType cellId, int faceId, vtkIdList *facePtIds, unsigned char &cellType, vtkIdList *tempCellPointIds, vtkGenericCell *tempCell) override
Get the point ids of the face faceId of the cell cellId, and the type of the cell,...
void SetCells(vtkDataArray *cellTypes, vtkCellArray *cells)
Provide cell information to define the dataset.
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 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 with a single type.
vtkSmartPointer< vtkDataArray > Types
vtkCellArray * GetPolyhedronFaceLocations()
Get pointer to faces and facelocations for polyhedron cells.
vtkUnsignedCharArray * GetDistinctCellTypesArray()
Get a list of types of cells in a dataset.
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.
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.
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 GetDistinctCellTypes(vtkCellTypes *types) override
Get a list of types of cells in a dataset.
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,...
int GetMinSpatialDimension() override
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
virtual int GetGhostLevel()
Get the ghost level.
int GetCellType(vtkIdType cellId) override
Get the type of the cell with the given cellId.
int GetCellNumberOfEdges(vtkIdType cellId, unsigned char &cellType, vtkGenericCell *tempCell) override
Get the number of edges of a cell, and its type.
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()
static vtkUnstructuredGrid * New()
Standard instantiation method.
void SetPolyhedralCells(vtkDataArray *cellTypes, vtkCellArray *cells, vtkPolyhedronCellArray *polyhedra)
Provide cell information to define the dataset.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts, vtkIdList *ptIds) override
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids.
vtkDataArray * GetCellTypes()
Get the array of all cell types in the grid.
vtkPolyhedronCellArray * GetPolyhedronCellArray()
Get the faces of the polyhedron cells, one cell per cell of the dataset, without faces for cells that...
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
#define vtkDataArray
#define VTK_DEPRECATED_IN_9_8_0(reason)
int vtkIdType
Definition vtkType.h:363
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
@ VTK_UNSTRUCTURED_GRID
Definition vtkType.h:113
#define VTK_SIZEHINT(...)
#define VTK_MARSHALMANUAL