Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Common/vtkRectilinearGrid.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkRectilinearGrid.h,v $
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 "vtkDataSet.h"
00045 #include "vtkStructuredData.h" // For inline methods
00046 
00047 class vtkVertex;
00048 class vtkLine;
00049 class vtkPixel;
00050 class vtkVoxel;
00051 class vtkDataArray;
00052 
00053 class VTK_COMMON_EXPORT vtkRectilinearGrid : public vtkDataSet
00054 {
00055 public:
00056   static vtkRectilinearGrid *New();
00057 
00058   vtkTypeRevisionMacro(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   int 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;}; //voxel is the largest
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 SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00155   void SetUpdateExtent(int piece, int numPieces)
00156     {this->SetUpdateExtent(piece, numPieces, 0);}
00158 
00160 
00161   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00162     { this->vtkDataSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00163   void SetUpdateExtent( int ext[6] )
00164     { this->vtkDataSet::SetUpdateExtent( ext ); };
00166 
00168 
00171   void SetExtent(int extent[6]);
00172   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00173   vtkGetVector6Macro(Extent,int);
00175 
00181   unsigned long GetActualMemorySize();
00182 
00184 
00185   void ShallowCopy(vtkDataObject *src);  
00186   void DeepCopy(vtkDataObject *src);
00188   
00194   virtual void UpdateData();
00195 
00197   int GetExtentType() { return VTK_3D_EXTENT; };
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   
00212   virtual void Crop();
00213 
00214   int Dimensions[3];
00215   int DataDescription;
00216 
00217   vtkDataArray *XCoordinates;
00218   vtkDataArray *YCoordinates;
00219   vtkDataArray *ZCoordinates;
00220 
00221   // Hang on to some space for returning points when GetPoint(id) is called.
00222   double PointReturn[3];
00223 
00224 private:
00226 
00227   void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00228     {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00230 private:
00231   vtkRectilinearGrid(const vtkRectilinearGrid&);  // Not implemented.
00232   void operator=(const vtkRectilinearGrid&);  // Not implemented.
00233 };
00234 
00235 
00236 
00237 
00238 inline vtkIdType vtkRectilinearGrid::GetNumberOfCells() 
00239 {
00240   vtkIdType nCells=1;
00241   int i;
00242 
00243   for (i=0; i<3; i++)
00244     {
00245     if (this->Dimensions[i] <= 0)
00246       {
00247       return 0;
00248       }
00249     if (this->Dimensions[i] > 1)
00250       {
00251       nCells *= (this->Dimensions[i]-1);
00252       }
00253     }
00254 
00255   return nCells;
00256 }
00257 
00258 inline vtkIdType vtkRectilinearGrid::GetNumberOfPoints()
00259 {
00260   return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
00261 }
00262 
00263 inline int vtkRectilinearGrid::GetDataDimension()
00264 {
00265   return vtkStructuredData::GetDataDimension(this->DataDescription);
00266 }
00267 
00268 inline vtkIdType vtkRectilinearGrid::ComputePointId(int ijk[3])
00269 {
00270   return vtkStructuredData::ComputePointId(this->Dimensions,ijk);
00271 }
00272 
00273 inline vtkIdType vtkRectilinearGrid::ComputeCellId(int ijk[3])
00274 {
00275   return vtkStructuredData::ComputeCellId(this->Dimensions,ijk);
00276 }
00277 
00278 #endif