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

Common/vtkUniformGrid.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkUniformGrid.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 =========================================================================*/
00034 #ifndef __vtkUniformGrid_h
00035 #define __vtkUniformGrid_h
00036 
00037 #include "vtkDataSet.h"
00038 
00039 #include "vtkStructuredData.h" // Needed for inline methods
00040 
00041 class vtkDataArray;
00042 class vtkEmptyCell;
00043 class vtkImageData;
00044 class vtkLine;
00045 class vtkPixel;
00046 class vtkVertex;
00047 class vtkVoxel;
00048 class vtkStructuredVisibilityConstraint;
00049 class vtkUnsignedCharArray;
00050 
00051 class VTK_COMMON_EXPORT vtkUniformGrid : public vtkDataSet
00052 {
00053 public:
00054   static vtkUniformGrid *New();
00055 
00056   vtkTypeRevisionMacro(vtkUniformGrid,vtkDataSet);
00057   void PrintSelf(ostream& os, vtkIndent indent);
00058 
00061   void CopyStructure(vtkDataSet *ds);
00062 
00064   int GetDataObjectType() {return VTK_UNIFORM_GRID;};
00065 
00067 
00068   vtkIdType GetNumberOfCells();
00069   vtkIdType GetNumberOfPoints();
00070   double *GetPoint(vtkIdType ptId);
00071   void GetPoint(vtkIdType id, double x[3]);
00072   vtkCell *GetCell(vtkIdType cellId);
00073   void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00074   void GetCellBounds(vtkIdType cellId, double bounds[6]);
00075   vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);};
00076   vtkIdType FindPoint(double x[3]);
00077   vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, 
00078                      int& subId, double pcoords[3], double *weights);
00079   vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell,
00080                      vtkIdType cellId, double tol2, int& subId, 
00081                      double pcoords[3], double *weights);
00082   vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, 
00083                           double tol2, int& subId, double pcoords[3],
00084                           double *weights);
00085   int GetCellType(vtkIdType cellId);
00086   void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
00087     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
00088                                       this->GetDimensions());}
00089   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
00090     {vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());}
00091   void ComputeBounds();
00092   void Initialize();
00093   int GetMaxCellSize() {return 8;}; //voxel is the largest
00094   virtual void GetScalarRange(double range[2]);
00095   double *GetScalarRange() {return this->Superclass::GetScalarRange();}
00097 
00099 
00101   void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00102   void SetUpdateExtent(int piece, int numPieces)
00103     {this->SetUpdateExtent(piece, numPieces, 0);}
00105 
00107 
00111   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00112     { this->Superclass::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00113   void SetUpdateExtent( int ext[6] )
00114     { this->Superclass::SetUpdateExtent( ext ); };
00116 
00118   void SetDimensions(int i, int j, int k);
00119 
00121   void SetDimensions(int dims[3]);
00122 
00124 
00126   int *GetDimensions();
00127   void GetDimensions(int dims[3]);
00129 
00135   int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
00136   
00138   int GetDataDimension();
00139 
00141 
00144   void SetExtent(int extent[6]);
00145   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00146   vtkGetVector6Macro(Extent,int);
00148 
00154   unsigned long GetActualMemorySize();
00155   
00157 
00159   vtkSetVector3Macro(Spacing,double);
00160   vtkGetVector3Macro(Spacing,double);
00162   
00164 
00166   vtkSetVector3Macro(Origin,double);
00167   vtkGetVector3Macro(Origin,double);
00169   
00171 
00172   void ShallowCopy(vtkDataObject *src);  
00173   void DeepCopy(vtkDataObject *src);
00175   
00177   int GetExtentType() { return VTK_3D_EXTENT; };
00178 
00180 
00184   void BlankPoint(vtkIdType ptId);
00185   void UnBlankPoint(vtkIdType ptId);
00187 
00189 
00192   void BlankCell(vtkIdType ptId);
00193   void UnBlankCell(vtkIdType ptId);
00195   
00197   vtkUnsignedCharArray *GetPointVisibilityArray(); 
00198 
00202   void SetPointVisibilityArray(vtkUnsignedCharArray *pointVisibility);
00203 
00205   vtkUnsignedCharArray *GetCellVisibilityArray(); 
00206 
00210   void SetCellVisibilityArray(vtkUnsignedCharArray *pointVisibility);
00211 
00214   unsigned char IsPointVisible(vtkIdType ptId);
00215   
00218   unsigned char IsCellVisible(vtkIdType cellId);
00219 
00222   unsigned char GetPointBlanking();
00223 
00226   unsigned char GetCellBlanking();
00227 
00228 protected:
00229   vtkUniformGrid();
00230   ~vtkUniformGrid();
00231 
00232   // for the GetCell method
00233   vtkVertex *Vertex;
00234   vtkLine *Line;
00235   vtkPixel *Pixel;
00236   vtkVoxel *Voxel;
00237   vtkEmptyCell *EmptyCell;
00238 
00239   // The extent of what is currently in the structured grid.
00240   // Dimensions is just an array to return a value.
00241   // Its contents are out of data until GetDimensions is called.
00242   int Dimensions[3];
00243   int DataDescription;
00244 
00245   double Origin[3];
00246   double Spacing[3];
00247 
00248   vtkStructuredVisibilityConstraint* PointVisibility;
00249 
00250   void SetPointVisibility(vtkStructuredVisibilityConstraint *pointVisibility);
00251   vtkGetObjectMacro(PointVisibility, vtkStructuredVisibilityConstraint);
00252 
00253   vtkStructuredVisibilityConstraint* CellVisibility;
00254 
00255   void SetCellVisibility(vtkStructuredVisibilityConstraint *cellVisibility);
00256   vtkGetObjectMacro(CellVisibility, vtkStructuredVisibilityConstraint);
00257 
00258 private:
00259   void InternalUniformGridCopy(vtkUniformGrid *src);
00260   void InternalUniformGridCopy(vtkImageData *src);
00261 private:
00262   vtkUniformGrid(const vtkUniformGrid&);  // Not implemented.
00263   void operator=(const vtkUniformGrid&);  // Not implemented.
00264 };
00265 
00266 
00267 inline void vtkUniformGrid::GetPoint(vtkIdType id, double x[3])
00268 {
00269   double *p=this->GetPoint(id);
00270   x[0] = p[0]; x[1] = p[1]; x[2] = p[2];
00271 }
00272 
00273 
00274 
00275 inline vtkIdType vtkUniformGrid::GetNumberOfPoints()
00276 {
00277   int *dims = this->GetDimensions();
00278   return dims[0]*dims[1]*dims[2];
00279 }
00280 
00281 inline int vtkUniformGrid::GetDataDimension()
00282 {
00283   return vtkStructuredData::GetDataDimension(this->DataDescription);
00284 }
00285 
00286 #endif
00287 
00288 
00289