VTK  9.5.20251013
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
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" // VTK_DEPRECATED_IN_9_6_0()
138#include "vtkSmartPointer.h" // for smart pointer
140#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
141
142VTK_ABI_NAMESPACE_BEGIN
143class vtkConstantUnsignedCharArray;
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;
249 VTK_DEPRECATED_IN_9_6_0("Use GetDistinctCellTypes(vtkCellTypes* types) instead.")
250 void GetCellTypes(vtkCellTypes* types) override { this->GetDistinctCellTypes(types); }
252
266
279 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
280 {
281 this->Connectivity->GetCellAtId(cellId, npts, pts);
282 }
283
300 vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override
301 {
302 this->Connectivity->GetCellAtId(cellId, npts, pts, ptIds);
303 }
304
306
311 void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
312 VTK_SIZEHINT(cells, ncells);
314
318 using CellTypesArrays = vtkTypeList::Create<vtkUnsignedCharArray, vtkConstantUnsignedCharArray>;
319
321
327 template <class TCellTypesArray = vtkDataArray>
328 TCellTypesArray* GetCellTypes()
329 {
330 return TCellTypesArray::FastDownCast(this->Types);
331 }
332 VTK_DEPRECATED_IN_9_6_0("Use GetCellTypes() instead")
333 vtkUnsignedCharArray* GetCellTypesArray() { return this->GetCellTypes<vtkUnsignedCharArray>(); }
335
339 void Squeeze() override;
340
344 void Initialize() override;
345
349 int GetMaxCellSize() override;
350
352
359
365
367
370 vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
371 vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
373
381 void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
382
384
394 void SetCells(int type, vtkCellArray* cells);
395 void SetCells(int* types, vtkCellArray* cells);
396 void SetCells(vtkDataArray* cellTypes, vtkCellArray* cells);
398 vtkDataArray* cellTypes, vtkCellArray* cells, vtkCellArray* faceLocations, vtkCellArray* faces);
399
400 // This was incorrectly deprecated in v9.4, so it should only been fully removed when removing
401 // VTK_DEPRECATED_IN_9_6_0
402 VTK_DEPRECATED_IN_9_5_0("This function is deprecated, use SetPolyhedralCells")
403 void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
404 vtkIdTypeArray* faces);
406
410 vtkCellArray* GetCells() { return this->Connectivity; }
411
413
419 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
420 {
421 this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
422 }
424 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
426
436 vtkIdType cellId, unsigned char& cellType, vtkGenericCell* cell) override;
437
439
450 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdType& neighborCellId);
451 bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds)
452 {
453 vtkIdType neighborCellId;
454 return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId);
455 }
457
459
463 vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
466 void ResizeCellList(vtkIdType ptId, int size);
468
470
473 virtual int GetPiece();
474 virtual int GetNumberOfPieces();
476
480 virtual int GetGhostLevel();
481
490 unsigned long GetActualMemorySize() override;
491
493
496 void ShallowCopy(vtkDataObject* src) override;
497 void DeepCopy(vtkDataObject* src) override;
499
505 void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
506
510 int IsHomogeneous() override;
511
518
520
526
531
533
540
549
558
571 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
572 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
573
574 static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
575 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
576
589 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
590 vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
591
598 static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
599
605 static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
606
613
614 //====================== Begin Legacy Methods ================================
615
623 VTK_DEPRECATED_IN_9_6_0("CellLocations is not longer used")
624 vtkIdTypeArray* GetCellLocationsArray();
625
627
643 VTK_DEPRECATED_IN_9_6_0("CellLocations is not longer used, use other SetCells methods")
644 void SetCells(
645 vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
646 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use SetPolyhedralCells")
647 void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
648 vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
650
651 //====================== End Legacy Methods ==================================
652
653protected:
656
657 void ReportReferences(vtkGarbageCollector*) override;
658
659 // Points derived from vtkPointSet.
660 // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
661 // derived from vtkDataSet.
662
663 // The heart of the data representation. The points are managed by the
664 // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
665 // point ids that define the cell) and the cell type, represented by the
666 // Connectivity and Types arrays.
667 // Finally, when certain topological information is needed (e.g.,
668 // all the cells that use a point), the cell links array is built.
672
673 // Set of all cell types present in the grid. All entries are unique.
674 vtkSmartPointer<vtkCellTypes> DistinctCellTypes;
675
676 // The DistinctCellTypes is cached, so we keep track of the last time it was
677 // updated so we can compare it to the modified time of the Types array.
678 vtkMTimeType DistinctCellTypesUpdateMTime;
679
688
689 // VTK_DEPRECATED_IN_9_6_0()
690 // Legacy support -- stores the old-style cell array locations.
692
693 vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
694 vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
695 vtkIdType InternalInsertNextCell(
696 int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]);
697 vtkIdType InternalInsertNextCell(
698 int type, vtkIdType npts, const vtkIdType pts[], vtkCellArray* faces) override;
699 void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
700
713 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
714 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces);
715
716 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
717 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* facesArray);
718
719 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCell, vtkIdType& numCellPts,
720 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkCellArray* faces);
721
722 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
723 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces,
724 vtkCellArray* faceLocations);
725
726 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
727 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* faces,
728 vtkCellArray* faceLocations);
729
730private:
731 // Hide these from the user and the compiler.
733 void operator=(const vtkUnstructuredGrid&) = delete;
734
735 void Cleanup();
736};
737
738VTK_ABI_NAMESPACE_END
739#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:129
abstract superclass for arrays of numeric data
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
virtual void GetDistinctCellTypes(vtkCellTypes *types)
Get a list of types of cells in a dataset.
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:133
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition vtkIdList.h:159
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
Definition vtkIdList.h:225
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.
Hold a reference to a vtkObjectBase instance.
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
void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId)
Use these methods only if the dataset has been specified as Editable.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
int GetDataObjectType() VTK_FUTURE_CONST override
Standard vtkDataSet API methods.
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.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts)
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids.
void SetCells(int *types, vtkCellArray *cells)
Provide cell information to define the dataset.
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
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.
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,...
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].
static vtkUnstructuredGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
int GetCellNumberOfFaces(vtkIdType cellId, unsigned char &cellType, vtkGenericCell *cell) override
Get the number of faces of a cell.
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 for polyhedron cells.
vtkUnsignedCharArray * GetDistinctCellTypesArray()
Get a list of types of cells in a dataset.
static void DecomposeAPolyhedronCell(const vtkIdType *polyhedronCellStream, vtkIdType &nCellpts, vtkIdType &nCellfaces, vtkCellArray *cellArray, vtkIdTypeArray *faces)
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,...
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.
vtkTypeList::Create< vtkUnsignedCharArray, vtkConstantUnsignedCharArray > CellTypesArrays
The possible types of arrays to use for the cell types array.
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.
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,...
static void ConvertFaceStreamPointIds(vtkCellArray *faces, vtkIdType *idMap)
Convert pid in a face stream into idMap[pid].
int GetMinSpatialDimension() override
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
TCellTypesArray * GetCellTypes()
Get the array of all cell types in the grid.
virtual int GetGhostLevel()
Get the ghost level.
int GetCellType(vtkIdType cellId) override
Get the type of the cell with the given cellId.
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.
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 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.
#define VTK_DEPRECATED_IN_9_6_0(reason)
#define VTK_DEPRECATED_IN_9_5_0(reason)
int vtkIdType
Definition vtkType.h:367
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:322
@ VTK_UNSTRUCTURED_GRID
Definition vtkType.h:113
#define VTK_SIZEHINT(...)
#define VTK_MARSHALMANUAL