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 =========================================================================*/
00066 #ifndef __vtkRectilinearGrid_h
00067 #define __vtkRectilinearGrid_h
00068 
00069 #include "vtkDataSet.h"
00070 #include "vtkStructuredData.h"
00071 class vtkVertex;
00072 class vtkLine;
00073 class vtkPixel;
00074 class vtkVoxel;
00075 
00076 class VTK_EXPORT vtkRectilinearGrid : public vtkDataSet
00077 {
00078 public:
00079   static vtkRectilinearGrid *New();
00080 
00081   vtkTypeMacro(vtkRectilinearGrid,vtkDataSet);
00082   void PrintSelf(ostream& os, vtkIndent indent);
00083 
00085   vtkDataObject *MakeObject() {return vtkRectilinearGrid::New();};
00086 
00088   int GetDataObjectType() {return VTK_RECTILINEAR_GRID;};
00089 
00092   void CopyStructure(vtkDataSet *ds);
00093 
00095   void Initialize();
00096 
00098   int GetNumberOfCells();
00099   int GetNumberOfPoints();
00100   float *GetPoint(int ptId);
00101   void GetPoint(int id, float x[3]);
00102   vtkCell *GetCell(int cellId);
00103   void GetCell(int cellId, vtkGenericCell *cell);
00104   void GetCellBounds(int cellId, float bounds[6]);
00105   int FindPoint(float x, float y, float z) { return this->vtkDataSet::FindPoint(x, y, z);};
00106   int FindPoint(float x[3]);
00107   int FindCell(float x[3], vtkCell *cell, int cellId, float tol2, int& subId, 
00108                float pcoords[3], float *weights);
00109   int FindCell(float x[3], vtkCell *cell, vtkGenericCell *gencell,
00110           int cellId, float tol2, int& subId, 
00111                float pcoords[3], float *weights);
00112   vtkCell *FindAndGetCell(float x[3], vtkCell *cell, int cellId, 
00113                float tol2, int& subId, float pcoords[3], float *weights);
00114   int GetCellType(int cellId);
00115   void GetCellPoints(int cellId, vtkIdList *ptIds)
00116     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
00117                   this->Dimensions);}
00118   void GetPointCells(int ptId, vtkIdList *cellIds)
00119     {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
00120   void ComputeBounds();
00121   int GetMaxCellSize() {return 8;}; //voxel is the largest
00122   void GetCellNeighbors(int cellId, vtkIdList *ptIds, vtkIdList *cellIds);
00123 
00126   void SetDimensions(int i, int j, int k);
00127   void SetDimensions(int dim[3]);
00128 
00130   vtkGetVectorMacro(Dimensions,int,3);
00131 
00133   int GetDataDimension();
00134 
00140   int ComputeStructuredCoordinates(float x[3], int ijk[3], float pcoords[3]);
00141 
00144   int ComputePointId(int ijk[3]);
00145 
00148   int ComputeCellId(int ijk[3]);
00149 
00151   vtkSetObjectMacro(XCoordinates,vtkScalars);
00152   vtkGetObjectMacro(XCoordinates,vtkScalars);
00153 
00155   vtkSetObjectMacro(YCoordinates,vtkScalars);
00156   vtkGetObjectMacro(YCoordinates,vtkScalars);
00157 
00159   vtkSetObjectMacro(ZCoordinates,vtkScalars);
00160   vtkGetObjectMacro(ZCoordinates,vtkScalars);
00161 
00165   void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00166   void SetUpdateExtent(int piece, int numPieces)
00167     {this->SetUpdateExtent(piece, numPieces, 0);}
00168 
00170   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00171     { this->vtkDataSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00172   void SetUpdateExtent( int ext[6] )
00173     { this->vtkDataSet::SetUpdateExtent( ext ); };
00174 
00178   void SetExtent(int extent[6]);
00179   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00180   vtkGetVector6Macro(Extent,int);
00181 
00187   unsigned long GetActualMemorySize();
00188 
00190   void ShallowCopy(vtkDataObject *src);  
00191   void DeepCopy(vtkDataObject *src);
00192   
00193 #ifndef VTK_REMOVE_LEGACY_CODE
00194 
00195   void GetCellPoints(int cellId, vtkIdList &ptIds)
00196     {VTK_LEGACY_METHOD(GetCellPoints,"3.2"); this->GetCellPoints(cellId, &ptIds);}
00197   void GetPointCells(int ptId, vtkIdList &cellIds)
00198     {VTK_LEGACY_METHOD(GetPointCells,"3.2"); this->GetPointCells(ptId, &cellIds);}
00199 #endif
00200   
00201 protected:
00202   vtkRectilinearGrid();
00203   ~vtkRectilinearGrid();
00204   vtkRectilinearGrid(const vtkRectilinearGrid&) {};
00205   void operator=(const vtkRectilinearGrid&) {};
00206 
00207   // for the GetCell method
00208   vtkVertex *Vertex;
00209   vtkLine *Line;
00210   vtkPixel *Pixel;
00211   vtkVoxel *Voxel;
00212   
00213   // The extent type is a 3D extent
00214   int GetExtentType() { return VTK_3D_EXTENT; };
00215 
00216   int Dimensions[3];
00217   int DataDescription;
00218 
00219   vtkScalars *XCoordinates;
00220   vtkScalars *YCoordinates;
00221   vtkScalars *ZCoordinates;
00222 
00223   // Hang on to some space for returning points when GetPoint(id) is called.
00224   float PointReturn[3];
00225 
00226 private:
00228   void GetCellNeighbors(int cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00229     {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00230 };
00231 
00232 
00233 
00234 
00235 inline int vtkRectilinearGrid::GetNumberOfCells() 
00236 {
00237   int nCells=1;
00238   int i;
00239 
00240   for (i=0; i<3; i++)
00241     {
00242     if (this->Dimensions[i] > 1)
00243       {
00244       nCells *= (this->Dimensions[i]-1);
00245       }
00246     }
00247 
00248   return nCells;
00249 }
00250 
00251 inline int vtkRectilinearGrid::GetNumberOfPoints()
00252 {
00253   return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
00254 }
00255 
00256 inline int vtkRectilinearGrid::GetDataDimension()
00257 {
00258   return vtkStructuredData::GetDataDimension(this->DataDescription);
00259 }
00260 
00261 inline int vtkRectilinearGrid::ComputePointId(int ijk[3])
00262 {
00263   return vtkStructuredData::ComputePointId(this->Dimensions,ijk);
00264 }
00265 
00266 inline int vtkRectilinearGrid::ComputeCellId(int ijk[3])
00267 {
00268   return vtkStructuredData::ComputeCellId(this->Dimensions,ijk);
00269 }
00270 
00271 #endif

Generated on Wed Nov 21 12:26:53 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001