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

Common/vtkStructuredGrid.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkStructuredGrid.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 =========================================================================*/
00051 #ifndef __vtkStructuredGrid_h
00052 #define __vtkStructuredGrid_h
00053 
00054 #include "vtkPointSet.h"
00055 
00056 #include "vtkStructuredData.h" // Needed for inline methods
00057 #include "vtkUnsignedCharArray.h" // Needed for inline methods
00058 
00059 class vtkEmptyCell;
00060 class vtkHexahedron;
00061 class vtkLine;
00062 class vtkQuad;
00063 class vtkVertex;
00064 
00065 class VTK_COMMON_EXPORT vtkStructuredGrid : public vtkPointSet 
00066 {
00067 public:
00068   static vtkStructuredGrid *New();
00069 
00070   vtkTypeRevisionMacro(vtkStructuredGrid,vtkPointSet);
00071   void PrintSelf(ostream& os, vtkIndent indent);
00072  
00074   int GetDataObjectType() {return VTK_STRUCTURED_GRID;}
00075 
00078   void CopyStructure(vtkDataSet *ds);
00079 
00081 
00082   vtkIdType GetNumberOfPoints() {return vtkPointSet::GetNumberOfPoints();}
00083   float *GetPoint(vtkIdType ptId) {return this->vtkPointSet::GetPoint(ptId);}
00084   void GetPoint(vtkIdType ptId, float p[3])
00085     {this->vtkPointSet::GetPoint(ptId,p);}
00086   vtkCell *GetCell(vtkIdType cellId);
00087   void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00088   void GetCellBounds(vtkIdType cellId, float bounds[6]);
00089   int GetCellType(vtkIdType cellId);
00090   vtkIdType GetNumberOfCells();
00091   void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00092   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
00093     {
00094       vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());
00095     }
00096   void Initialize();
00097   int GetMaxCellSize() {return 8;}; //hexahedron is the largest
00098   void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00099                         vtkIdList *cellIds);
00100   virtual void GetScalarRange(float range[2]);
00101   float *GetScalarRange() {return this->vtkPointSet::GetScalarRange();}
00103 
00105 
00106   void SetDimensions(int i, int j, int k);
00107   void SetDimensions(int dim[3]);
00109 
00111 
00112   virtual int *GetDimensions ();
00113   virtual void GetDimensions (int dim[3]);
00115 
00117   int GetDataDimension();
00118 
00120 
00122   void SetBlanking(int blanking);
00123   int GetBlanking() {return this->Blanking;}
00124   void BlankingOn();
00125   void BlankingOff();
00126   void BlankPoint(vtkIdType ptId);
00127   void UnBlankPoint(vtkIdType ptId);
00129   
00131 
00132   vtkUnsignedCharArray *GetPointVisibility() 
00133     {return this->PointVisibility;}
00135 
00139   void SetPointVisibility(vtkUnsignedCharArray *pointVisibility);
00140 
00142 
00144   unsigned char IsPointVisible(vtkIdType ptId)
00145     {return (this->Blanking ? this->PointVisibility->GetValue(ptId) : 1);}
00147   
00150   unsigned char IsCellVisible(vtkIdType cellId);
00151   
00153 
00156   void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00157   void SetUpdateExtent(int piece, int numPieces)
00158     {this->SetUpdateExtent(piece, numPieces, 0);}
00160 
00162 
00163   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00164     { this->vtkPointSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00165   void SetUpdateExtent( int ext[6] )
00166     { this->vtkPointSet::SetUpdateExtent( ext ); };
00168 
00170 
00173   void SetExtent(int extent[6]);
00174   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00175   vtkGetVector6Macro(Extent,int);
00177 
00183   unsigned long GetActualMemorySize();
00184 
00186 
00187   void ShallowCopy(vtkDataObject *src);  
00188   void DeepCopy(vtkDataObject *src);
00190 
00193   virtual void UpdateData();
00194 
00195 protected:
00196   vtkStructuredGrid();
00197   ~vtkStructuredGrid();
00198 
00199   // for the GetCell method
00200   vtkVertex *Vertex;
00201   vtkLine *Line;
00202   vtkQuad *Quad;  
00203   vtkHexahedron *Hexahedron;
00204   vtkEmptyCell *EmptyCell;
00205 
00206   // The extent type is a 3D extent
00207   int GetExtentType() { return VTK_3D_EXTENT; }
00208   
00212   virtual void Crop();
00213 
00214   int Dimensions[3];
00215   int DataDescription;
00216   int Blanking;
00217   vtkUnsignedCharArray *PointVisibility;
00218   void AllocatePointVisibility();
00219 
00220 private:
00222 
00223   void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00224     {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00226 
00227   // Internal method used by DeepCopy and ShallowCopy.
00228   void InternalStructuredGridCopy(vtkStructuredGrid *src);
00229 
00230 private:
00231   vtkStructuredGrid(const vtkStructuredGrid&);  // Not implemented.
00232   void operator=(const vtkStructuredGrid&);  // Not implemented.
00233 };
00234 
00235 
00236 inline vtkIdType vtkStructuredGrid::GetNumberOfCells() 
00237 {
00238   int nCells=1;
00239   int dims[3];
00240   int i;
00241 
00242   this->GetDimensions(dims);
00243   for (i=0; i<3; i++)
00244     {
00245     if (dims[i] <= 0)
00246       {
00247       return 0;
00248       }
00249     if (dims[i] > 1)
00250       {
00251       nCells *= (dims[i]-1);
00252       }
00253     }
00254 
00255   return nCells;
00256 }
00257 
00258 inline int vtkStructuredGrid::GetDataDimension()
00259 {
00260   return vtkStructuredData::GetDataDimension(this->DataDescription);
00261 }
00262 
00263 #endif
00264 
00265 
00266 
00267 
00268 
00269