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 =========================================================================*/
41 #ifndef vtkRectilinearGrid_h
42 #define vtkRectilinearGrid_h
43 
44 #include "vtkCommonDataModelModule.h" // For export macro
45 #include "vtkDataSet.h"
46 #include "vtkStructuredData.h" // For inline methods
47 
48 class vtkVertex;
49 class vtkLine;
50 class vtkPixel;
51 class vtkVoxel;
52 class vtkDataArray;
53 class vtkPoints;
54 
56 {
57 public:
58  static vtkRectilinearGrid *New();
59 
61  void PrintSelf(ostream& os, vtkIndent indent);
62 
65 
68  void CopyStructure(vtkDataSet *ds);
69 
71  void Initialize();
72 
74 
77  double *GetPoint(vtkIdType ptId);
78  void GetPoint(vtkIdType id, double x[3]);
79  vtkCell *GetCell(vtkIdType cellId);
80  void GetCell(vtkIdType cellId, vtkGenericCell *cell);
81  void GetCellBounds(vtkIdType cellId, double bounds[6]);
82  vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);};
83  vtkIdType FindPoint(double x[3]);
84  vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
85  int& subId, double pcoords[3], double *weights);
86  vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell,
87  vtkIdType cellId, double tol2, int& subId,
88  double pcoords[3], double *weights);
89  vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
90  double tol2, int& subId, double pcoords[3],
91  double *weights);
92  int GetCellType(vtkIdType cellId);
93  void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
94  {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
95  this->Dimensions);}
96  void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
97  {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
98  void ComputeBounds();
99  int GetMaxCellSize() {return 8;}; //voxel is the largest
100  void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
101  vtkIdList *cellIds);
103 
106  void GetPoints(vtkPoints* pnts);
107 
109 
111  void SetDimensions(int i, int j, int k);
112  void SetDimensions(int dim[3]);
114 
116 
117  vtkGetVectorMacro(Dimensions,int,3);
119 
121  int GetDataDimension();
122 
128  int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
129 
132  vtkIdType ComputePointId(int ijk[3]);
133 
136  vtkIdType ComputeCellId(int ijk[3]);
137 
141  void GetPoint(const int i,const int j,const int k,double p[3]);
142 
144 
145  virtual void SetXCoordinates(vtkDataArray*);
146  vtkGetObjectMacro(XCoordinates,vtkDataArray);
148 
150 
151  virtual void SetYCoordinates(vtkDataArray*);
152  vtkGetObjectMacro(YCoordinates,vtkDataArray);
154 
156 
157  virtual void SetZCoordinates(vtkDataArray*);
158  vtkGetObjectMacro(ZCoordinates,vtkDataArray);
160 
162 
165  void SetExtent(int extent[6]);
166  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
167  vtkGetVector6Macro(Extent, int);
169 
175  unsigned long GetActualMemorySize();
176 
178 
179  void ShallowCopy(vtkDataObject *src);
180  void DeepCopy(vtkDataObject *src);
182 
184  int GetExtentType() { return VTK_3D_EXTENT; };
185 
189  virtual void Crop(const int* updateExtent);
190 
191  //BTX
193 
195  static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i=0);
196  //ETX
198 
199 protected:
202 
203  // for the GetCell method
208 
209  int Dimensions[3];
211 
212  int Extent[6];
213 
217 
218  // Hang on to some space for returning points when GetPoint(id) is called.
219  double PointReturn[3];
220 
221 private:
222  void Cleanup();
223 
224 private:
225  vtkRectilinearGrid(const vtkRectilinearGrid&); // Not implemented.
226  void operator=(const vtkRectilinearGrid&); // Not implemented.
227 };
228 
229 //----------------------------------------------------------------------------
231 {
232  vtkIdType nCells=1;
233  int i;
234 
235  for (i=0; i<3; i++)
236  {
237  if (this->Dimensions[i] <= 0)
238  {
239  return 0;
240  }
241  if (this->Dimensions[i] > 1)
242  {
243  nCells *= (this->Dimensions[i]-1);
244  }
245  }
246 
247  return nCells;
248 }
249 
250 //----------------------------------------------------------------------------
252 {
253  return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
254 }
255 
256 //----------------------------------------------------------------------------
258 {
260 }
261 
262 //----------------------------------------------------------------------------
264 {
266 }
267 
268 //----------------------------------------------------------------------------
270 {
272 }
273 
274 #endif
vtkIdType FindPoint(double x, double y, double z)
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)
virtual vtkIdType GetNumberOfCells()=0
vtkIdType ComputeCellId(int ijk[3])
unsigned long GetActualMemorySize()
static vtkDataObject * New()
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:69
Store vtkAlgorithm input/output information.
virtual vtkIdType GetNumberOfPoints()=0
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
a cell that represents a 3D point
Definition: vtkVertex.h:35
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:61
static int GetDataDimension(int dataDescription)
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:39
virtual void ComputeBounds()
vtkDataArray * XCoordinates
static vtkIdType ComputePointId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
int vtkIdType
Definition: vtkType.h:275
static vtkDataSet * GetData(vtkInformation *info)
provides thread-safe access to cells
vtkIdType ComputePointId(int ijk[3])
virtual void Crop(const int *updateExtent)
vtkIdType GetNumberOfPoints()
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:61
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
void PrintSelf(ostream &os, vtkIndent indent)
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:43
a simple class to control print indentation
Definition: vtkIndent.h:38
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
vtkIdType GetNumberOfCells()
vtkDataArray * ZCoordinates
list of point or cell ids
Definition: vtkIdList.h:35
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
void DeepCopy(vtkDataObject *src)
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
static vtkIdType ComputeCellId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
vtkDataArray * YCoordinates
void Initialize()
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
virtual void CopyStructure(vtkDataSet *ds)=0
Store zero or more vtkInformation instances.
virtual double * GetPoint(vtkIdType ptId)=0
general representation of visualization data
Definition: vtkDataObject.h:64
vtkIdType FindPoint(double x, double y, double z)
Definition: vtkDataSet.h:154
#define VTKCOMMONDATAMODEL_EXPORT
virtual vtkCell * GetCell(vtkIdType cellId)=0
represent and manipulate 3D points
Definition: vtkPoints.h:38
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
virtual int GetCellType(vtkIdType cellId)=0
void ShallowCopy(vtkDataObject *src)