VTK  9.0.2
vtkStructuredGrid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStructuredGrid.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 =========================================================================*/
42 #ifndef vtkStructuredGrid_h
43 #define vtkStructuredGrid_h
44 
45 #include "vtkCommonDataModelModule.h" // For export macro
46 #include "vtkPointSet.h"
47 
48 #include "vtkStructuredData.h" // Needed for inline methods
49 
50 class vtkEmptyCell;
51 class vtkHexahedron;
52 class vtkLine;
53 class vtkQuad;
55 class vtkVertex;
56 
57 class VTKCOMMONDATAMODEL_EXPORT vtkStructuredGrid : public vtkPointSet
58 {
59 public:
61 
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
68  int GetDataObjectType() override { return VTK_STRUCTURED_GRID; }
69 
73  void CopyStructure(vtkDataSet* ds) override;
74 
76 
80  double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override
81  {
82  return this->vtkPointSet::GetPoint(ptId);
83  }
84  void GetPoint(vtkIdType ptId, double p[3]) override { this->vtkPointSet::GetPoint(ptId, p); }
85  vtkCell* GetCell(vtkIdType cellId) override;
86  vtkCell* GetCell(int i, int j, int k) override;
87  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
88  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
89  int GetCellType(vtkIdType cellId) override;
90  vtkIdType GetNumberOfCells() override;
91  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
92  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override
93  {
94  vtkStructuredData::GetPointCells(ptId, cellIds, this->GetDimensions());
95  }
96  void Initialize() override;
97  int GetMaxCellSize() override { return 8; } // hexahedron is the largest
98  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
99  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds, int* seedLoc);
101 
103 
106  void SetDimensions(int i, int j, int k);
107  void SetDimensions(const int dim[3]);
109 
111 
114  virtual int* GetDimensions() VTK_SIZEHINT(3);
115  virtual void GetDimensions(int dim[3]);
117 
121  int GetDataDimension();
122 
124 
129  void SetExtent(int extent[6]);
130  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
131  vtkGetVector6Macro(Extent, int);
133 
142  unsigned long GetActualMemorySize() override;
143 
145 
148  void ShallowCopy(vtkDataObject* src) override;
149  void DeepCopy(vtkDataObject* src) override;
151 
155  int GetExtentType() override { return VTK_3D_EXTENT; }
156 
158 
164  void BlankPoint(vtkIdType ptId);
167 
169 
175  void BlankCell(vtkIdType ptId);
176  void UnBlankCell(vtkIdType ptId);
178 
184  unsigned char IsPointVisible(vtkIdType ptId);
185 
191  unsigned char IsCellVisible(vtkIdType cellId);
192 
197  bool HasAnyBlankPoints() override;
202  bool HasAnyBlankCells() override;
203 
210  void GetCellDims(int cellDims[3]);
211 
217  void Crop(const int* updateExtent) override;
218 
220 
226 
236  void GetPoint(int i, int j, int k, double p[3], bool adjustForExtent = true);
237 
238 protected:
240  ~vtkStructuredGrid() override;
241 
242  // for the GetCell method
248 
249  int Dimensions[3];
251 
252  int Extent[6];
253 
258  void ComputeScalarRange() override;
259 
260 private:
264  void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
265  {
266  this->GetCellNeighbors(cellId, &ptIds, &cellIds);
267  }
268 
269  // Internal method used by DeepCopy and ShallowCopy.
270  void InternalStructuredGridCopy(vtkStructuredGrid* src);
271 
272  static unsigned char MASKED_CELL_VALUE;
273 
274 private:
275  vtkStructuredGrid(const vtkStructuredGrid&) = delete;
276  void operator=(const vtkStructuredGrid&) = delete;
277 };
278 
280 {
281  vtkIdType nCells = 1;
282  int dims[3];
283  int i;
284 
285  this->GetDimensions(dims);
286  for (i = 0; i < 3; i++)
287  {
288  if (dims[i] <= 0)
289  {
290  return 0;
291  }
292  if (dims[i] > 1)
293  {
294  nCells *= (dims[i] - 1);
295  }
296  }
297 
298  return nCells;
299 }
300 
302 {
304 }
305 
306 #endif
abstract class to specify cell behavior
Definition: vtkCell.h:57
general representation of visualization data
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:30
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.
cell represents a 1D line
Definition: vtkLine.h:30
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:63
vtkIdType GetNumberOfPoints() override
See vtkDataSet for additional information.
Definition: vtkPointSet.h:234
void GetPoint(vtkIdType ptId, double x[3]) override
Copy point coordinates into user provided array x[3] for specified point id.
Definition: vtkPointSet.h:102
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:36
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, int dim[3])
Get the cells using a point.
topologically regular array of data
vtkHexahedron * Hexahedron
void SetDimensions(int i, int j, int k)
following methods are specific to structured grid
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
Copy point coordinates into user provided array x[3] for specified point id.
void BlankPoint(vtkIdType ptId)
Methods for supporting blanking of cells.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
void SetDimensions(const int dim[3])
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Topological inquiry to get points defining cell.
int GetDataObjectType() override
Return what type of dataset this is.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkStructuredGrid * GetData(vtkInformationVector *v, int i=0)
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Topological inquiry to get cells using point.
int GetMaxCellSize() override
Convenience method returns largest cell size in dataset.
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...
vtkIdType GetNumberOfPoints() override
Standard vtkDataSet API methods.
vtkIdType GetNumberOfCells() override
Determine the number of cells composing the dataset.
vtkCell * GetCell(vtkIdType cellId) override
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
bool HasAnyBlankCells() override
Returns 1 if there is any visibility constraint on the cells, 0 otherwise.
void UnBlankPoint(vtkIdType ptId)
virtual int * GetDimensions()
Get dimensions of this structured points dataset.
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
See vtkDataSet for additional information.
int GetCellType(vtkIdType cellId) override
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
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)
void UnBlankCell(vtkIdType ptId)
void Initialize() override
Reset to an empty state and free any memory.
vtkEmptyCell * EmptyCell
vtkCell * GetCell(int i, int j, int k) override
dynamic, self-adjusting array of unsigned char
a cell that represents a 3D point
Definition: vtkVertex.h:31
@ info
Definition: vtkX3D.h:382
@ extent
Definition: vtkX3D.h:351
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:56
int vtkIdType
Definition: vtkType.h:338
#define VTK_STRUCTURED_GRID
Definition: vtkType.h:87
#define VTK_SIZEHINT(...)