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 "vtkDataSet.h"
45 #include "vtkStructuredData.h" // For inline methods
46 
47 class vtkVertex;
48 class vtkLine;
49 class vtkPixel;
50 class vtkVoxel;
51 class vtkDataArray;
52 
54 {
55 public:
56  static vtkRectilinearGrid *New();
57 
59  void PrintSelf(ostream& os, vtkIndent indent);
60 
63 
66  void CopyStructure(vtkDataSet *ds);
67 
69  void Initialize();
70 
72 
75  double *GetPoint(vtkIdType ptId);
76  void GetPoint(vtkIdType id, double x[3]);
77  vtkCell *GetCell(vtkIdType cellId);
78  void GetCell(vtkIdType cellId, vtkGenericCell *cell);
79  void GetCellBounds(vtkIdType cellId, double bounds[6]);
80  vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);};
81  vtkIdType FindPoint(double x[3]);
82  vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
83  int& subId, double pcoords[3], double *weights);
84  vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell,
85  vtkIdType cellId, double tol2, int& subId,
86  double pcoords[3], double *weights);
87  vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
88  double tol2, int& subId, double pcoords[3],
89  double *weights);
90  int GetCellType(vtkIdType cellId);
91  void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
92  {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
93  this->Dimensions);}
94  void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
95  {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
96  void ComputeBounds();
97  int GetMaxCellSize() {return 8;}; //voxel is the largest
98  void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
99  vtkIdList *cellIds);
101 
103 
105  void SetDimensions(int i, int j, int k);
106  void SetDimensions(int dim[3]);
108 
110 
111  vtkGetVectorMacro(Dimensions,int,3);
113 
115  int GetDataDimension();
116 
122  int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
123 
126  vtkIdType ComputePointId(int ijk[3]);
127 
130  vtkIdType ComputeCellId(int ijk[3]);
131 
133 
134  virtual void SetXCoordinates(vtkDataArray*);
135  vtkGetObjectMacro(XCoordinates,vtkDataArray);
137 
139 
140  virtual void SetYCoordinates(vtkDataArray*);
141  vtkGetObjectMacro(YCoordinates,vtkDataArray);
143 
145 
146  virtual void SetZCoordinates(vtkDataArray*);
147  vtkGetObjectMacro(ZCoordinates,vtkDataArray);
149 
151 
154  void SetExtent(int extent[6]);
155  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
156  vtkGetVector6Macro(Extent, int);
158 
164  unsigned long GetActualMemorySize();
165 
167 
168  void ShallowCopy(vtkDataObject *src);
169  void DeepCopy(vtkDataObject *src);
171 
173  int GetExtentType() { return VTK_3D_EXTENT; };
174 
178  virtual void Crop();
179 
180  //BTX
182 
184  static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i=0);
185  //ETX
187 
188 protected:
191 
192  // for the GetCell method
195  vtkPixel *Pixel;
197 
198  int Dimensions[3];
200 
201  int Extent[6];
202 
206 
207  // Hang on to some space for returning points when GetPoint(id) is called.
208  double PointReturn[3];
209 
210 private:
211  void Cleanup();
212 
214 
215  VTK_LEGACY(void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds));
216 private:
217  vtkRectilinearGrid(const vtkRectilinearGrid&); // Not implemented.
218  void operator=(const vtkRectilinearGrid&); // Not implemented.
219 };
221 
222 //----------------------------------------------------------------------------
224 {
225  vtkIdType nCells=1;
226  int i;
227 
228  for (i=0; i<3; i++)
229  {
230  if (this->Dimensions[i] <= 0)
231  {
232  return 0;
233  }
234  if (this->Dimensions[i] > 1)
235  {
236  nCells *= (this->Dimensions[i]-1);
237  }
238  }
239 
240  return nCells;
241 }
242 
243 //----------------------------------------------------------------------------
245 {
246  return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
247 }
248 
249 //----------------------------------------------------------------------------
251 {
253 }
254 
255 //----------------------------------------------------------------------------
257 {
259 }
260 
261 //----------------------------------------------------------------------------
263 {
265 }
266 
267 //----------------------------------------------------------------------------
268 #ifndef VTK_LEGACY_REMOVE
270  vtkIdList& ptIds, vtkIdList& cellIds)
271 {
272  this->GetCellNeighbors(cellId, &ptIds, &cellIds);
273 }
274 #endif
275 
276 #endif
static vtkIdType ComputeCellId(int dim[3], int ijk[3])
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()
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.
#define VTK_FILTERING_EXPORT
virtual vtkIdType GetNumberOfPoints()=0
abstract class to specify dataset behavior
Definition: vtkDataSet.h:58
a cell that represents a 3D point
Definition: vtkVertex.h:34
static int GetDataDimension(int dataDescription)
virtual void ComputeBounds()
vtkDataArray * XCoordinates
int vtkIdType
Definition: vtkType.h:255
static vtkDataSet * GetData(vtkInformation *info)
provides thread-safe access to cells
vtkIdType ComputePointId(int ijk[3])
vtkIdType GetNumberOfPoints()
cell represents a 1D line
Definition: vtkLine.h:33
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
void PrintSelf(ostream &os, vtkIndent indent)
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:42
a simple class to control print indentation
Definition: vtkIndent.h:37
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:34
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
void DeepCopy(vtkDataObject *src)
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
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
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
helper class to get VTK data object types as string and instantiate them
vtkIdType FindPoint(double x, double y, double z)
Definition: vtkDataSet.h:148
static vtkIdType ComputePointId(int dim[3], int ijk[3])
virtual vtkCell * GetCell(vtkIdType cellId)=0
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
virtual int GetCellType(vtkIdType cellId)=0
void ShallowCopy(vtkDataObject *src)