VTK  9.5.20251112
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 vtkIdList;
144class vtkIdTypeArray;
146
147class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkUnstructuredGrid
149{
150public:
156
158
162 void PrintSelf(ostream& os, vtkIndent indent) override;
164
168 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_UNSTRUCTURED_GRID; }
169
179 bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
180 {
181 return this->AllocateExact(numCells, numCells * maxCellSize);
182 }
183
193 bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
194
204 void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
205 {
206 this->AllocateExact(numCells, numCells);
207 }
208
210
213 void Reset();
214 void CopyStructure(vtkDataSet* ds) override;
217 vtkCell* GetCell(vtkIdType cellId) override;
218 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
219 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
220 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
221 void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
224
228 int GetCellType(vtkIdType cellId) override;
229
234
236
247 void GetDistinctCellTypes(vtkCellTypes* types) override;
248 VTK_DEPRECATED_IN_9_6_0("Use GetDistinctCellTypes(vtkCellTypes* types) instead.")
249 void GetCellTypes(vtkCellTypes* types) override { this->GetDistinctCellTypes(types); }
251
265
278 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
279 {
280 this->Connectivity->GetCellAtId(cellId, npts, pts);
281 }
282
299 vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override
300 {
301 this->Connectivity->GetCellAtId(cellId, npts, pts, ptIds);
302 }
303
305
310 void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
311 VTK_SIZEHINT(cells, ncells);
313
315
321 vtkDataArray* GetCellTypes() { return this->Types; }
322 VTK_DEPRECATED_IN_9_6_0("Use GetCellTypes() instead")
323 vtkUnsignedCharArray* GetCellTypesArray();
325
329 void Squeeze() override;
330
334 void Initialize() override;
335
339 int GetMaxCellSize() override;
340
342
346 int GetMaxSpatialDimension() override;
347 int GetMinSpatialDimension() override;
349
354 void BuildLinks();
355
357
360 vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
361 vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
363
371 void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
372
380 void SetCells(int type, vtkCellArray* cells);
381
383
393 void SetCells(int* types, vtkCellArray* cells);
394 void SetCells(vtkDataArray* cellTypes, vtkCellArray* cells);
395 void SetPolyhedralCells(
396 vtkDataArray* cellTypes, vtkCellArray* cells, vtkCellArray* faceLocations, vtkCellArray* faces);
397 // VTK_DEPRECATED_IN_9_6_0
398 VTK_DEPRECATED_IN_9_5_0("This function is deprecated, use SetPolyhedralCells")
399 void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
400 vtkIdTypeArray* faces);
402
406 vtkCellArray* GetCells() { return this->Connectivity; }
407
409
415 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
416 {
417 this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
418 }
420 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
422
432 vtkIdType cellId, unsigned char& cellType, vtkGenericCell* cell) override;
433
435
446 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdType& neighborCellId);
447 bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds)
448 {
449 vtkIdType neighborCellId;
450 return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId);
451 }
453
455
459 vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
462 void ResizeCellList(vtkIdType ptId, int size);
464
466
469 virtual int GetPiece();
470 virtual int GetNumberOfPieces();
472
476 virtual int GetGhostLevel();
477
486 unsigned long GetActualMemorySize() override;
487
489
492 void ShallowCopy(vtkDataObject* src) override;
493 void DeepCopy(vtkDataObject* src) override;
495
501 void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
502
506 int IsHomogeneous() override;
507
514
516
522
527
529
536
545
554
567 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
568 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
569
570 static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
571 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
572
585 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
586 vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
587
594 static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
595
601 static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
602
609
610 //====================== Begin Legacy Methods ================================
611
619 VTK_DEPRECATED_IN_9_6_0("CellLocations is not longer used")
620 vtkIdTypeArray* GetCellLocationsArray();
621
623
639 VTK_DEPRECATED_IN_9_6_0("CellLocations is not longer used, use other SetCells methods")
640 void SetCells(
641 vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
642 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use SetPolyhedralCells")
643 void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
644 vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
646
647 //====================== End Legacy Methods ==================================
648
649protected:
652
653 void ReportReferences(vtkGarbageCollector*) override;
654
655 // Points derived from vtkPointSet.
656 // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
657 // derived from vtkDataSet.
658
659 // The heart of the data representation. The points are managed by the
660 // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
661 // point ids that define the cell) and the cell type, represented by the
662 // Connectivity and Types arrays.
663 // Finally, when certain topological information is needed (e.g.,
664 // all the cells that use a point), the cell links array is built.
668
669 // Set of all cell types present in the grid. All entries are unique.
670 vtkSmartPointer<vtkCellTypes> DistinctCellTypes;
671
672 // The DistinctCellTypes is cached, so we keep track of the last time it was
673 // updated so we can compare it to the modified time of the Types array.
674 vtkMTimeType DistinctCellTypesUpdateMTime;
675
684
685 // VTK_DEPRECATED_IN_9_6_0()
686 // Legacy support -- stores the old-style cell array locations.
688
689 vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
690 vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
691 vtkIdType InternalInsertNextCell(
692 int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]);
693 vtkIdType InternalInsertNextCell(
694 int type, vtkIdType npts, const vtkIdType pts[], vtkCellArray* faces) override;
695 void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
696
709 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
710 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces);
711
712 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
713 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* facesArray);
714
715 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCell, vtkIdType& numCellPts,
716 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkCellArray* faces);
717
718 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
719 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces,
720 vtkCellArray* faceLocations);
721
722 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
723 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* faces,
724 vtkCellArray* faceLocations);
725
726private:
727 // Hide these from the user and the compiler.
729 void operator=(const vtkUnstructuredGrid&) = delete;
730
731 void Cleanup();
732};
733
734VTK_ABI_NAMESPACE_END
735#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 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.
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.
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,...
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.
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.
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.
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].
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 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.
vtkDataArray * GetCellTypes()
Get the array of all cell types in the grid.
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