00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00041 #ifndef __vtkRectilinearGrid_h
00042 #define __vtkRectilinearGrid_h
00043 
00044 #include "vtkDataSet.h"
00045 #include "vtkStructuredData.h" 
00046 
00047 class vtkVertex;
00048 class vtkLine;
00049 class vtkPixel;
00050 class vtkVoxel;
00051 class vtkDataArray;
00052 
00053 class VTK_FILTERING_EXPORT vtkRectilinearGrid : public vtkDataSet
00054 {
00055 public:
00056   static vtkRectilinearGrid *New();
00057 
00058   vtkTypeMacro(vtkRectilinearGrid,vtkDataSet);
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00062   int GetDataObjectType() {return VTK_RECTILINEAR_GRID;};
00063 
00066   void CopyStructure(vtkDataSet *ds);
00067 
00069   void Initialize();
00070 
00072 
00073   vtkIdType GetNumberOfCells();
00074   vtkIdType GetNumberOfPoints();
00075   double *GetPoint(vtkIdType ptId);
00076   void GetPoint(vtkIdType id, double x[3]);
00077   vtkCell *GetCell(vtkIdType cellId);
00078   void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00079   void GetCellBounds(vtkIdType cellId, double bounds[6]);
00080   vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);};
00081   vtkIdType FindPoint(double x[3]);
00082   vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
00083                      int& subId, double pcoords[3], double *weights);
00084   vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell,
00085                      vtkIdType cellId, double tol2, int& subId, 
00086                      double pcoords[3], double *weights);
00087   vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, 
00088                           double tol2, int& subId, double pcoords[3],
00089                           double *weights);
00090   int GetCellType(vtkIdType cellId);
00091   void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
00092     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
00093                                       this->Dimensions);}
00094   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
00095     {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
00096   void ComputeBounds();
00097   int GetMaxCellSize() {return 8;}; 
00098   void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00099                         vtkIdList *cellIds);
00101 
00103 
00105   void SetDimensions(int i, int j, int k);
00106   void SetDimensions(int dim[3]);
00108 
00110 
00111   vtkGetVectorMacro(Dimensions,int,3);
00113 
00115   int GetDataDimension();
00116 
00122   int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
00123 
00126   vtkIdType ComputePointId(int ijk[3]);
00127 
00130   vtkIdType ComputeCellId(int ijk[3]);
00131 
00133 
00134   virtual void SetXCoordinates(vtkDataArray*);
00135   vtkGetObjectMacro(XCoordinates,vtkDataArray);
00137 
00139 
00140   virtual void SetYCoordinates(vtkDataArray*);
00141   vtkGetObjectMacro(YCoordinates,vtkDataArray);
00143 
00145 
00146   virtual void SetZCoordinates(vtkDataArray*);
00147   vtkGetObjectMacro(ZCoordinates,vtkDataArray);
00149 
00151 
00154   void SetExtent(int extent[6]);
00155   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00156   vtkGetVector6Macro(Extent, int);
00158 
00164   unsigned long GetActualMemorySize();
00165 
00167 
00168   void ShallowCopy(vtkDataObject *src);  
00169   void DeepCopy(vtkDataObject *src);
00171 
00173   int GetExtentType() { return VTK_3D_EXTENT; };
00174 
00178   virtual void Crop();
00179 
00180   
00182 
00183   static vtkRectilinearGrid* GetData(vtkInformation* info);
00184   static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i=0);
00185   
00187 
00188 protected:
00189   vtkRectilinearGrid();
00190   ~vtkRectilinearGrid();
00191 
00192   
00193   vtkVertex *Vertex;
00194   vtkLine *Line;
00195   vtkPixel *Pixel;
00196   vtkVoxel *Voxel;
00197   
00198   int Dimensions[3];
00199   int DataDescription;
00200 
00201   int Extent[6];
00202 
00203   vtkDataArray *XCoordinates;
00204   vtkDataArray *YCoordinates;
00205   vtkDataArray *ZCoordinates;
00206 
00207   
00208   double PointReturn[3];
00209 
00210 private:
00211   void Cleanup();
00212 
00214 
00215   VTK_LEGACY(void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds));
00216 private:
00217   vtkRectilinearGrid(const vtkRectilinearGrid&);  
00218   void operator=(const vtkRectilinearGrid&);  
00219 };
00221 
00222 
00223 inline vtkIdType vtkRectilinearGrid::GetNumberOfCells() 
00224 {
00225   vtkIdType nCells=1;
00226   int i;
00227 
00228   for (i=0; i<3; i++)
00229     {
00230     if (this->Dimensions[i] <= 0)
00231       {
00232       return 0;
00233       }
00234     if (this->Dimensions[i] > 1)
00235       {
00236       nCells *= (this->Dimensions[i]-1);
00237       }
00238     }
00239 
00240   return nCells;
00241 }
00242 
00243 
00244 inline vtkIdType vtkRectilinearGrid::GetNumberOfPoints()
00245 {
00246   return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
00247 }
00248 
00249 
00250 inline int vtkRectilinearGrid::GetDataDimension()
00251 {
00252   return vtkStructuredData::GetDataDimension(this->DataDescription);
00253 }
00254 
00255 
00256 inline vtkIdType vtkRectilinearGrid::ComputePointId(int ijk[3])
00257 {
00258   return vtkStructuredData::ComputePointId(this->Dimensions,ijk);
00259 }
00260 
00261 
00262 inline vtkIdType vtkRectilinearGrid::ComputeCellId(int ijk[3])
00263 {
00264   return vtkStructuredData::ComputeCellId(this->Dimensions,ijk);
00265 }
00266 
00267 
00268 #ifndef VTK_LEGACY_REMOVE
00269 inline void vtkRectilinearGrid::GetCellNeighbors(vtkIdType cellId, 
00270   vtkIdList& ptIds, vtkIdList& cellIds)
00271 {
00272   this->GetCellNeighbors(cellId, &ptIds, &cellIds);
00273 }
00274 #endif
00275 
00276 #endif