VTK  9.7.1
vtkExplicitStructuredGrid.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
45 #ifndef vtkExplicitStructuredGrid_h
46 #define vtkExplicitStructuredGrid_h
47 
48 #include "vtkAbstractCellLinks.h" // For vtkAbstractCellLinks
49 #include "vtkCellArray.h" // For vtkCellArray
50 #include "vtkCommonDataModelModule.h" // For export macro
51 #include "vtkNew.h" // for vtkNew
52 #include "vtkPointSet.h"
53 #include "vtkStructuredData.h" // For static method usage
54 
55 VTK_ABI_NAMESPACE_BEGIN
56 class vtkCellArray;
57 
58 class VTKCOMMONDATAMODEL_EXPORT vtkExplicitStructuredGrid : public vtkPointSet
59 {
60 public:
62 
67  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
73  int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_EXPLICIT_STRUCTURED_GRID; }
74 
76 
79  void Initialize() override;
80  using vtkDataSet::GetCell;
81  vtkCell* GetCell(vtkIdType cellId) override;
82  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
83  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
84  int GetCellType(vtkIdType cellId) override;
85  vtkIdType GetCellSize(vtkIdType cellId) override;
86  vtkIdType GetNumberOfCells() override;
87  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
88  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
89  int GetMaxCellSize() override { return 8; } // hexahedron is the largest
90  int GetMaxSpatialDimension() override { return 3; }
91  int GetMinSpatialDimension() override { return 3; }
92  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
94 
98  void CopyStructure(vtkDataSet* ds) override;
99 
101 
104  void ShallowCopy(vtkDataObject* src) override;
105  void DeepCopy(vtkDataObject* src) override;
107 
111  int GetDataDimension() { return 3; }
112 
114 
119  void SetDimensions(int i, int j, int k);
120  void SetDimensions(int dim[3]);
121  void GetDimensions(int dim[3]);
123 
129  void GetCellDims(int cellDims[3]);
130 
134  int GetExtentType() VTK_FUTURE_CONST override { return VTK_3D_EXTENT; }
135 
137 
144  void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1);
145  void SetExtent(VTK_FUTURE_CONST int extent[6]);
146  vtkGetVector6Macro(Extent, int);
148 
150 
153  vtkSetSmartPointerMacro(Cells, vtkCellArray);
154  vtkGetSmartPointerMacro(Cells, vtkCellArray);
156 
161  void BuildLinks();
162 
164 
167  vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
168  vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
170 
177 
183  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType*& pts);
184 
193  void GetCellPoints(
194  vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override;
195 
199  void GetCellNeighbors(
200  vtkIdType cellId, vtkIdType neighbors[6], VTK_FUTURE_CONST int wholeExtent[6] = nullptr);
201 
210  void ComputeCellStructuredCoords(
211  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent = true);
212 
221  vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent = true);
222 
228  void ComputeFacesConnectivityFlagsArray();
229 
231 
234  vtkSetStringMacro(FacesConnectivityFlagsArrayName);
235  vtkGetStringMacro(FacesConnectivityFlagsArrayName);
237 
239 
245  void BlankCell(vtkIdType cellId);
246  void UnBlankCell(vtkIdType cellId);
248 
252  bool HasAnyBlankCells() override;
253 
259  unsigned char IsCellVisible(vtkIdType cellId);
260 
266  unsigned char IsCellGhost(vtkIdType cellId);
267 
271  bool HasAnyGhostCells();
272 
274 
279  void Crop(const int updateExtent[6]) override;
280  virtual void Crop(
281  vtkExplicitStructuredGrid* input, const int updateExtent[6], bool generateOriginalCellIds);
283 
285 
291 
300  unsigned long GetActualMemorySize() override;
301 
312  void CheckAndReorderFaces();
313 
315 
321  void GenerateGhostArray(int zeroExt[6], bool cellOnly) override;
323 
324 protected:
326  ~vtkExplicitStructuredGrid() override;
327 
328  void ReportReferences(vtkGarbageCollector*) override;
329 
334  void ComputeScalarRange() override;
335 
339  virtual void InternalCopy(vtkExplicitStructuredGrid* src);
340 
344  void InternalCheckAndReorderFaces(bool swap);
345 
350  int FindConnectedFaces(int foundFaces[3]);
351 
356  static void CheckConnectedFaces(int& nFoundFaces, int foundFaces[3]);
357 
361  static void ComputeSwapFlag(int foundFaces[3], int swap[3]);
362 
366  static void ComputeMirrorFlag(int foundFaces[3], int mirror[3]);
367 
371  void ReorderCellsPoints(const int* ptsMap, const int transformFlag[3]);
372 
375  int Extent[6];
377 
378 private:
380  void operator=(const vtkExplicitStructuredGrid&) = delete;
381 };
382 
383 //----------------------------------------------------------------------------
385 {
387 }
388 
389 //----------------------------------------------------------------------------
390 inline void vtkExplicitStructuredGrid::GetCellDims(int cellDims[3])
391 {
393 }
394 
395 //----------------------------------------------------------------------------
397  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent)
398 {
399  int ijk[3];
400  if (adjustForExtent)
401  {
403  }
404  else
405  {
406  int dims[3];
407  this->GetDimensions(dims);
409  }
410  i = ijk[0];
411  j = ijk[1];
412  k = ijk[2];
413 }
414 
415 //----------------------------------------------------------------------------
416 inline vtkIdType vtkExplicitStructuredGrid::ComputeCellId(int i, int j, int k, bool adjustForExtent)
417 {
418  int ijk[] = { i, j, k };
419  if (adjustForExtent)
420  {
422  }
423  else
424  {
425  int dims[3];
426  this->GetDimensions(dims);
427  return vtkStructuredData::ComputeCellId(dims, ijk);
428  }
429 }
430 VTK_ABI_NAMESPACE_END
431 #endif
vtkIdType GetCellSize(vtkIdType) override
This method always returns 1, as all cells are point in a pure vtkPointSet.
Definition: vtkPointSet.h:156
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:477
static void ComputeCellStructuredCoordsForExtent(vtkIdType cellIdx, const int ext[6], int ijk[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given the global grid extent and the linear index of a cell within the grid extent, this method computes the corresponding structured coordinates of the given cell.
int GetMinSpatialDimension() override
Standard vtkDataSet API methods.
VTKIOHDF_EXPORT std::vector< hsize_t > GetDimensions(hid_t fileID, const char *datasetName)
Returns the dimensions of a HDF dataset of a file.
static void ComputeCellStructuredCoords(vtkIdType cellId, const int dim[3], int ijk[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given a cellId and grid dimensions 'dim', get the structured coordinates (i-j-k). ...
static vtkIdType ComputeCellIdForExtent(const int extent[6], const int ijk[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given a location in structured coordinates (i-j-k), and the extent of the structured dataset...
int GetDataObjectType() VTK_FUTURE_CONST override
Return what type of dataset this is.
virtual void ComputeScalarRange()
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkSmartPointer< vtkCellArray > Cells
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:52
void GetCellPoints(vtkIdType, vtkIdList *idList) override
Topological inquiry to get points defining cell.
Definition: vtkPointSet.h:137
static void GetDimensionsFromExtent(const int ext[6], int dims[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Computes the structured grid dimensions based on the given extent.
static vtkPointSet * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
concrete class for storing a set of points
Definition: vtkPointSet.h:58
vtkIdType GetNumberOfCells() override
This method always returns 0, as there are no cells in a vtkPointSet.
Definition: vtkPointSet.h:121
int vtkIdType
Definition: vtkType.h:363
vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent=true)
Given a location in structured coordinates (i-j-k), return the cell id.
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:528
int GetCellType(vtkIdType) override
This method always returns VTK_EMPTY_CELL, as there is no cell in a vtkPointSet.
Definition: vtkPointSet.h:150
static vtkIdType ComputeCellId(const int dim[3], const int ijk[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given a location in structured coordinates (i-j-k), and the dimensions of the structured dataset...
void GetCellDims(int cellDims[3])
Computes the cell dimensions according to internal point dimensions.
Detect and break reference loops.
provides thread-safe access to cells
void GetDimensions(int dim[3])
Set/Get the dimensions of this structured dataset in term of number of points along each direction...
int GetMaxSpatialDimension() override
Standard vtkDataSet API methods.
abstract class to specify cell behavior
Definition: vtkCell.h:50
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
a simple class to control print indentation
Definition: vtkIndent.h:28
int GetExtentType() VTK_FUTURE_CONST override
The extent type is a 3D extent.
void ComputeCellStructuredCoords(vtkIdType cellId, int &i, int &j, int &k, bool adjustForExtent=true)
Given a cellId, get the structured coordinates (i-j-k).
static vtkPointSet * New()
Standard instantiation method.
list of point or cell ids
Definition: vtkIdList.h:25
bool HasAnyGhostCells()
Returns 1 if there are any ghost cells 0 otherwise.
void Initialize() override
Reset to an empty state and free any memory.
int GetDataDimension()
Return the dimensionality of the data.
vtkSmartPointer< vtkAbstractCellLinks > Links
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e...
int GetMaxCellSize() override
Standard vtkDataSet API methods.
A cell specified by degrees of freedom held in arrays.
object to represent cell connectivity
Definition: vtkCellArray.h:177
structured grid with explicit topology and geometry
static void GetCellDimensionsFromExtent(const int ext[6], int celldims[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Returns the cell dimensions, i.e., the number of cells along the i,j,k for the grid with the given gr...
void GetPointCells(vtkIdType, vtkIdList *idList) override
Topological inquiry to get cells using point.
Definition: vtkPointSet.h:138
Store zero or more vtkInformation instances.
virtual void Crop(const int updateExtent[6])
This method crops the data object (if necessary) so that the extent matches the update extent...
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.
general representation of visualization data
Definition: vtkDataObject.h:55
void ReportReferences(vtkGarbageCollector *) override
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.