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   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00058 #ifndef __vtkRectilinearGrid_h
    00059 #define __vtkRectilinearGrid_h
    00060
    00061 #include "vtkDataSet.h"
    00062 #include "vtkStructuredData.h" // For inline methods
    00063
    00064 class vtkVertex;
    00065 class vtkLine;
    00066 class vtkPixel;
    00067 class vtkVoxel;
    00068 class vtkDataArray;
    00069
    00070 class VTK_COMMON_EXPORT vtkRectilinearGrid : public vtkDataSet
    00071 {
    00072 public:
    00073   static vtkRectilinearGrid *New();
    00074
    00075   vtkTypeRevisionMacro(vtkRectilinearGrid,vtkDataSet);
    00076   void PrintSelf(ostream& os, vtkIndent indent);
    00077
    00079   int GetDataObjectType() {return VTK_RECTILINEAR_GRID;};
    00080
    00083   void CopyStructure(vtkDataSet *ds);
    00084
    00086   void Initialize();
    00087
    00089
    00090   vtkIdType GetNumberOfCells();
    00091   vtkIdType GetNumberOfPoints();
    00092   float *GetPoint(vtkIdType ptId);
    00093   void GetPoint(vtkIdType id, float x[3]);
    00094   vtkCell *GetCell(vtkIdType cellId);
    00095   void GetCell(vtkIdType cellId, vtkGenericCell *cell);
    00096   void GetCellBounds(vtkIdType cellId, float bounds[6]);
    00097   int FindPoint(float x, float y, float z) { return this->vtkDataSet::FindPoint(x, y, z);};
    00098   vtkIdType FindPoint(float x[3]);
    00099   vtkIdType FindCell(float x[3], vtkCell *cell, vtkIdType cellId, float tol2,
    00100                      int& subId, float pcoords[3], float *weights);
    00101   vtkIdType FindCell(float x[3], vtkCell *cell, vtkGenericCell *gencell,
    00102                      vtkIdType cellId, float tol2, int& subId,
    00103                      float pcoords[3], float *weights);
    00104   vtkCell *FindAndGetCell(float x[3], vtkCell *cell, vtkIdType cellId,
    00105                           float tol2, int& subId, float pcoords[3],
    00106                           float *weights);
    00107   int GetCellType(vtkIdType cellId);
    00108   void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
    00109     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
    00110                                       this->Dimensions);}
    00111   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
    00112     {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
    00113   void ComputeBounds();
    00114   int GetMaxCellSize() {return 8;}; //voxel is the largest
    00115   void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
    00116                         vtkIdList *cellIds);
    00118
    00120
    00122   void SetDimensions(int i, int j, int k);
    00123   void SetDimensions(int dim[3]);
    00125
    00127
    00128   vtkGetVectorMacro(Dimensions,int,3);
    00130
    00132   int GetDataDimension();
    00133
    00139   int ComputeStructuredCoordinates(float x[3], int ijk[3], float pcoords[3]);
    00140
    00143   vtkIdType ComputePointId(int ijk[3]);
    00144
    00147   vtkIdType ComputeCellId(int ijk[3]);
    00148
    00150
    00151   virtual void SetXCoordinates(vtkDataArray*);
    00152   vtkGetObjectMacro(XCoordinates,vtkDataArray);
    00154
    00156
    00157   virtual void SetYCoordinates(vtkDataArray*);
    00158   vtkGetObjectMacro(YCoordinates,vtkDataArray);
    00160
    00162
    00163   virtual void SetZCoordinates(vtkDataArray*);
    00164   vtkGetObjectMacro(ZCoordinates,vtkDataArray);
    00166
    00168
    00171   void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
    00172   void SetUpdateExtent(int piece, int numPieces)
    00173     {this->SetUpdateExtent(piece, numPieces, 0);}
    00175
    00177
    00178   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
    00179     { this->vtkDataSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
    00180   void SetUpdateExtent( int ext[6] )
    00181     { this->vtkDataSet::SetUpdateExtent( ext ); };
    00183
    00185
    00188   void SetExtent(int extent[6]);
    00189   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
    00190   vtkGetVector6Macro(Extent,int);
    00192
    00198   unsigned long GetActualMemorySize();
    00199
    00201
    00202   void ShallowCopy(vtkDataObject *src);
    00203   void DeepCopy(vtkDataObject *src);
    00205
    00211   virtual void UpdateData();
    00212
    00213 protected:
    00214   vtkRectilinearGrid();
    00215   ~vtkRectilinearGrid();
    00216
    00217   // for the GetCell method
    00218   vtkVertex *Vertex;
    00219   vtkLine *Line;
    00220   vtkPixel *Pixel;
    00221   vtkVoxel *Voxel;
    00222
    00223   // The extent type is a 3D extent
    00224   int GetExtentType() { return VTK_3D_EXTENT; };
    00225
    00229   virtual void Crop();
    00230
    00231   int Dimensions[3];
    00232   int DataDescription;
    00233
    00234   vtkDataArray *XCoordinates;
    00235   vtkDataArray *YCoordinates;
    00236   vtkDataArray *ZCoordinates;
    00237
    00238   // Hang on to some space for returning points when GetPoint(id) is called.
    00239   float PointReturn[3];
    00240
    00241 private:
    00243
    00244   void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
    00245     {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
    00247 private:
    00248   vtkRectilinearGrid(const vtkRectilinearGrid&);  // Not implemented.
    00249   void operator=(const vtkRectilinearGrid&);  // Not implemented.
    00250 };
    00251
    00252
    00253
    00254
    00255 inline vtkIdType vtkRectilinearGrid::GetNumberOfCells()
    00256 {
    00257   vtkIdType nCells=1;
    00258   int i;
    00259
    00260   for (i=0; i<3; i++)
    00261     {
    00262     if (this->Dimensions[i] <= 0)
    00263       {
    00264       return 0;
    00265       }
    00266     if (this->Dimensions[i] > 1)
    00267       {
    00268       nCells *= (this->Dimensions[i]-1);
    00269       }
    00270     }
    00271
    00272   return nCells;
    00273 }
    00274
    00275 inline vtkIdType vtkRectilinearGrid::GetNumberOfPoints()
    00276 {
    00277   return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
    00278 }
    00279
    00280 inline int vtkRectilinearGrid::GetDataDimension()
    00281 {
    00282   return vtkStructuredData::GetDataDimension(this->DataDescription);
    00283 }
    00284
    00285 inline vtkIdType vtkRectilinearGrid::ComputePointId(int ijk[3])
    00286 {
    00287   return vtkStructuredData::ComputePointId(this->Dimensions,ijk);
    00288 }
    00289
    00290 inline vtkIdType vtkRectilinearGrid::ComputeCellId(int ijk[3])
    00291 {
    00292   return vtkStructuredData::ComputeCellId(this->Dimensions,ijk);
    00293 }
    00294
    00295 #endif