VTK  9.2.6
vtkExplicitStructuredGrid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkExplicitStructuredGrid.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
54 #ifndef vtkExplicitStructuredGrid_h
55 #define vtkExplicitStructuredGrid_h
56 
57 #include "vtkCommonDataModelModule.h" // For export macro
58 #include "vtkNew.h" // for vtkNew
59 #include "vtkPointSet.h"
60 #include "vtkStructuredData.h" // For static method usage
61 
62 class vtkCellArray;
64 class vtkEmptyCell;
65 class vtkHexahedron;
66 
67 class VTKCOMMONDATAMODEL_EXPORT vtkExplicitStructuredGrid : public vtkPointSet
68 {
69 public:
71 
76  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
83 
85 
88  void Initialize() override;
89  using vtkDataSet::GetCell;
90  vtkCell* GetCell(vtkIdType cellId) override;
91  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
92  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
93  int GetCellType(vtkIdType cellId) override;
94  vtkIdType GetCellSize(vtkIdType cellId) override;
95  vtkIdType GetNumberOfCells() override;
96  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
97  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
98  int GetMaxCellSize() override { return 8; } // hexahedron is the largest
99  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
101 
105  void CopyStructure(vtkDataSet* ds) override;
106 
108 
111  void ShallowCopy(vtkDataObject* src) override;
112  void DeepCopy(vtkDataObject* src) override;
114 
118  inline int GetDataDimension() { return 3; }
119 
121 
126  void SetDimensions(int i, int j, int k);
127  void SetDimensions(int dim[3]);
128  void GetDimensions(int dim[3]);
130 
136  void GetCellDims(int cellDims[3]);
137 
141  int GetExtentType() override { return VTK_3D_EXTENT; }
142 
144 
151  void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1);
152  void SetExtent(int extent[6]);
153  vtkGetVector6Macro(Extent, int);
155 
157 
160  void SetCells(vtkCellArray* cells);
161  vtkGetObjectMacro(Cells, vtkCellArray);
163 
165 
169  void BuildLinks();
170  vtkGetObjectMacro(Links, vtkAbstractCellLinks);
172 
179 
185  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType*& pts);
186 
195  void GetCellPoints(
196  vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override;
197 
201  void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int* wholeExtent = nullptr);
202 
211  void ComputeCellStructuredCoords(
212  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent = true);
213 
222  vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent = true);
223 
229  void ComputeFacesConnectivityFlagsArray();
230 
232 
235  vtkSetStringMacro(FacesConnectivityFlagsArrayName);
236  vtkGetStringMacro(FacesConnectivityFlagsArrayName);
238 
240 
246  void BlankCell(vtkIdType cellId);
247  void UnBlankCell(vtkIdType cellId);
249 
253  bool HasAnyBlankCells() override;
254 
260  unsigned char IsCellVisible(vtkIdType cellId);
261 
267  unsigned char IsCellGhost(vtkIdType cellId);
268 
272  bool HasAnyGhostCells();
273 
275 
280  void Crop(const int* updateExtent) override;
281  virtual void Crop(
282  vtkExplicitStructuredGrid* input, const int* updateExtent, bool generateOriginalCellIds);
284 
286 
292 
301  unsigned long GetActualMemorySize() override;
302 
313  void CheckAndReorderFaces();
314 
316 
322  void GenerateGhostArray(int zeroExt[6], bool cellOnly) override;
324 
325 protected:
327  ~vtkExplicitStructuredGrid() override;
328 
333  void ComputeScalarRange() override;
334 
338  virtual void InternalCopy(vtkExplicitStructuredGrid* src);
339 
343  void GetCell(vtkIdType, vtkCell*);
344 
348  void InternalCheckAndReorderFaces(bool swap);
349 
354  int FindConnectedFaces(int foundFaces[3]);
355 
360  static void CheckConnectedFaces(int& nFoundFaces, int foundFaces[3]);
361 
365  static void ComputeSwapFlag(int foundFaces[3], int swap[3]);
366 
370  static void ComputeMirrorFlag(int foundFaces[3], int mirror[3]);
371 
375  void ReorderCellsPoints(const int* ptsMap, const int transformFlag[3]);
376 
377  // Used by GetCell method
380 
383  int Extent[6];
385 
386 private:
388  void operator=(const vtkExplicitStructuredGrid&) = delete;
389 };
390 
391 //----------------------------------------------------------------------------
393 {
395 }
396 
397 //----------------------------------------------------------------------------
398 inline void vtkExplicitStructuredGrid::GetCellDims(int cellDims[3])
399 {
401 }
402 
403 //----------------------------------------------------------------------------
405  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent)
406 {
407  int ijk[3];
408  if (adjustForExtent)
409  {
411  }
412  else
413  {
414  int dims[3];
415  this->GetDimensions(dims);
417  }
418  i = ijk[0];
419  j = ijk[1];
420  k = ijk[2];
421 }
422 
423 //----------------------------------------------------------------------------
424 inline vtkIdType vtkExplicitStructuredGrid::ComputeCellId(int i, int j, int k, bool adjustForExtent)
425 {
426  int ijk[] = { i, j, k };
427  if (adjustForExtent)
428  {
430  }
431  else
432  {
433  int dims[3];
434  this->GetDimensions(dims);
435  return vtkStructuredData::ComputeCellId(dims, ijk);
436  }
437 }
438 #endif
static void ComputeCellStructuredCoordsForExtent(const vtkIdType cellIdx, const int ext[6], int ijk[3], int dataDescription=VTK_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.
static void GetCellDimensionsFromExtent(const int ext[6], int celldims[3], int dataDescription=VTK_EMPTY)
Returns the cell dimensions, i.e., the number of cells along the i,j,k for the grid with the given gr...
vtkIdType GetCellSize(vtkIdType) override
This method always returns 1, as all cells are point in a pure vtkPointSet.
Definition: vtkPointSet.h:164
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:432
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:62
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:62
static void ComputeCellStructuredCoords(const vtkIdType cellId, const int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
Given a cellId and grid dimensions 'dim', get the structured coordinates (i-j-k). ...
vtkNew< vtkHexahedron > Hexahedron
void GetCellPoints(vtkIdType, vtkIdList *idList) override
Topological inquiry to get points defining cell.
Definition: vtkPointSet.h:145
static void GetDimensionsFromExtent(const int ext[6], int dims[3], int dataDescription=VTK_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:69
vtkIdType GetNumberOfCells() override
This method always returns 0, as there are no cells in a vtkPointSet.
Definition: vtkPointSet.h:129
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:32
int vtkIdType
Definition: vtkType.h:332
vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent=true)
Given a location in structured coordinates (i-j-k), return the cell id.
int GetExtentType() override
The extent type is a 3D extent.
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:472
int GetCellType(vtkIdType) override
This method always returns VTK_EMPTY_CELL, as there is no cell in a vtkPointSet.
Definition: vtkPointSet.h:158
void GetCellDims(int cellDims[3])
Computes the cell dimensions according to internal point dimensions.
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...
virtual void Crop(const int *updateExtent)
This method crops the data object (if necessary) so that the extent matches the update extent...
abstract class to specify cell behavior
Definition: vtkCell.h:60
int GetDataObjectType() override
Return what type of dataset this is.
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:39
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:33
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.
#define VTK_EXPLICIT_STRUCTURED_GRID
Definition: vtkType.h:117
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:44
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.
object to represent cell connectivity
Definition: vtkCellArray.h:186
structured grid with explicit topology and geometry
static vtkIdType ComputeCellIdForExtent(const int extent[6], const int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the extent of the structured dataset...
static vtkIdType ComputeCellId(const int dim[3], const int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the dimensions of the structured dataset...
void GetPointCells(vtkIdType, vtkIdList *idList) override
Topological inquiry to get cells using point.
Definition: vtkPointSet.h:146
Store zero or more vtkInformation instances.
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.
Definition: vtkPointSet.h:138
void CopyStructure(vtkDataSet *pd) override
Copy the geometric structure of an input point set object.
general representation of visualization data
Definition: vtkDataObject.h:65
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.