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 =========================================================================*/
42 #ifndef vtkRectilinearGrid_h
43 #define vtkRectilinearGrid_h
44 
45 #include "vtkCommonDataModelModule.h" // For export macro
46 #include "vtkDataSet.h"
47 #include "vtkStructuredData.h" // For inline methods
48 
49 class vtkVertex;
50 class vtkLine;
51 class vtkPixel;
52 class vtkVoxel;
53 class vtkDataArray;
54 class vtkPoints;
55 
56 class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet
57 {
58 public:
59  static vtkRectilinearGrid *New();
60 
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
67  int GetDataObjectType() override {return VTK_RECTILINEAR_GRID;};
68 
73  void CopyStructure(vtkDataSet *ds) override;
74 
78  void Initialize() override;
79 
81 
84  vtkIdType GetNumberOfCells() override;
85  vtkIdType GetNumberOfPoints() override;
86  double *GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
87  void GetPoint(vtkIdType id, double x[3]) override;
88  vtkCell *GetCell(vtkIdType cellId) override;
89  vtkCell *GetCell(int i, int j, int k) override;
90  void GetCell(vtkIdType cellId, vtkGenericCell *cell) override;
91  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
92  vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);};
93  vtkIdType FindPoint(double x[3]) override;
94  vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
95  int& subId, double pcoords[3], double *weights) override;
96  vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell,
97  vtkIdType cellId, double tol2, int& subId,
98  double pcoords[3], double *weights) override;
99  vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
100  double tol2, int& subId, double pcoords[3],
101  double *weights) override;
102  int GetCellType(vtkIdType cellId) override;
103  void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
104  {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
105  this->Dimensions);}
106  void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
107  {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
108  void ComputeBounds() override;
109  int GetMaxCellSize() override {return 8;}; //voxel is the largest
110  void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
111  vtkIdList *cellIds) override;
113 
118  void GetPoints(vtkPoints* pnts);
119 
121 
125  void SetDimensions(int i, int j, int k);
126  void SetDimensions(const int dim[3]);
128 
130 
133  vtkGetVectorMacro(Dimensions,int,3);
135 
139  int GetDataDimension();
140 
147  int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
148 
152  vtkIdType ComputePointId(int ijk[3]);
153 
157  vtkIdType ComputeCellId(int ijk[3]);
158 
164  void GetPoint(const int i,const int j,const int k,double p[3]);
165 
167 
170  virtual void SetXCoordinates(vtkDataArray*);
171  vtkGetObjectMacro(XCoordinates,vtkDataArray);
173 
175 
178  virtual void SetYCoordinates(vtkDataArray*);
179  vtkGetObjectMacro(YCoordinates,vtkDataArray);
181 
183 
186  virtual void SetZCoordinates(vtkDataArray*);
187  vtkGetObjectMacro(ZCoordinates,vtkDataArray);
189 
191 
196  void SetExtent(int extent[6]);
197  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
198  vtkGetVector6Macro(Extent, int);
200 
209  unsigned long GetActualMemorySize() override;
210 
212 
215  void ShallowCopy(vtkDataObject *src) override;
216  void DeepCopy(vtkDataObject *src) override;
218 
222  int GetExtentType() override { return VTK_3D_EXTENT; };
223 
229  void Crop(const int* updateExtent) override;
230 
232 
236  static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i=0);
238 
239 protected:
241  ~vtkRectilinearGrid() override;
242 
243  // for the GetCell method
248 
249  int Dimensions[3];
251 
252  int Extent[6];
253 
257 
258  // Hang on to some space for returning points when GetPoint(id) is called.
259  double PointReturn[3];
260 
261 private:
262  void Cleanup();
263 
264 private:
265  vtkRectilinearGrid(const vtkRectilinearGrid&) = delete;
266  void operator=(const vtkRectilinearGrid&) = delete;
267 };
268 
269 //----------------------------------------------------------------------------
271 {
272  vtkIdType nCells=1;
273  int i;
274 
275  for (i=0; i<3; i++)
276  {
277  if (this->Dimensions[i] <= 0)
278  {
279  return 0;
280  }
281  if (this->Dimensions[i] > 1)
282  {
283  nCells *= (this->Dimensions[i]-1);
284  }
285  }
286 
287  return nCells;
288 }
289 
290 //----------------------------------------------------------------------------
292 {
293  return static_cast<vtkIdType>(this->Dimensions[0]) *
294  this->Dimensions[1] * this->Dimensions[2];
295 }
296 
297 //----------------------------------------------------------------------------
299 {
301 }
302 
303 //----------------------------------------------------------------------------
305 {
307 }
308 
309 //----------------------------------------------------------------------------
311 {
313 }
314 
315 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkDataSet::GetNumberOfPoints
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
vtkDataSet::GetActualMemorySize
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkStructuredData::GetDataDimension
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
vtkRectilinearGrid::GetExtentType
int GetExtentType() override
Structured extent.
Definition: vtkRectilinearGrid.h:222
vtkRectilinearGrid::Voxel
vtkVoxel * Voxel
Definition: vtkRectilinearGrid.h:247
vtkDataSet::ShallowCopy
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkRectilinearGrid::Vertex
vtkVertex * Vertex
Definition: vtkRectilinearGrid.h:244
vtkRectilinearGrid
a dataset that is topologically regular with variable spacing in the three coordinate directions
Definition: vtkRectilinearGrid.h:56
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkDataSet::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRectilinearGrid::Pixel
vtkPixel * Pixel
Definition: vtkRectilinearGrid.h:246
vtkDataSet::GetData
static vtkDataSet * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkRectilinearGrid::GetPointCells
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Topological inquiry to get cells using point.
Definition: vtkRectilinearGrid.h:106
vtkRectilinearGrid::GetNumberOfPoints
vtkIdType GetNumberOfPoints() override
Determine the number of points composing the dataset.
Definition: vtkRectilinearGrid.h:291
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkRectilinearGrid::GetNumberOfCells
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
Definition: vtkRectilinearGrid.h:270
vtkRectilinearGrid::YCoordinates
vtkDataArray * YCoordinates
Definition: vtkRectilinearGrid.h:255
vtkVertex
a cell that represents a 3D point
Definition: vtkVertex.h:36
vtkDataSet::FindCell
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.
vtkLine
cell represents a 1D line
Definition: vtkLine.h:35
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:61
vtkDataSet::ComputeBounds
virtual void ComputeBounds()
Compute the data bounding box from data points.
vtkStructuredData.h
vtkStructuredData::ComputePointId
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,...
Definition: vtkStructuredData.h:295
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkStructuredData::GetCellPoints
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
Get the points defining a cell.
vtkDataSet::FindPoint
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:197
vtkDataSet::GetCellNeighbors
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:59
vtkRectilinearGrid::GetCellPoints
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Topological inquiry to get points defining cell.
Definition: vtkRectilinearGrid.h:103
vtkRectilinearGrid::GetDataDimension
int GetDataDimension()
Return the dimensionality of the data.
Definition: vtkRectilinearGrid.h:298
vtkRectilinearGrid::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkRectilinearGrid.h:67
vtkStructuredData::GetPointCells
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
Get the cells using a point.
vtkRectilinearGrid::GetMaxCellSize
int GetMaxCellSize() override
Convenience method returns largest cell size in dataset.
Definition: vtkRectilinearGrid.h:109
vtkRectilinearGrid::FindPoint
vtkIdType FindPoint(double x, double y, double z)
Definition: vtkRectilinearGrid.h:92
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkRectilinearGrid::Line
vtkLine * Line
Definition: vtkRectilinearGrid.h:245
vtkDataSet::Initialize
void Initialize() override
Restore data object to initial state.
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkRectilinearGrid::ComputePointId
vtkIdType ComputePointId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the point id.
Definition: vtkRectilinearGrid.h:304
vtkRectilinearGrid::ComputeCellId
vtkIdType ComputeCellId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the cell id.
Definition: vtkRectilinearGrid.h:310
vtkRectilinearGrid::Dimensions
int Dimensions[3]
Definition: vtkRectilinearGrid.h:249
vtkDataObject::Crop
virtual void Crop(const int *updateExtent)
This method crops the data object (if necessary) so that the extent matches the update extent.
vtkStructuredData::ComputeCellId
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,...
Definition: vtkStructuredData.h:302
vtkDataSet.h
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkRectilinearGrid::XCoordinates
vtkDataArray * XCoordinates
Definition: vtkRectilinearGrid.h:254
vtkX3D::info
Definition: vtkX3D.h:376
vtkDataSet::GetPoint
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
vtkPixel
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:40
vtkDataSet::CopyStructure
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:39
vtkX3D::extent
Definition: vtkX3D.h:345
vtkDataSet::GetNumberOfCells
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkDataSet::GetCellType
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkDataSet::GetCellBounds
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkRectilinearGrid::ZCoordinates
vtkDataArray * ZCoordinates
Definition: vtkRectilinearGrid.h:256
vtkDataSet::FindAndGetCell
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.
VTK_RECTILINEAR_GRID
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:94
vtkRectilinearGrid::DataDescription
int DataDescription
Definition: vtkRectilinearGrid.h:250
vtkDataSet::DeepCopy
void DeepCopy(vtkDataObject *src) override
vtkDataObject::New
static vtkDataObject * New()
vtkDataSet::GetCell
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkVoxel
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:44