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 =========================================================================*/
83 #ifndef vtkExplicitStructuredGrid_h
84 #define vtkExplicitStructuredGrid_h
85 
86 #include "vtkCommonDataModelModule.h" // For export macro
87 #include "vtkNew.h" // for vtkNew
88 #include "vtkPointSet.h"
89 #include "vtkStructuredData.h" // For static method usage
90 
91 class vtkCellArray;
93 class vtkEmptyCell;
94 class vtkHexahedron;
95 
96 class VTKCOMMONDATAMODEL_EXPORT vtkExplicitStructuredGrid : public vtkPointSet
97 {
98 public:
100 
105  void PrintSelf(ostream& os, vtkIndent indent) override;
107 
112 
114 
117  void Initialize() override;
118  using vtkDataSet::GetCell;
119  vtkCell* GetCell(vtkIdType cellId) override;
120  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
121  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
122  int GetCellType(vtkIdType cellId) override;
124  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
125  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
126  int GetMaxCellSize() override { return 8; } // hexahedron is the largest
127  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
129 
133  void CopyStructure(vtkDataSet* ds) override;
134 
136 
139  void ShallowCopy(vtkDataObject* src) override;
140  void DeepCopy(vtkDataObject* src) override;
142 
146  inline int GetDataDimension() { return 3; }
147 
149 
154  void SetDimensions(int i, int j, int k);
155  void SetDimensions(int dim[3]);
156  void GetDimensions(int dim[3]);
158 
164  void GetCellDims(int cellDims[3]);
165 
169  int GetExtentType() override { return VTK_3D_EXTENT; }
170 
172 
179  void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1);
180  void SetExtent(int extent[6]);
181  vtkGetVector6Macro(Extent, int);
183 
185 
188  void SetCells(vtkCellArray* cells);
189  vtkGetObjectMacro(Cells, vtkCellArray);
191 
193 
197  void BuildLinks();
198  vtkGetObjectMacro(Links, vtkAbstractCellLinks);
200 
205 
209  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType*& pts);
210 
214  void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int* wholeExtent = nullptr);
215 
224  void ComputeCellStructuredCoords(
225  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent = true);
226 
235  vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent = true);
236 
243 
245 
248  vtkSetStringMacro(FacesConnectivityFlagsArrayName);
249  vtkGetStringMacro(FacesConnectivityFlagsArrayName);
251 
253 
259  void BlankCell(vtkIdType cellId);
260  void UnBlankCell(vtkIdType cellId);
262 
266  bool HasAnyBlankCells() override;
267 
273  unsigned char IsCellVisible(vtkIdType cellId);
274 
280  unsigned char IsCellGhost(vtkIdType cellId);
281 
286 
288 
293  void Crop(const int* updateExtent) override;
294  virtual void Crop(
295  vtkExplicitStructuredGrid* input, const int* updateExtent, bool generateOriginalCellIds);
297 
299 
305 
314  unsigned long GetActualMemorySize() override;
315 
327 
329 
335  void GenerateGhostArray(int zeroExt[6], bool cellOnly) override;
337 
338 protected:
341 
346  void ComputeScalarRange() override;
347 
352 
357 
362 
367  int FindConnectedFaces(int foundFaces[3]);
368 
373  static void CheckConnectedFaces(int& nFoundFaces, int foundFaces[3]);
374 
378  static void ComputeSwapFlag(int foundFaces[3], int swap[3]);
379 
383  static void ComputeMirrorFlag(int foundFaces[3], int mirror[3]);
384 
388  void ReorderCellsPoints(const int* ptsMap, const int transformFlag[3]);
389 
390  // Used by GetCell method
393 
396  int Extent[6];
398 
399 private:
401  void operator=(const vtkExplicitStructuredGrid&) = delete;
402 };
403 
404 //----------------------------------------------------------------------------
406 {
408 }
409 
410 //----------------------------------------------------------------------------
411 inline void vtkExplicitStructuredGrid::GetCellDims(int cellDims[3])
412 {
414 }
415 
416 //----------------------------------------------------------------------------
418  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent)
419 {
420  int ijk[3];
421  if (adjustForExtent)
422  {
424  }
425  else
426  {
427  int dims[3];
428  this->GetDimensions(dims);
430  }
431  i = ijk[0];
432  j = ijk[1];
433  k = ijk[2];
434 }
435 
436 //----------------------------------------------------------------------------
437 inline vtkIdType vtkExplicitStructuredGrid::ComputeCellId(int i, int j, int k, bool adjustForExtent)
438 {
439  int ijk[] = { i, j, k };
440  if (adjustForExtent)
441  {
443  }
444  else
445  {
446  int dims[3];
447  this->GetDimensions(dims);
448  return vtkStructuredData::ComputeCellId(dims, ijk);
449  }
450 }
451 #endif
vtkExplicitStructuredGrid::GetCellPoints
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
vtkExplicitStructuredGrid::Hexahedron
vtkNew< vtkHexahedron > Hexahedron
Definition: vtkExplicitStructuredGrid.h:391
vtkDataSet::GenerateGhostArray
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:503
vtkExplicitStructuredGrid::HasAnyBlankCells
bool HasAnyBlankCells() override
Returns true if one or more cells are blanked, false otherwise.
vtkExplicitStructuredGrid::GetCell
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet API methods.
vtkExplicitStructuredGrid::FindConnectedFaces
int FindConnectedFaces(int foundFaces[3])
Find a connected face for each axis if any.
vtkExplicitStructuredGrid::GetDimensions
void GetDimensions(int dim[3])
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
Definition: vtkExplicitStructuredGrid.h:405
vtkExplicitStructuredGrid::GetData
static vtkExplicitStructuredGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
vtkExplicitStructuredGrid::Crop
virtual void Crop(vtkExplicitStructuredGrid *input, const int *updateExtent, bool generateOriginalCellIds)
Reallocates and copies to set the Extent to the UpdateExtent.
vtkExplicitStructuredGrid::SetDimensions
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.
vtkExplicitStructuredGrid::CopyStructure
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input poly data object.
vtkExplicitStructuredGrid::Crop
void Crop(const int *updateExtent) override
Reallocates and copies to set the Extent to the UpdateExtent.
vtkExplicitStructuredGrid::GetCell
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet API methods.
vtkHexahedron
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:111
vtkExplicitStructuredGrid::New
static vtkExplicitStructuredGrid * New()
Standard methods for instantiation, type information, and printing.
vtkExplicitStructuredGrid::ComputeSwapFlag
static void ComputeSwapFlag(int foundFaces[3], int swap[3])
Compute a swap flag based if a face have been found.
vtkExplicitStructuredGrid::EmptyCell
vtkNew< vtkEmptyCell > EmptyCell
Definition: vtkExplicitStructuredGrid.h:392
vtkPointSet.h
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkExplicitStructuredGrid::CheckConnectedFaces
static void CheckConnectedFaces(int &nFoundFaces, int foundFaces[3])
Check a list of connected faces and remove invalid face or extrapolate missing faces.
vtkExplicitStructuredGrid::ReorderCellsPoints
void ReorderCellsPoints(const int *ptsMap, const int transformFlag[3])
Reorder all cells points based on a transformFlag for each axis and a points map.
vtkStructuredData::GetCellDimensionsFromExtent
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...
Definition: vtkStructuredData.h:317
vtkStructuredData::ComputeCellStructuredCoords
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).
Definition: vtkStructuredData.h:436
vtkExplicitStructuredGrid::vtkExplicitStructuredGrid
vtkExplicitStructuredGrid()
vtkExplicitStructuredGrid::ComputeCellId
vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent=true)
Given a location in structured coordinates (i-j-k), return the cell id.
Definition: vtkExplicitStructuredGrid.h:437
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkEmptyCell
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:30
vtkExplicitStructuredGrid::ComputeMirrorFlag
static void ComputeMirrorFlag(int foundFaces[3], int mirror[3])
Compute a mirror flag based if a face have been found.
vtkExplicitStructuredGrid::GenerateGhostArray
void GenerateGhostArray(int zeroExt[6], bool cellOnly) override
Normally called by pipeline executives or algorithms only.
vtkExplicitStructuredGrid::Initialize
void Initialize() override
Standard vtkDataSet API methods.
vtkExplicitStructuredGrid::InternalCopy
virtual void InternalCopy(vtkExplicitStructuredGrid *src)
Internal method used by DeepCopy and ShallowCopy.
vtkExplicitStructuredGrid::GetCellType
int GetCellType(vtkIdType cellId) override
Standard vtkDataSet API methods.
vtkExplicitStructuredGrid::GetNumberOfCells
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
vtkExplicitStructuredGrid::GetCellPoints
vtkIdType * GetCellPoints(vtkIdType cellId)
Get direct raw pointer to the 8 points indices of an hexahedra.
vtkExplicitStructuredGrid::ComputeFacesConnectivityFlagsArray
void ComputeFacesConnectivityFlagsArray()
Compute the faces connectivity flags array.
vtkExplicitStructuredGrid::GetCell
void GetCell(vtkIdType, vtkCell *)
Internal method used by GetCell.
vtkStructuredData::GetDimensionsFromExtent
static void GetDimensionsFromExtent(const int ext[6], int dims[3], int dataDescription=VTK_EMPTY)
Computes the structured grid dimensions based on the given extent.
Definition: vtkStructuredData.h:375
vtkExplicitStructuredGrid::GetPointCells
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
vtkExplicitStructuredGrid::IsCellGhost
unsigned char IsCellGhost(vtkIdType cellId)
Return non-zero value if specified cell is a ghost cell.
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:165
vtkExplicitStructuredGrid::GetCellDims
void GetCellDims(int cellDims[3])
Computes the cell dimensions according to internal point dimensions.
Definition: vtkExplicitStructuredGrid.h:411
vtkStructuredData.h
vtkExplicitStructuredGrid::CheckAndReorderFaces
void CheckAndReorderFaces()
Check faces are numbered correctly regarding ijk numbering If not this will reorganize cell points or...
vtkExplicitStructuredGrid::GetData
static vtkExplicitStructuredGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkExplicitStructuredGrid::ComputeCellStructuredCoords
void ComputeCellStructuredCoords(vtkIdType cellId, int &i, int &j, int &k, bool adjustForExtent=true)
Given a cellId, get the structured coordinates (i-j-k).
Definition: vtkExplicitStructuredGrid.h:417
vtkExplicitStructuredGrid::ComputeScalarRange
void ComputeScalarRange() override
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:147
vtkExplicitStructuredGrid::SetDimensions
void SetDimensions(int dim[3])
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
vtkExplicitStructuredGrid::GetMaxCellSize
int GetMaxCellSize() override
Standard vtkDataSet API methods.
Definition: vtkExplicitStructuredGrid.h:126
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkExplicitStructuredGrid::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, type information, and printing.
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:290
vtkExplicitStructuredGrid::BuildLinks
void BuildLinks()
Create/Get upward links from points to cells that use each point.
vtkExplicitStructuredGrid::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkExplicitStructuredGrid.h:111
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkExplicitStructuredGrid::GetCellNeighbors
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
vtkNew< vtkHexahedron >
vtkExplicitStructuredGrid::UnBlankCell
void UnBlankCell(vtkIdType cellId)
Methods for supporting blanking of cells.
vtkExplicitStructuredGrid::GetExtentType
int GetExtentType() override
The extent type is a 3D extent.
Definition: vtkExplicitStructuredGrid.h:169
vtkExplicitStructuredGrid::GetActualMemorySize
unsigned long GetActualMemorySize() override
Return the actual size of the data in kilobytes.
vtkExplicitStructuredGrid::ShallowCopy
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::info
@ info
Definition: vtkX3D.h:382
VTK_EXPLICIT_STRUCTURED_GRID
#define VTK_EXPLICIT_STRUCTURED_GRID
Definition: vtkType.h:117
vtkNew.h
vtkExplicitStructuredGrid::FacesConnectivityFlagsArrayName
char * FacesConnectivityFlagsArrayName
Definition: vtkExplicitStructuredGrid.h:397
vtkPointSet
concrete class for storing a set of points
Definition: vtkPointSet.h:106
vtkExplicitStructuredGrid::BlankCell
void BlankCell(vtkIdType cellId)
Methods for supporting blanking of cells.
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:116
vtkExplicitStructuredGrid::GetCellNeighbors
void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int *wholeExtent=nullptr)
Get cell neighbors of the cell for every faces.
vtkExplicitStructuredGrid::Extent
int Extent[6]
Definition: vtkExplicitStructuredGrid.h:396
vtkExplicitStructuredGrid
structured grid with explicit topology and geometry
Definition: vtkExplicitStructuredGrid.h:97
vtkExplicitStructuredGrid::InternalCheckAndReorderFaces
void InternalCheckAndReorderFaces(bool swap)
Internal method used by CheckAndReorderFaces.
vtkExplicitStructuredGrid::GetCellBounds
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Standard vtkDataSet API methods.
vtkStructuredData::ComputeCellStructuredCoordsForExtent
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,...
Definition: vtkStructuredData.h:444
vtkX3D::extent
@ extent
Definition: vtkX3D.h:351
vtkExplicitStructuredGrid::SetExtent
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.
vtkExplicitStructuredGrid::SetCells
void SetCells(vtkCellArray *cells)
Set/Get the cell array defining hexahedron.
vtkExplicitStructuredGrid::GetDataDimension
int GetDataDimension()
Return the dimensionality of the data.
Definition: vtkExplicitStructuredGrid.h:146
vtkStructuredData::ComputeCellId
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,...
Definition: vtkStructuredData.h:331
vtkStructuredData::ComputeCellIdForExtent
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,...
Definition: vtkStructuredData.h:423
vtkExplicitStructuredGrid::Cells
vtkCellArray * Cells
Definition: vtkExplicitStructuredGrid.h:394
vtkExplicitStructuredGrid::DeepCopy
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkExplicitStructuredGrid::Links
vtkAbstractCellLinks * Links
Definition: vtkExplicitStructuredGrid.h:395
vtkExplicitStructuredGrid::~vtkExplicitStructuredGrid
~vtkExplicitStructuredGrid() override
vtkExplicitStructuredGrid::IsCellVisible
unsigned char IsCellVisible(vtkIdType cellId)
Return non-zero value if specified cell is visible.
vtkExplicitStructuredGrid::GetCellPoints
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType *&pts)
More efficient method to obtain cell points.
vtkExplicitStructuredGrid::SetExtent
void SetExtent(int extent[6])
Set/Get the extent of this structured dataset in term of number of points along each direction.
vtkExplicitStructuredGrid::HasAnyGhostCells
bool HasAnyGhostCells()
Returns true if one or more cells are ghost, false otherwise.
vtkDataSet::GetCell
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.