VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkRectilinearGrid.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00041 #ifndef __vtkRectilinearGrid_h 00042 #define __vtkRectilinearGrid_h 00043 00044 #include "vtkCommonDataModelModule.h" // For export macro 00045 #include "vtkDataSet.h" 00046 #include "vtkStructuredData.h" // For inline methods 00047 00048 class vtkVertex; 00049 class vtkLine; 00050 class vtkPixel; 00051 class vtkVoxel; 00052 class vtkDataArray; 00053 class vtkPoints; 00054 00055 class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet 00056 { 00057 public: 00058 static vtkRectilinearGrid *New(); 00059 00060 vtkTypeMacro(vtkRectilinearGrid,vtkDataSet); 00061 void PrintSelf(ostream& os, vtkIndent indent); 00062 00064 int GetDataObjectType() {return VTK_RECTILINEAR_GRID;}; 00065 00068 void CopyStructure(vtkDataSet *ds); 00069 00071 void Initialize(); 00072 00074 00075 vtkIdType GetNumberOfCells(); 00076 vtkIdType GetNumberOfPoints(); 00077 double *GetPoint(vtkIdType ptId); 00078 void GetPoint(vtkIdType id, double x[3]); 00079 vtkCell *GetCell(vtkIdType cellId); 00080 void GetCell(vtkIdType cellId, vtkGenericCell *cell); 00081 void GetCellBounds(vtkIdType cellId, double bounds[6]); 00082 vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);}; 00083 vtkIdType FindPoint(double x[3]); 00084 vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, 00085 int& subId, double pcoords[3], double *weights); 00086 vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, 00087 vtkIdType cellId, double tol2, int& subId, 00088 double pcoords[3], double *weights); 00089 vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, 00090 double tol2, int& subId, double pcoords[3], 00091 double *weights); 00092 int GetCellType(vtkIdType cellId); 00093 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) 00094 {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription, 00095 this->Dimensions);} 00096 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) 00097 {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);} 00098 void ComputeBounds(); 00099 int GetMaxCellSize() {return 8;}; //voxel is the largest 00100 void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, 00101 vtkIdList *cellIds); 00103 00106 void GetPoints(vtkPoints* pnts); 00107 00109 00111 void SetDimensions(int i, int j, int k); 00112 void SetDimensions(int dim[3]); 00114 00116 00117 vtkGetVectorMacro(Dimensions,int,3); 00119 00121 int GetDataDimension(); 00122 00128 int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]); 00129 00132 vtkIdType ComputePointId(int ijk[3]); 00133 00136 vtkIdType ComputeCellId(int ijk[3]); 00137 00141 void GetPoint(const int i,const int j,const int k,double p[3]); 00142 00144 00145 virtual void SetXCoordinates(vtkDataArray*); 00146 vtkGetObjectMacro(XCoordinates,vtkDataArray); 00148 00150 00151 virtual void SetYCoordinates(vtkDataArray*); 00152 vtkGetObjectMacro(YCoordinates,vtkDataArray); 00154 00156 00157 virtual void SetZCoordinates(vtkDataArray*); 00158 vtkGetObjectMacro(ZCoordinates,vtkDataArray); 00160 00162 00165 void SetExtent(int extent[6]); 00166 void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2); 00167 vtkGetVector6Macro(Extent, int); 00169 00175 unsigned long GetActualMemorySize(); 00176 00178 00179 void ShallowCopy(vtkDataObject *src); 00180 void DeepCopy(vtkDataObject *src); 00182 00184 int GetExtentType() { return VTK_3D_EXTENT; }; 00185 00189 virtual void Crop(const int* updateExtent); 00190 00191 //BTX 00193 00194 static vtkRectilinearGrid* GetData(vtkInformation* info); 00195 static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i=0); 00196 //ETX 00198 00199 protected: 00200 vtkRectilinearGrid(); 00201 ~vtkRectilinearGrid(); 00202 00203 // for the GetCell method 00204 vtkVertex *Vertex; 00205 vtkLine *Line; 00206 vtkPixel *Pixel; 00207 vtkVoxel *Voxel; 00208 00209 int Dimensions[3]; 00210 int DataDescription; 00211 00212 int Extent[6]; 00213 00214 vtkDataArray *XCoordinates; 00215 vtkDataArray *YCoordinates; 00216 vtkDataArray *ZCoordinates; 00217 00218 // Hang on to some space for returning points when GetPoint(id) is called. 00219 double PointReturn[3]; 00220 00221 private: 00222 void Cleanup(); 00223 00224 private: 00225 vtkRectilinearGrid(const vtkRectilinearGrid&); // Not implemented. 00226 void operator=(const vtkRectilinearGrid&); // Not implemented. 00227 }; 00228 00229 //---------------------------------------------------------------------------- 00230 inline vtkIdType vtkRectilinearGrid::GetNumberOfCells() 00231 { 00232 vtkIdType nCells=1; 00233 int i; 00234 00235 for (i=0; i<3; i++) 00236 { 00237 if (this->Dimensions[i] <= 0) 00238 { 00239 return 0; 00240 } 00241 if (this->Dimensions[i] > 1) 00242 { 00243 nCells *= (this->Dimensions[i]-1); 00244 } 00245 } 00246 00247 return nCells; 00248 } 00249 00250 //---------------------------------------------------------------------------- 00251 inline vtkIdType vtkRectilinearGrid::GetNumberOfPoints() 00252 { 00253 return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2]; 00254 } 00255 00256 //---------------------------------------------------------------------------- 00257 inline int vtkRectilinearGrid::GetDataDimension() 00258 { 00259 return vtkStructuredData::GetDataDimension(this->DataDescription); 00260 } 00261 00262 //---------------------------------------------------------------------------- 00263 inline vtkIdType vtkRectilinearGrid::ComputePointId(int ijk[3]) 00264 { 00265 return vtkStructuredData::ComputePointId(this->Dimensions,ijk); 00266 } 00267 00268 //---------------------------------------------------------------------------- 00269 inline vtkIdType vtkRectilinearGrid::ComputeCellId(int ijk[3]) 00270 { 00271 return vtkStructuredData::ComputeCellId(this->Dimensions,ijk); 00272 } 00273 00274 #endif