VTK
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 =========================================================================*/
36 #ifndef vtkRectilinearGrid_h
37 #define vtkRectilinearGrid_h
38 
39 #include "vtkCommonDataModelModule.h" // For export macro
40 #include "vtkDataSet.h"
41 #include "vtkStructuredData.h" // For inline methods
42 
43 class vtkVertex;
44 class vtkLine;
45 class vtkPixel;
46 class vtkVoxel;
47 class vtkDataArray;
48 class vtkPoints;
49 
50 class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet
51 {
52 public:
53  static vtkRectilinearGrid *New();
54 
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
61  int GetDataObjectType() override {return VTK_RECTILINEAR_GRID;};
62 
67  void CopyStructure(vtkDataSet *ds) override;
68 
72  void Initialize() override;
73 
75 
78  vtkIdType GetNumberOfCells() override;
79  vtkIdType GetNumberOfPoints() override;
80  double *GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
81  void GetPoint(vtkIdType id, double x[3]) override;
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  vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);};
87  vtkIdType FindPoint(double x[3]) override;
88  vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
89  int& subId, double pcoords[3], double *weights) override;
90  vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell,
91  vtkIdType cellId, double tol2, int& subId,
92  double pcoords[3], double *weights) override;
93  vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
94  double tol2, int& subId, double pcoords[3],
95  double *weights) override;
96  int GetCellType(vtkIdType cellId) override;
97  void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
98  {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
99  this->Dimensions);}
100  void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
101  {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
102  void ComputeBounds() override;
103  int GetMaxCellSize() override {return 8;}; //voxel is the largest
104  void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
105  vtkIdList *cellIds) override;
107 
112  void GetPoints(vtkPoints* pnts);
113 
115 
119  void SetDimensions(int i, int j, int k);
120  void SetDimensions(int dim[3]);
122 
124 
127  vtkGetVectorMacro(Dimensions,int,3);
129 
133  int GetDataDimension();
134 
141  int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
142 
146  vtkIdType ComputePointId(int ijk[3]);
147 
151  vtkIdType ComputeCellId(int ijk[3]);
152 
158  void GetPoint(const int i,const int j,const int k,double p[3]);
159 
161 
164  virtual void SetXCoordinates(vtkDataArray*);
165  vtkGetObjectMacro(XCoordinates,vtkDataArray);
167 
169 
172  virtual void SetYCoordinates(vtkDataArray*);
173  vtkGetObjectMacro(YCoordinates,vtkDataArray);
175 
177 
180  virtual void SetZCoordinates(vtkDataArray*);
181  vtkGetObjectMacro(ZCoordinates,vtkDataArray);
183 
185 
190  void SetExtent(int extent[6]);
191  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
192  vtkGetVector6Macro(Extent, int);
194 
203  unsigned long GetActualMemorySize() override;
204 
206 
209  void ShallowCopy(vtkDataObject *src) override;
210  void DeepCopy(vtkDataObject *src) override;
212 
216  int GetExtentType() override { return VTK_3D_EXTENT; };
217 
223  void Crop(const int* updateExtent) override;
224 
226 
230  static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i=0);
232 
233 protected:
235  ~vtkRectilinearGrid() override;
236 
237  // for the GetCell method
242 
243  int Dimensions[3];
245 
246  int Extent[6];
247 
251 
252  // Hang on to some space for returning points when GetPoint(id) is called.
253  double PointReturn[3];
254 
255 private:
256  void Cleanup();
257 
258 private:
259  vtkRectilinearGrid(const vtkRectilinearGrid&) = delete;
260  void operator=(const vtkRectilinearGrid&) = delete;
261 };
262 
263 //----------------------------------------------------------------------------
265 {
266  vtkIdType nCells=1;
267  int i;
268 
269  for (i=0; i<3; i++)
270  {
271  if (this->Dimensions[i] <= 0)
272  {
273  return 0;
274  }
275  if (this->Dimensions[i] > 1)
276  {
277  nCells *= (this->Dimensions[i]-1);
278  }
279  }
280 
281  return nCells;
282 }
283 
284 //----------------------------------------------------------------------------
286 {
287  return static_cast<vtkIdType>(this->Dimensions[0]) *
288  this->Dimensions[1] * this->Dimensions[2];
289 }
290 
291 //----------------------------------------------------------------------------
293 {
295 }
296 
297 //----------------------------------------------------------------------------
299 {
301 }
302 
303 //----------------------------------------------------------------------------
305 {
307 }
308 
309 #endif
int GetDataDimension()
Return the dimensionality of the data.
vtkIdType FindPoint(double x, double y, double z)
Standard vtkDataSet API methods.
int GetDataObjectType() override
Return what type of dataset this is.
a dataset that is topologically regular with variable spacing in the three coordinate directions
virtual vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)
Locate the cell that contains a point and return the cell.
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
vtkIdType ComputeCellId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the cell id.
int GetMaxCellSize() override
Standard vtkDataSet API methods.
static vtkDataObject * New()
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
Locate cell based on global coordinate x and tolerance squared.
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:94
Store vtkAlgorithm input/output information.
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
a cell that represents a 3D point
Definition: vtkVertex.h:30
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:55
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:34
virtual void ComputeBounds()
Compute the data bounding box from data points.
int GetExtentType() override
Structured extent.
vtkDataArray * XCoordinates
static vtkIdType ComputePointId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the dimensions of the structured dataset,...
int vtkIdType
Definition: vtkType.h:345
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
static vtkDataSet * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
provides thread-safe access to cells
vtkIdType ComputePointId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the point id.
virtual void Crop(const int *updateExtent)
This method crops the data object (if necessary) so that the extent matches the update extent.
cell represents a 1D line
Definition: vtkLine.h:29
abstract class to specify cell behavior
Definition: vtkCell.h:56
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:38
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIdType GetNumberOfPoints() override
Standard vtkDataSet API methods.
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
Get the points defining a cell.
vtkDataArray * ZCoordinates
list of point or cell ids
Definition: vtkIdList.h:30
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
#define VTK_SIZEHINT(...)
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
Get the cells using a point.
static vtkIdType ComputeCellId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the dimensions of the structured dataset,...
void Initialize() override
Restore data object to initial state.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
vtkDataArray * YCoordinates
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
Store zero or more vtkInformation instances.
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
general representation of visualization data
Definition: vtkDataObject.h:58
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:191
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
represent and manipulate 3D points
Definition: vtkPoints.h:33
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the 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.
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.