VTK  9.4.20241108
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 "vtkIdTypeArray.h" // inline GetCellPoints()
139#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
140
141#include "vtkSmartPointer.h" // for smart pointer
142
143VTK_ABI_NAMESPACE_BEGIN
144class vtkCellArray;
145class vtkIdList;
146class vtkIdTypeArray;
148class vtkIdTypeArray;
149
150class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkUnstructuredGrid
152{
153public:
159
161
165 void PrintSelf(ostream& os, vtkIndent indent) override;
167
171 int GetDataObjectType() override { return VTK_UNSTRUCTURED_GRID; }
172
182 bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
183 {
184 return this->AllocateExact(numCells, numCells * maxCellSize);
185 }
186
196 bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
197
207 void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
208 {
209 this->AllocateExact(numCells, numCells);
210 }
211
213
216 void Reset();
217 void CopyStructure(vtkDataSet* ds) override;
220 vtkCell* GetCell(vtkIdType cellId) override;
221 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
222 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
223 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
224 void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
227
231 int GetCellType(vtkIdType cellId) override;
232
237
249 void GetCellTypes(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
320
324 void Squeeze() override;
325
329 void Initialize() override;
330
334 int GetMaxCellSize() override;
335
337
344
350
352
358
366 VTK_DEPRECATED_IN_9_3_0("Use GetLinks() instead.")
367 vtkAbstractCellLinks* GetCellLinks();
368
376 void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
377
387 VTK_DEPRECATED_IN_9_4_0("Use the threadsafe GetFaceStream or GetPolyhedronFaces.")
388 void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType const*& ptIds);
389
391
401 void SetCells(int type, vtkCellArray* cells);
402 void SetCells(int* types, vtkCellArray* cells);
403 void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells);
404 void SetPolyhedralCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells,
405 vtkCellArray* faceLocations, vtkCellArray* faces);
406 VTK_DEPRECATED_IN_9_4_0("This function is deprecated, use SetPolyhedralCells")
407 void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
408 vtkIdTypeArray* faces);
410
414 vtkCellArray* GetCells() { return this->Connectivity; }
415
417
423 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
424 {
425 this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
426 }
428 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
430
432
443 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdType& neighborCellId);
444 bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds)
445 {
446 vtkIdType neighborCellId;
447 return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId);
448 }
449 VTK_DEPRECATED_IN_9_3_0("Use the overload that doesn't take a vtkIdList instead.")
450 bool IsCellBoundary(
451 vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* vtkNotUsed(cellIds))
452 {
453 return this->IsCellBoundary(cellId, npts, ptIds);
454 }
456
458
462 vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
465 void ResizeCellList(vtkIdType ptId, int size);
467
469
472 virtual int GetPiece();
473 virtual int GetNumberOfPieces();
475
479 virtual int GetGhostLevel();
480
489 unsigned long GetActualMemorySize() override;
490
492
495 void ShallowCopy(vtkDataObject* src) override;
496 void DeepCopy(vtkDataObject* src) override;
498
504 void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
505
509 int IsHomogeneous() override;
510
517
519
525
529 VTK_DEPRECATED_IN_9_4_0("Use GetPolyhedronFaces instead.")
530 vtkIdType* GetFaces(vtkIdType cellId);
531
535 void GetPolyhedronFaces(vtkIdType cellId, vtkCellArray* faces);
536
538
542 VTK_DEPRECATED_IN_9_4_0("Use GetPolyhedronFaces instead.")
543 vtkIdTypeArray* GetFaces();
544 VTK_DEPRECATED_IN_9_4_0("Use GetPolyhedronFaceLocations instead.")
545 vtkIdTypeArray* GetFaceLocations();
550 vtkCellArray* GetPolyhedronFaces();
551 vtkCellArray* GetPolyhedronFaceLocations();
553
561 int InitializeFacesRepresentation(vtkIdType numPrevCells);
562
570 vtkMTimeType GetMeshMTime() override;
571
584 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
585 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
586
587 static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
588 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
589
602 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
603 vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
604
611 static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
612
618 static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
619
625 static void ConvertFaceStreamPointIds(vtkCellArray* faces, vtkIdType* idMap);
626
627 //====================== Begin Legacy Methods ================================
628
636 vtkIdTypeArray* GetCellLocationsArray();
637
639
655 void SetCells(
656 vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
657 void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
658 vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
660
661 //====================== End Legacy Methods ==================================
662
663protected:
666
667 void ReportReferences(vtkGarbageCollector*) override;
668
669 // Points derived from vtkPointSet.
670 // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
671 // derived from vtkDataSet.
672
673 // The heart of the data representation. The points are managed by the
674 // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
675 // point ids that define the cell) and the cell type, represented by the
676 // Connectivity and Types arrays.
677 // Finally, when certain topological information is needed (e.g.,
678 // all the cells that use a point), the cell links array is built.
682
683 // Set of all cell types present in the grid. All entries are unique.
684 vtkSmartPointer<vtkCellTypes> DistinctCellTypes;
685
686 // The DistinctCellTypes is cached, so we keep track of the last time it was
687 // updated so we can compare it to the modified time of the Types array.
688 vtkMTimeType DistinctCellTypesUpdateMTime;
689
698
699 // Legacy support -- stores the old-style cell array locations.
701
702 vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
703 vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
704 vtkIdType InternalInsertNextCell(
705 int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]);
706 vtkIdType InternalInsertNextCell(
707 int type, vtkIdType npts, const vtkIdType pts[], vtkCellArray* faces) override;
708 void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
709
723 vtkSmartPointer<vtkIdTypeArray> LegacyFaceLocations;
724
729 VTK_DEPRECATED_IN_9_4_0("This member is deprecated.")
730 vtkSmartPointer<vtkIdList> LegacyPointIdsBuffer;
731
744 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
745 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces);
746
747 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
748 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* facesArray);
749
750 static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCell, vtkIdType& numCellPts,
751 vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkCellArray* faces);
752
753 static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
754 vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces,
755 vtkCellArray* faceLocations);
756
757 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
758 vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* faces,
759 vtkCellArray* faceLocations);
760
764 static int CopyPolyhedronToFaceStream(vtkCellArray* faceArray, vtkCellArray* faceLocationArray,
765 vtkIdTypeArray* faceStream, vtkIdTypeArray* faceLocation);
766
767private:
768 // Hide these from the user and the compiler.
770 void operator=(const vtkUnstructuredGrid&) = delete;
771
772 void Cleanup();
773};
774
775VTK_ABI_NAMESPACE_END
776#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:130
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
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 GetCellTypes(vtkCellTypes *types) override
Get a list of types of cells in a dataset.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
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.
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.
int IsHomogeneous() override
Returns whether cells are all of the same type.
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.
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
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.
vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks)
Set/Get the links that you created possibly without using BuildLinks.
vtkUnsignedCharArray * GetDistinctCellTypesArray()
Get a list of types of cells in a dataset.
vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks)
Set/Get the links that you created possibly without using BuildLinks.
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.
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.
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.
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.
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.
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.
#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