Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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   Language:  C++
00006 
00007 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00069 #ifndef __vtkRectilinearGrid_h
00070 #define __vtkRectilinearGrid_h
00071 
00072 #include "vtkDataSet.h"
00073 #include "vtkStructuredData.h"
00074 class vtkVertex;
00075 class vtkLine;
00076 class vtkPixel;
00077 class vtkVoxel;
00078 class vtkDataArray;
00079 
00080 class VTK_COMMON_EXPORT vtkRectilinearGrid : public vtkDataSet
00081 {
00082 public:
00083   static vtkRectilinearGrid *New();
00084 
00085   vtkTypeMacro(vtkRectilinearGrid,vtkDataSet);
00086   void PrintSelf(ostream& os, vtkIndent indent);
00087 
00089   vtkDataObject *MakeObject() {return vtkRectilinearGrid::New();};
00090 
00092   int GetDataObjectType() {return VTK_RECTILINEAR_GRID;};
00093 
00096   void CopyStructure(vtkDataSet *ds);
00097 
00099   void Initialize();
00100 
00102 
00103   vtkIdType GetNumberOfCells();
00104   vtkIdType GetNumberOfPoints();
00105   float *GetPoint(vtkIdType ptId);
00106   void GetPoint(vtkIdType id, float x[3]);
00107   vtkCell *GetCell(vtkIdType cellId);
00108   void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00109   void GetCellBounds(vtkIdType cellId, float bounds[6]);
00110   int FindPoint(float x, float y, float z) { return this->vtkDataSet::FindPoint(x, y, z);};
00111   vtkIdType FindPoint(float x[3]);
00112   vtkIdType FindCell(float x[3], vtkCell *cell, vtkIdType cellId, float tol2,
00113                      int& subId, float pcoords[3], float *weights);
00114   vtkIdType FindCell(float x[3], vtkCell *cell, vtkGenericCell *gencell,
00115                      vtkIdType cellId, float tol2, int& subId, 
00116                      float pcoords[3], float *weights);
00117   vtkCell *FindAndGetCell(float x[3], vtkCell *cell, vtkIdType cellId, 
00118                           float tol2, int& subId, float pcoords[3],
00119                           float *weights);
00120   int GetCellType(vtkIdType cellId);
00121   void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
00122     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
00123                                       this->Dimensions);}
00124   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
00125     {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
00126   void ComputeBounds();
00127   int GetMaxCellSize() {return 8;}; //voxel is the largest
00128   void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00129                         vtkIdList *cellIds);
00131 
00133 
00135   void SetDimensions(int i, int j, int k);
00136   void SetDimensions(int dim[3]);
00138 
00140 
00141   vtkGetVectorMacro(Dimensions,int,3);
00143 
00145   int GetDataDimension();
00146 
00152   int ComputeStructuredCoordinates(float x[3], int ijk[3], float pcoords[3]);
00153 
00156   vtkIdType ComputePointId(int ijk[3]);
00157 
00160   vtkIdType ComputeCellId(int ijk[3]);
00161 
00163 
00164   vtkSetObjectMacro(XCoordinates,vtkDataArray);
00165   vtkGetObjectMacro(XCoordinates,vtkDataArray);
00167 
00169 
00170   vtkSetObjectMacro(YCoordinates,vtkDataArray);
00171   vtkGetObjectMacro(YCoordinates,vtkDataArray);
00173 
00175 
00176   vtkSetObjectMacro(ZCoordinates,vtkDataArray);
00177   vtkGetObjectMacro(ZCoordinates,vtkDataArray);
00179 
00181 
00184   void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00185   void SetUpdateExtent(int piece, int numPieces)
00186     {this->SetUpdateExtent(piece, numPieces, 0);}
00188 
00190 
00191   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00192     { this->vtkDataSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00193   void SetUpdateExtent( int ext[6] )
00194     { this->vtkDataSet::SetUpdateExtent( ext ); };
00196 
00198 
00201   void SetExtent(int extent[6]);
00202   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00203   vtkGetVector6Macro(Extent,int);
00205 
00211   unsigned long GetActualMemorySize();
00212 
00214 
00215   void ShallowCopy(vtkDataObject *src);  
00216   void DeepCopy(vtkDataObject *src);
00218   
00219 protected:
00220   vtkRectilinearGrid();
00221   ~vtkRectilinearGrid();
00222 
00223   // for the GetCell method
00224   vtkVertex *Vertex;
00225   vtkLine *Line;
00226   vtkPixel *Pixel;
00227   vtkVoxel *Voxel;
00228   
00229   // The extent type is a 3D extent
00230   int GetExtentType() { return VTK_3D_EXTENT; };
00231 
00235   virtual void Crop();
00236 
00237   int Dimensions[3];
00238   int DataDescription;
00239 
00240   vtkDataArray *XCoordinates;
00241   vtkDataArray *YCoordinates;
00242   vtkDataArray *ZCoordinates;
00243 
00244   // Hang on to some space for returning points when GetPoint(id) is called.
00245   float PointReturn[3];
00246 
00247 private:
00249 
00250   void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00251     {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00253 private:
00254   vtkRectilinearGrid(const vtkRectilinearGrid&);  // Not implemented.
00255   void operator=(const vtkRectilinearGrid&);  // Not implemented.
00256 };
00257 
00258 
00259 
00260 
00261 inline vtkIdType vtkRectilinearGrid::GetNumberOfCells() 
00262 {
00263   vtkIdType nCells=1;
00264   int i;
00265 
00266   for (i=0; i<3; i++)
00267     {
00268     if (this->Dimensions[i] <= 0)
00269       {
00270       return 0;
00271       }
00272     if (this->Dimensions[i] > 1)
00273       {
00274       nCells *= (this->Dimensions[i]-1);
00275       }
00276     }
00277 
00278   return nCells;
00279 }
00280 
00281 inline vtkIdType vtkRectilinearGrid::GetNumberOfPoints()
00282 {
00283   return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
00284 }
00285 
00286 inline int vtkRectilinearGrid::GetDataDimension()
00287 {
00288   return vtkStructuredData::GetDataDimension(this->DataDescription);
00289 }
00290 
00291 inline vtkIdType vtkRectilinearGrid::ComputePointId(int ijk[3])
00292 {
00293   return vtkStructuredData::ComputePointId(this->Dimensions,ijk);
00294 }
00295 
00296 inline vtkIdType vtkRectilinearGrid::ComputeCellId(int ijk[3])
00297 {
00298   return vtkStructuredData::ComputeCellId(this->Dimensions,ijk);
00299 }
00300 
00301 #endif

Generated on Thu Mar 28 14:19:17 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001