VTK  9.0.1
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 =========================================================================*/
49 #ifndef vtkExplicitStructuredGrid_h
50 #define vtkExplicitStructuredGrid_h
51 
52 #include "vtkCommonDataModelModule.h" // For export macro
53 #include "vtkNew.h" // for vtkNew
54 #include "vtkPointSet.h"
55 #include "vtkStructuredData.h" // For static method usage
56 
57 class vtkCellArray;
59 class vtkEmptyCell;
60 class vtkHexahedron;
61 
62 class VTKCOMMONDATAMODEL_EXPORT vtkExplicitStructuredGrid : public vtkPointSet
63 {
64 public:
66 
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
78 
80 
83  void Initialize() override;
84  using vtkDataSet::GetCell;
85  vtkCell* GetCell(vtkIdType cellId) override;
86  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
87  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
88  int GetCellType(vtkIdType cellId) override;
89  vtkIdType GetNumberOfCells() override;
90  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
91  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
92  int GetMaxCellSize() override { return 8; } // hexahedron is the largest
93  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
95 
99  void CopyStructure(vtkDataSet* ds) override;
100 
102 
105  void ShallowCopy(vtkDataObject* src) override;
106  void DeepCopy(vtkDataObject* src) override;
108 
112  inline int GetDataDimension() { return 3; }
113 
115 
120  void SetDimensions(int i, int j, int k);
121  void SetDimensions(int dim[3]);
122  void GetDimensions(int dim[3]);
124 
130  void GetCellDims(int cellDims[3]);
131 
135  int GetExtentType() override { return VTK_3D_EXTENT; }
136 
138 
145  void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1);
146  void SetExtent(int extent[6]);
147  vtkGetVector6Macro(Extent, int);
149 
151 
154  void SetCells(vtkCellArray* cells);
155  vtkGetObjectMacro(Cells, vtkCellArray);
157 
159 
163  void BuildLinks();
164  vtkGetObjectMacro(Links, vtkAbstractCellLinks);
166 
171 
175  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType*& pts);
176 
180  void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int* wholeExtent = nullptr);
181 
190  void ComputeCellStructuredCoords(
191  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent = true);
192 
201  vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent = true);
202 
206  void ComputeFacesConnectivityFlagsArray();
207 
209 
212  vtkSetStringMacro(FacesConnectivityFlagsArrayName);
213  vtkGetStringMacro(FacesConnectivityFlagsArrayName);
215 
217 
223  void BlankCell(vtkIdType cellId);
224  void UnBlankCell(vtkIdType cellId);
226 
230  bool HasAnyBlankCells() override;
231 
237  unsigned char IsCellVisible(vtkIdType cellId);
238 
244  unsigned char IsCellGhost(vtkIdType cellId);
245 
249  bool HasAnyGhostCells();
250 
252 
257  void Crop(const int* updateExtent) override;
258  virtual void Crop(
259  vtkExplicitStructuredGrid* input, const int* updateExtent, bool generateOriginalCellIds);
261 
263 
269 
278  unsigned long GetActualMemorySize() override;
279 
290  void CheckAndReorderFaces();
291 
293 
299  void GenerateGhostArray(int zeroExt[6], bool cellOnly) override;
301 
302 protected:
304  ~vtkExplicitStructuredGrid() override;
305 
310  virtual void ComputeScalarRange() override;
311 
315  virtual void InternalCopy(vtkExplicitStructuredGrid* src);
316 
320  void GetCell(vtkIdType, vtkCell*);
321 
325  void InternalCheckAndReorderFaces(bool swap);
326 
331  int FindConnectedFaces(int foundFaces[3]);
332 
337  static void CheckConnectedFaces(int& nFoundFaces, int foundFaces[3]);
338 
342  static void ComputeSwapFlag(int foundFaces[3], int swap[3]);
343 
347  static void ComputeMirrorFlag(int foundFaces[3], int mirror[3]);
348 
352  void ReorderCellsPoints(const int* ptsMap, const int transformFlag[3]);
353 
354  // Used by GetCell method
357 
360  int Extent[6];
362 
363 private:
365  void operator=(const vtkExplicitStructuredGrid&) = delete;
366 };
367 
368 //----------------------------------------------------------------------------
370 {
372 }
373 
374 //----------------------------------------------------------------------------
375 inline void vtkExplicitStructuredGrid::GetCellDims(int cellDims[3])
376 {
378 }
379 
380 //----------------------------------------------------------------------------
382  vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent)
383 {
384  int ijk[3];
385  if (adjustForExtent)
386  {
388  }
389  else
390  {
391  int dims[3];
392  this->GetDimensions(dims);
394  }
395  i = ijk[0];
396  j = ijk[1];
397  k = ijk[2];
398 }
399 
400 //----------------------------------------------------------------------------
401 inline vtkIdType vtkExplicitStructuredGrid::ComputeCellId(int i, int j, int k, bool adjustForExtent)
402 {
403  int ijk[] = { i, j, k };
404  if (adjustForExtent)
405  {
407  }
408  else
409  {
410  int dims[3];
411  this->GetDimensions(dims);
412  return vtkStructuredData::ComputeCellId(dims, ijk);
413  }
414 }
415 #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...
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:386
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
Topological inquiry to get cells using point.
static vtkDataObject * New()
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
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:56
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
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.
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:62
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:29
int vtkIdType
Definition: vtkType.h:338
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:426
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:56
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 methdos for type information and printing.
a simple class to control print indentation
Definition: vtkIndent.h:33
void ComputeCellStructuredCoords(vtkIdType cellId, int &i, int &j, int &k, bool adjustForExtent=true)
Given a cellId, get the structured coordinates (i-j-k).
list of point or cell ids
Definition: vtkIdList.h:30
bool HasAnyGhostCells()
Returns 1 if there are any ghost cells 0 otherwise.
void Initialize() override
Reset to an empty state and free any memory.
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
int GetDataDimension()
Return the dimensionality of the data.
#define VTK_EXPLICIT_STRUCTURED_GRID
Definition: vtkType.h:125
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:41
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:179
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...
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.
void CopyStructure(vtkDataSet *pd) override
Copy the geometric structure of an input point set object.
general representation of visualization data
Definition: vtkDataObject.h:59
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.
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.