VTK  9.0.3
vtkRectilinearGrid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRectilinearGrid.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 =========================================================================*/
37 #ifndef vtkRectilinearGrid_h
38 #define vtkRectilinearGrid_h
39 
40 #include "vtkCommonDataModelModule.h" // For export macro
41 #include "vtkDataSet.h"
42 #include "vtkStructuredData.h" // For inline methods
43 
44 class vtkVertex;
45 class vtkLine;
46 class vtkPixel;
47 class vtkVoxel;
48 class vtkDataArray;
49 class vtkPoints;
50 
51 class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet
52 {
53 public:
55 
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
62  int GetDataObjectType() override { return VTK_RECTILINEAR_GRID; }
63 
68  void CopyStructure(vtkDataSet* ds) override;
69 
73  void Initialize() override;
74 
76 
79  vtkIdType GetNumberOfCells() override;
80  vtkIdType GetNumberOfPoints() override;
81  double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
82  void GetPoint(vtkIdType id, double x[3]) override;
83  vtkCell* GetCell(vtkIdType cellId) override;
84  vtkCell* GetCell(int i, int j, int k) override;
85  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
86  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
87  vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z); }
88  vtkIdType FindPoint(double x[3]) override;
89  vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
90  double pcoords[3], double* weights) override;
91  vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
92  double tol2, int& subId, double pcoords[3], double* weights) override;
93  vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
94  double pcoords[3], double* weights) override;
95  int GetCellType(vtkIdType cellId) override;
96  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override
97  {
98  vtkStructuredData::GetCellPoints(cellId, ptIds, this->DataDescription, this->Dimensions);
99  }
100  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override
101  {
102  vtkStructuredData::GetPointCells(ptId, cellIds, this->Dimensions);
103  }
104  void ComputeBounds() override;
105  int GetMaxCellSize() override { return 8; } // voxel is the largest
106  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
108 
113  void GetPoints(vtkPoints* pnts);
114 
116 
120  void SetDimensions(int i, int j, int k);
121  void SetDimensions(const int dim[3]);
123 
125 
128  vtkGetVectorMacro(Dimensions, int, 3);
130 
134  int GetDataDimension();
135 
142  int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
143 
147  vtkIdType ComputePointId(int ijk[3]);
148 
152  vtkIdType ComputeCellId(int ijk[3]);
153 
159  void GetPoint(const int i, const int j, const int k, double p[3]);
160 
162 
166  vtkGetObjectMacro(XCoordinates, vtkDataArray);
168 
170 
174  vtkGetObjectMacro(YCoordinates, vtkDataArray);
176 
178 
182  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
184 
186 
191  void SetExtent(int extent[6]);
192  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
193  vtkGetVector6Macro(Extent, int);
195 
204  unsigned long GetActualMemorySize() override;
205 
207 
210  void ShallowCopy(vtkDataObject* src) override;
211  void DeepCopy(vtkDataObject* src) override;
213 
217  int GetExtentType() override { return VTK_3D_EXTENT; }
218 
224  void Crop(const int* updateExtent) override;
225 
227 
233 
234 protected:
237 
238  // for the GetCell method
243 
244  int Dimensions[3];
246 
247  int Extent[6];
248 
252 
253  // Hang on to some space for returning points when GetPoint(id) is called.
254  double PointReturn[3];
255 
256 private:
257  void Cleanup();
258 
259 private:
260  vtkRectilinearGrid(const vtkRectilinearGrid&) = delete;
261  void operator=(const vtkRectilinearGrid&) = delete;
262 };
263 
264 //----------------------------------------------------------------------------
266 {
267  vtkIdType nCells = 1;
268  int i;
269 
270  for (i = 0; i < 3; i++)
271  {
272  if (this->Dimensions[i] <= 0)
273  {
274  return 0;
275  }
276  if (this->Dimensions[i] > 1)
277  {
278  nCells *= (this->Dimensions[i] - 1);
279  }
280  }
281 
282  return nCells;
283 }
284 
285 //----------------------------------------------------------------------------
287 {
288  return static_cast<vtkIdType>(this->Dimensions[0]) * this->Dimensions[1] * this->Dimensions[2];
289 }
290 
291 //----------------------------------------------------------------------------
293 {
295 }
296 
297 //----------------------------------------------------------------------------
299 {
301 }
302 
303 //----------------------------------------------------------------------------
305 {
306  return vtkStructuredData::ComputeCellId(this->Dimensions, ijk);
307 }
308 
309 #endif
abstract class to specify cell behavior
Definition: vtkCell.h:57
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
general representation of visualization data
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:193
provides thread-safe access to cells
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
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:35
represent and manipulate 3D points
Definition: vtkPoints.h:34
a dataset that is topologically regular with variable spacing in the three coordinate directions
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Initialize() override
Restore object to initial state.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Locate cell based on global coordinate x and tolerance squared.
virtual void SetZCoordinates(vtkDataArray *)
Specify the grid coordinates in the z-direction.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Topological inquiry to get cells using point.
void GetPoint(const int i, const int j, const int k, double p[3])
Given the IJK-coordinates of the point, it returns the corresponding xyz-coordinates.
vtkIdType GetNumberOfPoints() override
Determine the number of points composing the dataset.
virtual void SetYCoordinates(vtkDataArray *)
Specify the grid coordinates in the y-direction.
virtual void SetXCoordinates(vtkDataArray *)
Specify the grid coordinates in the x-direction.
vtkCell * GetCell(vtkIdType cellId) override
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkIdType ComputeCellId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the cell id.
int GetExtentType() override
Structured extent.
void DeepCopy(vtkDataObject *src) override
vtkDataArray * YCoordinates
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
void SetExtent(int extent[6])
Different ways to set the extent of the data array.
vtkIdType FindPoint(double x, double y, double z)
int GetDataObjectType() override
Return what type of dataset this is.
void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2)
vtkDataArray * XCoordinates
static vtkRectilinearGrid * GetData(vtkInformationVector *v, int i=0)
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input rectilinear grid object.
void SetDimensions(int i, int j, int k)
Set dimensions of rectilinear grid dataset.
void GetPoints(vtkPoints *pnts)
Given a user-supplied vtkPoints container object, this method fills in all the points of the Rectilin...
~vtkRectilinearGrid() override
vtkIdType ComputePointId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the point id.
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Topological inquiry to get points defining cell.
vtkIdType FindPoint(double x[3]) override
double * GetPoint(vtkIdType ptId) override
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
int GetCellType(vtkIdType cellId) override
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
void GetPoint(vtkIdType id, double x[3]) override
Copy point coordinates into user provided array x[3] for specified point id.
vtkDataArray * ZCoordinates
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
static vtkRectilinearGrid * New()
vtkCell * GetCell(int i, int j, int k) override
int GetDataDimension()
Return the dimensionality of the data.
void ComputeBounds() override
Compute the data bounding box from data points.
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 Crop(const int *updateExtent) override
Reallocates and copies to set the Extent to the UpdateExtent.
vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
This is a version of the above method that can be used with multithreaded applications.
int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3])
Convenience function computes the structured coordinates for a point x[3].
static vtkRectilinearGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
int GetMaxCellSize() override
Convenience method returns largest cell size in dataset.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Locate the cell that contains a point and return the cell.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
void SetDimensions(const int dim[3])
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
Get the points defining a cell.
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
static vtkIdType ComputePointId(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,...
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
Get the cells using a point.
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,...
a cell that represents a 3D point
Definition: vtkVertex.h:31
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:39
@ 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_RECTILINEAR_GRID
Definition: vtkType.h:88
#define VTK_SIZEHINT(...)