VTK  9.3.0
vtkStructuredGrid.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
36 #ifndef vtkStructuredGrid_h
37 #define vtkStructuredGrid_h
38 
39 #include "vtkCommonDataModelModule.h" // For export macro
40 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
41 #include "vtkPointSet.h"
42 
43 #include "vtkStructuredData.h" // Needed for inline methods
44 
45 VTK_ABI_NAMESPACE_BEGIN
46 class vtkEmptyCell;
47 class vtkHexahedron;
48 class vtkLine;
49 class vtkQuad;
51 class vtkVertex;
52 
53 class VTKCOMMONDATAMODEL_EXPORT vtkStructuredGrid : public vtkPointSet
54 {
55 public:
58 
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
65  int GetDataObjectType() override { return VTK_STRUCTURED_GRID; }
66 
70  void CopyStructure(vtkDataSet* ds) override;
71 
73 
77  double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override
78  {
79  return this->vtkPointSet::GetPoint(ptId);
80  }
81  void GetPoint(vtkIdType ptId, double p[3]) override { this->vtkPointSet::GetPoint(ptId, p); }
82  vtkCell* GetCell(vtkIdType cellId) override;
83  vtkCell* GetCell(int i, int j, int k) override;
84  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
85  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
86  int GetCellType(vtkIdType cellId) override;
87  vtkIdType GetCellSize(vtkIdType cellId) override;
88  vtkIdType GetNumberOfCells() override;
90  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
91  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override
92  {
93  int dims[3];
94  this->GetDimensions(dims);
95  vtkStructuredData::GetPointCells(ptId, cellIds, dims);
96  }
97  void Initialize() override;
98  int GetMaxCellSize() override { return 8; } // hexahedron is the largest
99  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
100  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds, int* seedLoc);
102 
104 
107  void SetDimensions(int i, int j, int k);
108 
112  void SetDimensions(const int dims[3]);
114 
116 
119  VTK_DEPRECATED_IN_9_3_0("Please use GetDimensions(int dims[3]) instead.")
120  virtual int* GetDimensions() VTK_SIZEHINT(3);
121 
125  virtual void GetDimensions(int dims[3]);
127 
131  int GetDataDimension();
132 
134 
139  void SetExtent(VTK_FUTURE_CONST int extent[6]);
140  void SetExtent(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax);
141  vtkGetVector6Macro(Extent, int);
143 
152  unsigned long GetActualMemorySize() override;
153 
155 
158  void ShallowCopy(vtkDataObject* src) override;
159  void DeepCopy(vtkDataObject* src) override;
161 
165  int GetExtentType() override { return VTK_3D_EXTENT; }
166 
168 
174  void BlankPoint(vtkIdType ptId);
177 
179 
185  void BlankCell(vtkIdType ptId);
186  void UnBlankCell(vtkIdType ptId);
188 
194  unsigned char IsPointVisible(vtkIdType ptId);
195 
201  unsigned char IsCellVisible(vtkIdType cellId);
202 
207  bool HasAnyBlankPoints() override;
212  bool HasAnyBlankCells() override;
213 
220  void GetCellDims(int cellDims[3]);
221 
227  void Crop(const int* updateExtent) override;
228 
230 
236 
246  void GetPoint(int i, int j, int k, double p[3], bool adjustForExtent = true);
247 
248 protected:
250  ~vtkStructuredGrid() override;
251 
252  // for the GetCell method
258 
259 #if !defined(VTK_LEGACY_REMOVE)
260  int Dimensions[3];
261 #endif
263 
264  int Extent[6];
265 
270  void ComputeScalarRange() override;
271 
272 private:
273  // Internal method used by DeepCopy and ShallowCopy.
274  void InternalStructuredGridCopy(vtkStructuredGrid* src);
275 
276  vtkStructuredGrid(const vtkStructuredGrid&) = delete;
277  void operator=(const vtkStructuredGrid&) = delete;
278 };
279 
281 {
282  vtkIdType nCells = 1;
283  int dims[3];
284  int i;
285 
286  this->GetDimensions(dims);
287  for (i = 0; i < 3; i++)
288  {
289  if (dims[i] <= 0)
290  {
291  return 0;
292  }
293  if (dims[i] > 1)
294  {
295  nCells *= (dims[i] - 1);
296  }
297  }
298 
299  return nCells;
300 }
301 
303 {
305 }
306 
307 VTK_ABI_NAMESPACE_END
308 #endif
abstract class to specify cell behavior
Definition: vtkCell.h:50
general representation of visualization data
Definition: vtkDataObject.h:55
abstract class to specify dataset behavior
Definition: vtkDataSet.h:53
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:22
provides thread-safe access to cells
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:34
list of point or cell ids
Definition: vtkIdList.h:23
a simple class to control print indentation
Definition: vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
cell represents a 1D line
Definition: vtkLine.h:23
concrete class for storing a set of points
Definition: vtkPointSet.h:59
vtkIdType GetNumberOfCells() override
This method always returns 0, as there are no cells in a vtkPointSet.
Definition: vtkPointSet.h:123
vtkIdType GetNumberOfPoints() override
See vtkDataSet for additional information.
Definition: vtkPointSet.h:283
void GetPoint(vtkIdType ptId, double x[3]) override
See vtkDataSet for additional information.
Definition: vtkPointSet.h:110
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:28
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, VTK_FUTURE_CONST int dim[3])
Get the cells using a point.
topologically regular array of data
vtkHexahedron * Hexahedron
void SetDimensions(int i, int j, int k)
Sets the extent to be 0 to i-1, 0 to j-1, and 0 to k-1.
vtkIdType GetCellSize(vtkIdType cellId) override
Standard vtkDataSet API methods.
void GetCellDims(int cellDims[3])
Given the node dimensions of this grid instance, this method computes the node dimensions.
void BlankCell(vtkIdType ptId)
Methods for supporting blanking of cells.
static vtkStructuredGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
void GetPoint(vtkIdType ptId, double p[3]) override
Standard vtkDataSet API methods.
void BlankPoint(vtkIdType ptId)
Methods for supporting blanking of cells.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Standard vtkDataSet API methods.
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
int GetDataObjectType() override
Return what type of dataset this is.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet API methods.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
static vtkStructuredGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
int GetMaxCellSize() override
Standard vtkDataSet API methods.
int GetDataDimension()
Return the dimensionality of the data.
static vtkStructuredGrid * New()
~vtkStructuredGrid() override
void ComputeScalarRange() override
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
static vtkStructuredGrid * ExtendedNew()
vtkIdType GetNumberOfPoints() override
Standard vtkDataSet API methods.
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet API methods.
bool HasAnyBlankCells() override
Returns 1 if there is any visibility constraint on the cells, 0 otherwise.
void UnBlankPoint(vtkIdType ptId)
Methods for supporting blanking of cells.
virtual int * GetDimensions()
Get dimensions of this structured grid.
void Crop(const int *updateExtent) override
Reallocates and copies to set the Extent to the UpdateExtent.
unsigned char IsCellVisible(vtkIdType cellId)
Return non-zero value if specified point is visible.
double * GetPoint(vtkIdType ptId) override
Standard vtkDataSet API methods.
int GetCellType(vtkIdType cellId) override
Standard vtkDataSet API methods.
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input poly data object.
unsigned char IsPointVisible(vtkIdType ptId)
Return non-zero value if specified point is visible.
void GetPoint(int i, int j, int k, double p[3], bool adjustForExtent=true)
Get a point in the grid.
bool HasAnyBlankPoints() override
Returns 1 if there is any visibility constraint on the points, 0 otherwise.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds, int *seedLoc)
Standard vtkDataSet API methods.
void UnBlankCell(vtkIdType ptId)
Methods for supporting blanking of cells.
void Initialize() override
Standard vtkDataSet API methods.
vtkEmptyCell * EmptyCell
vtkCell * GetCell(int i, int j, int k) override
Standard vtkDataSet API methods.
void SetDimensions(const int dims[3])
Sets the extent to be 0 to dim[i]-1 in all 3 dimensions.
dynamic, self-adjusting array of unsigned char
a cell that represents a 3D point
Definition: vtkVertex.h:23
@ info
Definition: vtkX3D.h:376
@ extent
Definition: vtkX3D.h:345
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:51
#define VTK_DEPRECATED_IN_9_3_0(reason)
int vtkIdType
Definition: vtkType.h:315
#define VTK_STRUCTURED_GRID
Definition: vtkType.h:67
#define VTK_SIZEHINT(...)