VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
55 class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet
56 {
57 public:
58  static vtkRectilinearGrid *New();
59 
60  vtkTypeMacro(vtkRectilinearGrid,vtkDataSet);
61  void PrintSelf(ostream& os, vtkIndent indent);
62 
64  int GetDataObjectType() {return VTK_RECTILINEAR_GRID;};
65 
68  void CopyStructure(vtkDataSet *ds);
69 
71  void Initialize();
72 
74 
75  vtkIdType GetNumberOfCells();
76  vtkIdType GetNumberOfPoints();
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 
194  static vtkRectilinearGrid* GetData(vtkInformation* info);
195  static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i=0);
196  //ETX
198 
199 protected:
202 
203  // for the GetCell method
205  vtkLine *Line;
207  vtkVoxel *Voxel;
208 
209  int Dimensions[3];
211 
212  int Extent[6];
213 
214  vtkDataArray *XCoordinates;
215  vtkDataArray *YCoordinates;
216  vtkDataArray *ZCoordinates;
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 //----------------------------------------------------------------------------
263 inline vtkIdType vtkRectilinearGrid::ComputePointId(int ijk[3])
264 {
266 }
267 
268 //----------------------------------------------------------------------------
269 inline vtkIdType vtkRectilinearGrid::ComputeCellId(int ijk[3])
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 ...
vtkIdType ComputeCellId(int ijk[3])
static vtkIdType ComputePointId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
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
vtkDataArray * XCoordinates
provides thread-safe access to cells
vtkIdType ComputePointId(int ijk[3])
vtkIdType GetNumberOfPoints()
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
static vtkIdType ComputeCellId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
vtkIdType GetNumberOfCells()
vtkDataArray * ZCoordinates
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
vtkDataArray * YCoordinates
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
general representation of visualization data
Definition: vtkDataObject.h:64