VTK
dox/Common/DataModel/vtkStructuredGrid.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkStructuredGrid.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00047 #ifndef __vtkStructuredGrid_h
00048 #define __vtkStructuredGrid_h
00049 
00050 #include "vtkCommonDataModelModule.h" // For export macro
00051 #include "vtkPointSet.h"
00052 
00053 #include "vtkStructuredData.h" // Needed for inline methods
00054 
00055 class vtkEmptyCell;
00056 class vtkHexahedron;
00057 class vtkLine;
00058 class vtkQuad;
00059 class vtkStructuredVisibilityConstraint;
00060 class vtkUnsignedCharArray;
00061 class vtkVertex;
00062 
00063 class VTKCOMMONDATAMODEL_EXPORT vtkStructuredGrid : public vtkPointSet
00064 {
00065 public:
00066   static vtkStructuredGrid *New();
00067 
00068   vtkTypeMacro(vtkStructuredGrid,vtkPointSet);
00069   void PrintSelf(ostream& os, vtkIndent indent);
00070 
00072   int GetDataObjectType() {return VTK_STRUCTURED_GRID;}
00073 
00076   void CopyStructure(vtkDataSet *ds);
00077 
00079 
00080   vtkIdType GetNumberOfPoints() {return vtkPointSet::GetNumberOfPoints();}
00081   double *GetPoint(vtkIdType ptId) {return this->vtkPointSet::GetPoint(ptId);}
00082   void GetPoint(vtkIdType ptId, double p[3])
00083     {this->vtkPointSet::GetPoint(ptId,p);}
00084   vtkCell *GetCell(vtkIdType cellId);
00085   void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00086   void GetCellBounds(vtkIdType cellId, double bounds[6]);
00087   int GetCellType(vtkIdType cellId);
00088   vtkIdType GetNumberOfCells();
00089   void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00090   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
00091     {
00092       vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());
00093     }
00094   void Initialize();
00095   int GetMaxCellSize() {return 8;}; //hexahedron is the largest
00096   void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00097                         vtkIdList *cellIds);
00098   virtual void GetScalarRange(double range[2]);
00099   double *GetScalarRange() {return this->Superclass::GetScalarRange();}
00101 
00103 
00104   void SetDimensions(int i, int j, int k);
00105   void SetDimensions(int dim[3]);
00107 
00109 
00110   virtual int *GetDimensions ();
00111   virtual void GetDimensions (int dim[3]);
00113 
00115   int GetDataDimension();
00116 
00118 
00121   void SetExtent(int extent[6]);
00122   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00123   vtkGetVector6Macro(Extent, int);
00125 
00131   unsigned long GetActualMemorySize();
00132 
00134 
00135   void ShallowCopy(vtkDataObject *src);
00136   void DeepCopy(vtkDataObject *src);
00138 
00140   int GetExtentType() { return VTK_3D_EXTENT; }
00141 
00143 
00147   void BlankPoint(vtkIdType ptId);
00148   void UnBlankPoint(vtkIdType ptId);
00150 
00152 
00156   void BlankCell(vtkIdType ptId);
00157   void UnBlankCell(vtkIdType ptId);
00159 
00161   vtkUnsignedCharArray *GetPointVisibilityArray();
00162 
00166   void SetPointVisibilityArray(vtkUnsignedCharArray *pointVisibility);
00167 
00169   vtkUnsignedCharArray *GetCellVisibilityArray();
00170 
00174   void SetCellVisibilityArray(vtkUnsignedCharArray *pointVisibility);
00175 
00178   unsigned char IsPointVisible(vtkIdType ptId);
00179 
00182   unsigned char IsCellVisible(vtkIdType cellId);
00183 
00186   unsigned char GetPointBlanking();
00187 
00190   unsigned char GetCellBlanking();
00191 
00196   void GetCellDims( int cellDims[3] );
00197 
00201   virtual void Crop(const int* updateExtent);
00202 
00203   //BTX
00205 
00206   static vtkStructuredGrid* GetData(vtkInformation* info);
00207   static vtkStructuredGrid* GetData(vtkInformationVector* v, int i=0);
00208   //ETX
00210 
00217   void GetPoint(int i, int j, int k, double p[3], bool adjustForExtent = true);
00218 
00219 protected:
00220   vtkStructuredGrid();
00221   ~vtkStructuredGrid();
00222 
00223   // for the GetCell method
00224   vtkVertex *Vertex;
00225   vtkLine *Line;
00226   vtkQuad *Quad;
00227   vtkHexahedron *Hexahedron;
00228   vtkEmptyCell *EmptyCell;
00229 
00230   int Dimensions[3];
00231   int DataDescription;
00232 
00233   int Extent[6];
00234 
00235   vtkStructuredVisibilityConstraint* PointVisibility;
00236 
00237   void SetPointVisibility(vtkStructuredVisibilityConstraint *pointVisibility);
00238   vtkGetObjectMacro(PointVisibility, vtkStructuredVisibilityConstraint);
00239 
00240   vtkStructuredVisibilityConstraint* CellVisibility;
00241 
00242   void SetCellVisibility(vtkStructuredVisibilityConstraint *cellVisibility);
00243   vtkGetObjectMacro(CellVisibility, vtkStructuredVisibilityConstraint);
00244 
00245 private:
00247 
00248   void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00249     {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00251 
00252   // Internal method used by DeepCopy and ShallowCopy.
00253   void InternalStructuredGridCopy(vtkStructuredGrid *src);
00254 
00255 private:
00256   vtkStructuredGrid(const vtkStructuredGrid&);  // Not implemented.
00257   void operator=(const vtkStructuredGrid&);  // Not implemented.
00258 };
00259 
00260 
00261 inline vtkIdType vtkStructuredGrid::GetNumberOfCells()
00262 {
00263   int nCells=1;
00264   int dims[3];
00265   int i;
00266 
00267   this->GetDimensions(dims);
00268   for (i=0; i<3; i++)
00269     {
00270     if (dims[i] <= 0)
00271       {
00272       return 0;
00273       }
00274     if (dims[i] > 1)
00275       {
00276       nCells *= (dims[i]-1);
00277       }
00278     }
00279 
00280   return nCells;
00281 }
00282 
00283 inline int vtkStructuredGrid::GetDataDimension()
00284 {
00285   return vtkStructuredData::GetDataDimension(this->DataDescription);
00286 }
00287 
00288 #endif
00289 
00290 
00291 
00292 
00293 
00294