VTK
dox/Common/DataModel/vtkUnstructuredGrid.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkUnstructuredGrid.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 =========================================================================*/
00032 #ifndef __vtkUnstructuredGrid_h
00033 #define __vtkUnstructuredGrid_h
00034 
00035 #include "vtkCommonDataModelModule.h" // For export macro
00036 #include "vtkUnstructuredGridBase.h"
00037 
00038 class vtkCellArray;
00039 class vtkCellLinks;
00040 class vtkConvexPointSet;
00041 class vtkEmptyCell;
00042 class vtkHexahedron;
00043 class vtkIdList;
00044 class vtkIdTypeArray;
00045 class vtkLine;
00046 class vtkPixel;
00047 class vtkPolyLine;
00048 class vtkPolyVertex;
00049 class vtkPolygon;
00050 class vtkPyramid;
00051 class vtkPentagonalPrism;
00052 class vtkHexagonalPrism;
00053 class vtkQuad;
00054 class vtkQuadraticEdge;
00055 class vtkQuadraticHexahedron;
00056 class vtkQuadraticWedge;
00057 class vtkQuadraticPolygon;
00058 class vtkQuadraticPyramid;
00059 class vtkQuadraticQuad;
00060 class vtkQuadraticTetra;
00061 class vtkQuadraticTriangle;
00062 class vtkTetra;
00063 class vtkTriangle;
00064 class vtkTriangleStrip;
00065 class vtkUnsignedCharArray;
00066 class vtkVertex;
00067 class vtkVoxel;
00068 class vtkWedge;
00069 class vtkTriQuadraticHexahedron;
00070 class vtkQuadraticLinearWedge;
00071 class vtkQuadraticLinearQuad;
00072 class vtkBiQuadraticQuad;
00073 class vtkBiQuadraticQuadraticWedge;
00074 class vtkBiQuadraticQuadraticHexahedron;
00075 class vtkBiQuadraticTriangle;
00076 class vtkCubicLine;
00077 class vtkPolyhedron;
00078 class vtkIdTypeArray;
00079 
00080 class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGrid :
00081     public vtkUnstructuredGridBase
00082 {
00083 public:
00084   static vtkUnstructuredGrid *New();
00085 
00086   vtkTypeMacro(vtkUnstructuredGrid, vtkUnstructuredGridBase)
00087   void PrintSelf(ostream& os, vtkIndent indent);
00088 
00090   int GetDataObjectType() {return VTK_UNSTRUCTURED_GRID;};
00091 
00096   virtual void Allocate(vtkIdType numCells=1000, int extSize=1000);
00097 
00106   vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds);
00107 
00114   vtkIdType InsertNextCell(int type, vtkIdList *ptIds);
00115 
00116   // Desciption:
00117   // Insert/create a polyhedron cell. npts is the number of unique points in
00118   // the cell. pts is the list of the unique cell point Ids. nfaces is the
00119   // number of faces in the cell. faces is the face-stream
00120   // [numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...].
00121   // All point Ids are global.
00122   vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds,
00123                            vtkIdType nfaces, vtkIdType *faces);
00124 
00126 
00127   void Reset();
00128   virtual void CopyStructure(vtkDataSet *ds);
00129   vtkIdType GetNumberOfCells();
00130   virtual vtkCell *GetCell(vtkIdType cellId);
00131   virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00132   virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
00133   virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00134   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00135   vtkCellIterator* NewCellIterator();
00137 
00138   int GetCellType(vtkIdType cellId);
00139   vtkUnsignedCharArray* GetCellTypesArray() { return this->Types; }
00140   vtkIdTypeArray* GetCellLocationsArray() { return this->Locations; }
00141   void Squeeze();
00142   void Initialize();
00143   int GetMaxCellSize();
00144   void BuildLinks();
00145   vtkCellLinks *GetCellLinks() {return this->Links;};
00146   virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts,
00147                              vtkIdType* &pts);
00148 
00154   void GetFaceStream(vtkIdType cellId, vtkIdList *ptIds);
00155 
00161   void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType* &ptIds);
00162 
00164 
00176   void SetCells(int type, vtkCellArray *cells);
00177   void SetCells(int *types, vtkCellArray *cells);
00178   void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations,
00179                 vtkCellArray *cells);
00180   void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations,
00181                 vtkCellArray *cells, vtkIdTypeArray *faceLocations,
00182                 vtkIdTypeArray *faces);
00184 
00185   vtkCellArray *GetCells() {return this->Connectivity;};
00186   void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
00187   vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00188   void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00189   void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00190   void ResizeCellList(vtkIdType ptId, int size);
00191 
00193 
00196   virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00197                                 vtkIdList *cellIds);
00199 
00201 
00203   virtual int GetPiece();
00204   virtual int GetNumberOfPieces();
00206 
00208   virtual int GetGhostLevel();
00209 
00215   unsigned long GetActualMemorySize();
00216 
00218 
00219   virtual void ShallowCopy(vtkDataObject *src);
00220   virtual void DeepCopy(vtkDataObject *src);
00222 
00226   void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array);
00227 
00229   int IsHomogeneous();
00230 
00233   void RemoveGhostCells(int level);
00234 
00235   //BTX
00237 
00238   static vtkUnstructuredGrid* GetData(vtkInformation* info);
00239   static vtkUnstructuredGrid* GetData(vtkInformationVector* v, int i=0);
00240   //ETX
00242 
00244   vtkIdType      *GetFaces(vtkIdType cellId);
00245 
00247 
00248   vtkIdTypeArray* GetFaces(){return this->Faces;};
00249   vtkIdTypeArray* GetFaceLocations(){return this->FaceLocations;};
00251 
00258   int InitializeFacesRepresentation(vtkIdType numPrevCells);
00259 
00261 
00270   static void DecomposeAPolyhedronCell(vtkCellArray *polyhedronCellArray,
00271                                        vtkIdType & nCellpts,
00272                                        vtkIdType & nCellfaces,
00273                                        vtkCellArray *cellArray,
00274                                        vtkIdTypeArray *faces);
00276 
00277   static void DecomposeAPolyhedronCell(vtkIdType * polyhedronCellStream,
00278                                        vtkIdType & nCellpts,
00279                                        vtkIdType & nCellfaces,
00280                                        vtkCellArray *cellArray,
00281                                        vtkIdTypeArray *faces);
00282 
00284 
00293   static void DecomposeAPolyhedronCell(vtkIdType nCellFaces,
00294                                        vtkIdType * inFaceStream,
00295                                        vtkIdType & nCellpts,
00296                                        vtkCellArray * cellArray,
00297                                        vtkIdTypeArray * faces);
00299 
00301 
00305   static void ConvertFaceStreamPointIds(vtkIdList * faceStream,
00306                                         vtkIdType * idMap);
00308 
00310 
00314   static void ConvertFaceStreamPointIds(vtkIdType nfaces,
00315                                         vtkIdType * faceStream,
00316                                         vtkIdType * idMap);
00318 
00319 
00320 protected:
00321   vtkUnstructuredGrid();
00322   ~vtkUnstructuredGrid();
00323 
00324   // used by GetCell method
00325   vtkVertex                         *Vertex;
00326   vtkPolyVertex                     *PolyVertex;
00327   vtkLine                           *Line;
00328   vtkPolyLine                       *PolyLine;
00329   vtkTriangle                       *Triangle;
00330   vtkTriangleStrip                  *TriangleStrip;
00331   vtkPixel                          *Pixel;
00332   vtkQuad                           *Quad;
00333   vtkPolygon                        *Polygon;
00334   vtkTetra                          *Tetra;
00335   vtkVoxel                          *Voxel;
00336   vtkHexahedron                     *Hexahedron;
00337   vtkWedge                          *Wedge;
00338   vtkPyramid                        *Pyramid;
00339   vtkPentagonalPrism                *PentagonalPrism;
00340   vtkHexagonalPrism                 *HexagonalPrism;
00341   vtkQuadraticEdge                  *QuadraticEdge;
00342   vtkQuadraticTriangle              *QuadraticTriangle;
00343   vtkQuadraticQuad                  *QuadraticQuad;
00344   vtkQuadraticPolygon               *QuadraticPolygon;
00345   vtkQuadraticTetra                 *QuadraticTetra;
00346   vtkQuadraticHexahedron            *QuadraticHexahedron;
00347   vtkQuadraticWedge                 *QuadraticWedge;
00348   vtkQuadraticPyramid               *QuadraticPyramid;
00349   vtkQuadraticLinearQuad            *QuadraticLinearQuad;
00350   vtkBiQuadraticQuad                *BiQuadraticQuad;
00351   vtkTriQuadraticHexahedron         *TriQuadraticHexahedron;
00352   vtkQuadraticLinearWedge           *QuadraticLinearWedge;
00353   vtkBiQuadraticQuadraticWedge      *BiQuadraticQuadraticWedge;
00354   vtkBiQuadraticQuadraticHexahedron *BiQuadraticQuadraticHexahedron;
00355   vtkBiQuadraticTriangle            *BiQuadraticTriangle;
00356   vtkCubicLine                      *CubicLine;
00357   vtkConvexPointSet                 *ConvexPointSet;
00358   vtkPolyhedron                     *Polyhedron;
00359   vtkEmptyCell                      *EmptyCell;
00360 
00361   // points inherited
00362   // point data (i.e., scalars, vectors, normals, tcoords) inherited
00363   vtkCellArray *Connectivity;
00364   vtkCellLinks *Links;
00365   vtkUnsignedCharArray *Types;
00366   vtkIdTypeArray *Locations;
00367 
00368   // Special support for polyhedra/cells with explicit face representations.
00369   // The Faces class represents polygonal faces using a modified vtkCellArray
00370   // structure. Each cell face list begins with the total number of faces in
00371   // the cell, followed by a vtkCellArray data organization
00372   // (n,i,j,k,n,i,j,k,...).
00373   vtkIdTypeArray *Faces;
00374   vtkIdTypeArray *FaceLocations;
00375 
00376 private:
00377   // Hide these from the user and the compiler.
00378   vtkUnstructuredGrid(const vtkUnstructuredGrid&);  // Not implemented.
00379   void operator=(const vtkUnstructuredGrid&);  // Not implemented.
00380 
00381   void Cleanup();
00382 
00384 
00385   VTK_LEGACY(void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds));
00386 };
00388 
00389 #endif