VTK  9.7.1
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
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 "vtkDeprecation.h" // VTK_DEPRECATED_IN_9_6_0()
29 #include "vtkSmartPointer.h" // for smart pointer
31 #include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
32 
33 VTK_ABI_NAMESPACE_BEGIN
34 class vtkIdList;
35 class vtkIdTypeArray;
37 
38 class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkUnstructuredGrid
40 {
41 public:
45  static vtkUnstructuredGrid* New();
47 
49 
53  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
59  int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_UNSTRUCTURED_GRID; }
60 
70  bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
71  {
72  return this->AllocateExact(numCells, numCells * maxCellSize);
73  }
74 
84  bool AllocateExact(vtkIdType numCells, vtkIdType connectivitySize);
85 
95  void Allocate(vtkIdType numCells = 1000, int vtkNotUsed(extSize) = 1000) override
96  {
97  this->AllocateExact(numCells, numCells);
98  }
99 
101 
104  void Reset();
105  void CopyStructure(vtkDataSet* ds) override;
106  vtkIdType GetNumberOfCells() override;
107  using vtkDataSet::GetCell;
108  vtkCell* GetCell(vtkIdType cellId) override;
109  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
110  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
111  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
112  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
113  vtkCellIterator* NewCellIterator() override;
115 
119  int GetCellType(vtkIdType cellId) override;
120 
124  vtkIdType GetCellSize(vtkIdType cellId) override;
125 
127 
138  void GetDistinctCellTypes(vtkCellTypes* types) override;
140 
153  vtkUnsignedCharArray* GetDistinctCellTypesArray();
154 
167  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts)
168  {
169  this->Connectivity->GetCellAtId(cellId, npts, pts);
170  }
171 
188  vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override
189  {
190  this->Connectivity->GetCellAtId(cellId, npts, pts, ptIds);
191  }
192 
194 
199  void GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells)
200  VTK_SIZEHINT(cells, ncells);
202 
204 
211  vtkDataArray* GetCellTypes() { return this->Types; }
212  VTK_DEPRECATED_IN_9_6_0("Use GetCellTypes() instead")
213  vtkUnsignedCharArray* GetCellTypesArray();
215 
219  void Squeeze() override;
220 
224  void Initialize() override;
225 
229  int GetMaxCellSize() override;
230 
232 
236  int GetMaxSpatialDimension() override;
237  int GetMinSpatialDimension() override;
239 
244  void BuildLinks();
245 
247 
250  vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
251  vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
253 
261  void GetFaceStream(vtkIdType cellId, vtkIdList* ptIds);
262 
270  void SetCells(int type, vtkCellArray* cells);
271 
273 
283  void SetCells(int* types, vtkCellArray* cells);
284  void SetCells(vtkDataArray* cellTypes, vtkCellArray* cells);
285  void SetPolyhedralCells(
286  vtkDataArray* cellTypes, vtkCellArray* cells, vtkCellArray* faceLocations, vtkCellArray* faces);
287  VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use SetPolyhedralCells")
288  void SetCells(vtkUnsignedCharArray* cellTypes, vtkCellArray* cells, vtkIdTypeArray* faceLocations,
289  vtkIdTypeArray* faces);
291 
295  vtkCellArray* GetCells() { return this->Connectivity; }
296 
298 
304  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override
305  {
306  this->GetCellNeighbors(cellId, ptIds->GetNumberOfIds(), ptIds->GetPointer(0), cellIds);
307  }
308  void GetCellNeighbors(
309  vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* cellIds);
311 
321  vtkIdType cellId, unsigned char& cellType, vtkGenericCell* cell) override;
322 
324 
334  bool IsCellBoundary(
335  vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdType& neighborCellId);
336  bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds)
337  {
338  vtkIdType neighborCellId;
339  return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId);
340  }
342 
344 
348  vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
349  void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
350  void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
351  void ResizeCellList(vtkIdType ptId, int size);
353 
355 
358  virtual int GetPiece();
359  virtual int GetNumberOfPieces();
361 
365  virtual int GetGhostLevel();
366 
375  unsigned long GetActualMemorySize() override;
376 
378 
381  void ShallowCopy(vtkDataObject* src) override;
382  void DeepCopy(vtkDataObject* src) override;
384 
390  void GetIdsOfCellsOfType(int type, vtkIdTypeArray* array) override;
391 
395  int IsHomogeneous() override;
396 
402  void RemoveGhostCells();
403 
405 
409  static vtkUnstructuredGrid* GetData(vtkInformationVector* v, int i = 0);
411 
415  void GetPolyhedronFaces(vtkIdType cellId, vtkCellArray* faces);
416 
418 
422  vtkCellArray* GetPolyhedronFaces();
423  vtkCellArray* GetPolyhedronFaceLocations();
425 
433  int InitializeFacesRepresentation(vtkIdType numPrevCells);
434 
442  vtkMTimeType GetMeshMTime() override;
443 
456  static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCellArray, vtkIdType& nCellpts,
457  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
458 
459  static void DecomposeAPolyhedronCell(const vtkIdType* polyhedronCellStream, vtkIdType& nCellpts,
460  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkIdTypeArray* faces);
461 
474  static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* inFaceStream,
475  vtkIdType& nCellpts, vtkCellArray* cellArray, vtkIdTypeArray* faces);
476 
483  static void ConvertFaceStreamPointIds(vtkIdList* faceStream, vtkIdType* idMap);
484 
490  static void ConvertFaceStreamPointIds(vtkIdType nfaces, vtkIdType* faceStream, vtkIdType* idMap);
491 
497  static void ConvertFaceStreamPointIds(vtkCellArray* faces, vtkIdType* idMap);
498 
499  //====================== Begin Legacy Methods ================================
500 
508  VTK_DEPRECATED_IN_9_6_0("CellLocations is not longer used")
509  vtkIdTypeArray* GetCellLocationsArray();
510 
512 
528  VTK_DEPRECATED_IN_9_6_0("CellLocations is not longer used, use other SetCells methods")
529  void SetCells(
530  vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells);
531  VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use SetPolyhedralCells")
532  void SetCells(vtkUnsignedCharArray* cellTypes, vtkIdTypeArray* cellLocations, vtkCellArray* cells,
533  vtkIdTypeArray* faceLocations, vtkIdTypeArray* faces);
535 
536  //====================== End Legacy Methods ==================================
537 
538 protected:
540  ~vtkUnstructuredGrid() override;
541 
542  void ReportReferences(vtkGarbageCollector*) override;
543 
544  // Points derived from vtkPointSet.
545  // Attribute data (i.e., point and cell data (i.e., scalars, vectors, normals, tcoords)
546  // derived from vtkDataSet.
547 
548  // The heart of the data representation. The points are managed by the
549  // superclass vtkPointSet. A cell is defined by its connectivity (i.e., the
550  // point ids that define the cell) and the cell type, represented by the
551  // Connectivity and Types arrays.
552  // Finally, when certain topological information is needed (e.g.,
553  // all the cells that use a point), the cell links array is built.
557 
558  // Set of all cell types present in the grid. All entries are unique.
559  vtkSmartPointer<vtkCellTypes> DistinctCellTypes;
560 
561  // The DistinctCellTypes is cached, so we keep track of the last time it was
562  // updated so we can compare it to the modified time of the Types array.
563  vtkMTimeType DistinctCellTypesUpdateMTime;
564 
573 
574  // VTK_DEPRECATED_IN_9_6_0()
575  // Legacy support -- stores the old-style cell array locations.
577 
578  vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
579  vtkIdType InternalInsertNextCell(int type, vtkIdList* ptIds) override;
580  vtkIdType InternalInsertNextCell(
581  int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces, const vtkIdType faces[]);
582  vtkIdType InternalInsertNextCell(
583  int type, vtkIdType npts, const vtkIdType pts[], vtkCellArray* faces) override;
584  void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
585 
598  static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
599  vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces);
600 
601  static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
602  vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* facesArray);
603 
604  static void DecomposeAPolyhedronCell(vtkCellArray* polyhedronCell, vtkIdType& numCellPts,
605  vtkIdType& nCellfaces, vtkCellArray* cellArray, vtkCellArray* faces);
606 
607  static void DecomposeAPolyhedronCell(const vtkIdType* cellStream, vtkIdType& numCellPts,
608  vtkIdType& nCellFaces, vtkCellArray* cellArray, vtkCellArray* faces,
609  vtkCellArray* faceLocations);
610 
611  static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, const vtkIdType* cellStream,
612  vtkIdType& numCellPts, vtkCellArray* cellArray, vtkCellArray* faces,
613  vtkCellArray* faceLocations);
614 
615 private:
616  // Hide these from the user and the compiler.
617  vtkUnstructuredGrid(const vtkUnstructuredGrid&) = delete;
618  void operator=(const vtkUnstructuredGrid&) = delete;
619 
620  void Cleanup();
621 };
622 
623 VTK_ABI_NAMESPACE_END
624 #endif
vtkIdType GetCellSize(vtkIdType) override
This method always returns 1, as all cells are point in a pure vtkPointSet.
Definition: vtkPointSet.h:156
bool AllocateEstimate(vtkIdType numCells, vtkIdType maxCellSize)
Pre-allocate memory in internal data structures.
static vtkUnstructuredGridBase * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkDataArray * GetCellTypes()
void Allocate(vtkIdType numCells=1000, int extSize=1000) override
Method allocates initial storage for the cell connectivity.
bool IsCellBoundary(vtkIdType cellId, vtkIdType npts, const vtkIdType *ptIds)
A topological inquiry to determine whether a topological entity (e.g., point, edge, or face) defined by the point ids (ptIds of length npts) is a boundary entity of a specified cell (indicated by cellId).
void GetCellPoints(vtkIdType, vtkIdList *idList) override
Topological inquiry to get points defining cell.
Definition: vtkPointSet.h:137
dynamic, self-adjusting array of vtkIdType
vtkIdType GetNumberOfCells() override
This method always returns 0, as there are no cells in a vtkPointSet.
Definition: vtkPointSet.h:121
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
virtual int GetCellNumberOfFaces(vtkIdType cellId, unsigned char &cellType, vtkGenericCell *cell)
Get the number of faces of a cell.
virtual vtkMTimeType GetMeshMTime()
Abstract method which return the mesh (geometry/topology) modification time.
int vtkIdType
Definition: vtkType.h:363
int GetCellType(vtkIdType) override
This method always returns VTK_EMPTY_CELL, as there is no cell in a vtkPointSet.
Definition: vtkPointSet.h:150
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
Detect and break reference loops.
provides thread-safe access to cells
abstract class to specify cell behavior
Definition: vtkCell.h:50
#define VTK_DEPRECATED_IN_9_6_0(reason)
#define VTK_MARSHALMANUAL
virtual void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array)=0
Fill vtkIdTypeArray container with list of cell Ids.
a simple class to control print indentation
Definition: vtkIndent.h:28
static vtkPointSet * New()
Standard instantiation method.
list of point or cell ids
Definition: vtkIdList.h:25
virtual void GetDistinctCellTypes(vtkCellTypes *types)
Get a list of types of cells in a dataset.
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts)
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids...
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition: vtkIdList.h:76
virtual void GetCellTypes(vtkCellTypes *types)
Get a list of types of cells in a dataset.
Definition: vtkDataSet.h:189
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e...
#define VTK_SIZEHINT(...)
int GetDataObjectType() VTK_FUTURE_CONST override
Standard vtkDataSet API methods.
dynamic, self-adjusting array of unsigned char
static vtkPointSet * ExtendedNew()
object to represent cell connectivity
Definition: vtkCellArray.h:177
vtkCellIterator * NewCellIterator() override
Return an iterator that traverses the cells in this data set.
virtual int IsHomogeneous()=0
Traverse cells and determine if cells are all of the same type.
void GetPointCells(vtkIdType, vtkIdList *idList) override
Topological inquiry to get cells using point.
Definition: vtkPointSet.h:138
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
Store zero or more vtkInformation instances.
Efficient cell iterator for vtkDataSet topologies.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkCell * GetCell(vtkIdType) override
This method always return a vtkEmptyCell, as there is no cell in a vtkPointSet.
void CopyStructure(vtkDataSet *pd) override
Copy the geometric structure of an input point set object.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts, vtkIdList *ptIds) override
A higher-performing variant of the virtual vtkDataSet::GetCellPoints() for unstructured grids...
general representation of visualization data
Definition: vtkDataObject.h:55
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:43
dataset represents arbitrary combinations of all possible cell types.
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
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...
vtkIdType * GetPointer(vtkIdType i)
Get a pointer to a particular data index.
Definition: vtkIdList.h:150
VTKIOCATALYSTCONDUIT_EXPORT void SetPolyhedralCells(vtkUnstructuredGrid *grid, vtkCellArray *elements, vtkCellArray *subelements)
Create polyhedron in grid from elements and subelements.