VTK  9.1.0
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;
95  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
96  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
97  int GetMaxCellSize() override { return 8; } // hexahedron is the largest
98  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
100 
104  void CopyStructure(vtkDataSet* ds) override;
105 
107 
110  void ShallowCopy(vtkDataObject* src) override;
111  void DeepCopy(vtkDataObject* src) override;
113 
117  inline int GetDataDimension() { return 3; }
118 
120 
125  void SetDimensions(int i, int j, int k);
126  void SetDimensions(int dim[3]);
127  void GetDimensions(int dim[3]);
129 
135  void GetCellDims(int cellDims[3]);
136 
140  int GetExtentType() override { return VTK_3D_EXTENT; }
141 
143 
150  void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1);
151  void SetExtent(int extent[6]);
152  vtkGetVector6Macro(Extent, int);
154 
156 
159  void SetCells(vtkCellArray* cells);
160  vtkGetObjectMacro(Cells, vtkCellArray);
162 
164 
168  void BuildLinks();
169  vtkGetObjectMacro(Links, vtkAbstractCellLinks);
171 
176 
180  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType*& pts);
181 
185  void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int* wholeExtent = nullptr);
186 
195  void ComputeCellStructuredCoords(
196  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent = true);
197 
206  vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent = true);
207 
214 
216 
219  vtkSetStringMacro(FacesConnectivityFlagsArrayName);
220  vtkGetStringMacro(FacesConnectivityFlagsArrayName);
222 
224 
230  void BlankCell(vtkIdType cellId);
231  void UnBlankCell(vtkIdType cellId);
233 
237  bool HasAnyBlankCells() override;
238 
244  unsigned char IsCellVisible(vtkIdType cellId);
245 
251  unsigned char IsCellGhost(vtkIdType cellId);
252 
257 
259 
264  void Crop(const int* updateExtent) override;
265  virtual void Crop(
266  vtkExplicitStructuredGrid* input, const int* updateExtent, bool generateOriginalCellIds);
268 
270 
276 
285  unsigned long GetActualMemorySize() override;
286 
298 
300 
306  void GenerateGhostArray(int zeroExt[6], bool cellOnly) override;
308 
309 protected:
312 
317  void ComputeScalarRange() override;
318 
323 
328 
333 
338  int FindConnectedFaces(int foundFaces[3]);
339 
344  static void CheckConnectedFaces(int& nFoundFaces, int foundFaces[3]);
345 
349  static void ComputeSwapFlag(int foundFaces[3], int swap[3]);
350 
354  static void ComputeMirrorFlag(int foundFaces[3], int mirror[3]);
355 
359  void ReorderCellsPoints(const int* ptsMap, const int transformFlag[3]);
360 
361  // Used by GetCell method
364 
367  int Extent[6];
369 
370 private:
372  void operator=(const vtkExplicitStructuredGrid&) = delete;
373 };
374 
375 //----------------------------------------------------------------------------
377 {
379 }
380 
381 //----------------------------------------------------------------------------
382 inline void vtkExplicitStructuredGrid::GetCellDims(int cellDims[3])
383 {
385 }
386 
387 //----------------------------------------------------------------------------
389  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent)
390 {
391  int ijk[3];
392  if (adjustForExtent)
393  {
395  }
396  else
397  {
398  int dims[3];
399  this->GetDimensions(dims);
401  }
402  i = ijk[0];
403  j = ijk[1];
404  k = ijk[2];
405 }
406 
407 //----------------------------------------------------------------------------
408 inline vtkIdType vtkExplicitStructuredGrid::ComputeCellId(int i, int j, int k, bool adjustForExtent)
409 {
410  int ijk[] = { i, j, k };
411  if (adjustForExtent)
412  {
414  }
415  else
416  {
417  int dims[3];
418  this->GetDimensions(dims);
419  return vtkStructuredData::ComputeCellId(dims, ijk);
420  }
421 }
422 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:181
abstract class to specify cell behavior
Definition: vtkCell.h:58
general representation of visualization data
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:394
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:30
structured grid with explicit topology and geometry
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkNew< vtkHexahedron > Hexahedron
void InternalCheckAndReorderFaces(bool swap)
Internal method used by CheckAndReorderFaces.
void Initialize() override
Standard vtkDataSet API methods.
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Standard vtkDataSet API methods.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
void ComputeScalarRange() override
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
int GetDataObjectType() override
Return what type of dataset this is.
void Crop(const int *updateExtent) override
Reallocates and copies to set the Extent to the UpdateExtent.
void SetCells(vtkCellArray *cells)
Set/Get the cell array defining hexahedron.
void GetCellDims(int cellDims[3])
Computes the cell dimensions according to internal point dimensions.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet API methods.
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
void ReorderCellsPoints(const int *ptsMap, const int transformFlag[3])
Reorder all cells points based on a transformFlag for each axis and a points map.
void ComputeCellStructuredCoords(vtkIdType cellId, int &i, int &j, int &k, bool adjustForExtent=true)
Given a cellId, get the structured coordinates (i-j-k).
int GetDataDimension()
Return the dimensionality of the data.
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input poly data object.
virtual void InternalCopy(vtkExplicitStructuredGrid *src)
Internal method used by DeepCopy and ShallowCopy.
void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1)
Set/Get the extent of this structured dataset in term of number of points along each direction.
int FindConnectedFaces(int foundFaces[3])
Find a connected face for each axis if any.
virtual void Crop(vtkExplicitStructuredGrid *input, const int *updateExtent, bool generateOriginalCellIds)
Reallocates and copies to set the Extent to the UpdateExtent.
vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent=true)
Given a location in structured coordinates (i-j-k), return the cell id.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
int GetCellType(vtkIdType cellId) override
Standard vtkDataSet API methods.
unsigned char IsCellVisible(vtkIdType cellId)
Return non-zero value if specified cell is visible.
static vtkExplicitStructuredGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
void SetDimensions(int dim[3])
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kilobytes.
void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int *wholeExtent=nullptr)
Get cell neighbors of the cell for every faces.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, type information, and printing.
void GetCell(vtkIdType, vtkCell *)
Internal method used by GetCell.
~vtkExplicitStructuredGrid() override
bool HasAnyGhostCells()
Returns true if one or more cells are ghost, false otherwise.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType *&pts)
More efficient method to obtain cell points.
void BuildLinks()
Create/Get upward links from points to cells that use each point.
static void CheckConnectedFaces(int &nFoundFaces, int foundFaces[3])
Check a list of connected faces and remove invalid face or extrapolate missing faces.
int GetMaxCellSize() override
Standard vtkDataSet API methods.
static void ComputeSwapFlag(int foundFaces[3], int swap[3])
Compute a swap flag based if a face have been found.
int GetExtentType() override
The extent type is a 3D extent.
void SetDimensions(int i, int j, int k)
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
void BlankCell(vtkIdType cellId)
Methods for supporting blanking of cells.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
void CheckAndReorderFaces()
Check faces are numbered correctly regarding ijk numbering If not this will reorganize cell points or...
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet API methods.
void UnBlankCell(vtkIdType cellId)
Methods for supporting blanking of cells.
void GetDimensions(int dim[3])
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
static void ComputeMirrorFlag(int foundFaces[3], int mirror[3])
Compute a mirror flag based if a face have been found.
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
bool HasAnyBlankCells() override
Returns true if one or more cells are blanked, false otherwise.
static vtkExplicitStructuredGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
static vtkExplicitStructuredGrid * New()
Standard methods for instantiation, type information, and printing.
vtkIdType * GetCellPoints(vtkIdType cellId)
Get direct raw pointer to the 8 points indices of an hexahedra.
unsigned char IsCellGhost(vtkIdType cellId)
Return non-zero value if specified cell is a ghost cell.
void ComputeFacesConnectivityFlagsArray()
Compute the faces connectivity flags array.
void GenerateGhostArray(int zeroExt[6], bool cellOnly) override
Normally called by pipeline executives or algorithms only.
void SetExtent(int extent[6])
Set/Get the extent of this structured dataset in term of number of points along each direction.
provides thread-safe access to cells
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:42
list of point or cell ids
Definition: vtkIdList.h:31
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
concrete class for storing a set of points
Definition: vtkPointSet.h:67
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...
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).
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 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,...
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,...
@ info
Definition: vtkX3D.h:382
@ extent
Definition: vtkX3D.h:351
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:56
int vtkIdType
Definition: vtkType.h:332
#define VTK_EXPLICIT_STRUCTURED_GRID
Definition: vtkType.h:117