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 "vtkPointSet.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 vtkQuadraticPyramid;
00058 class vtkQuadraticQuad;
00059 class vtkQuadraticTetra;
00060 class vtkQuadraticTriangle;
00061 class vtkTetra;
00062 class vtkTriangle;
00063 class vtkTriangleStrip;
00064 class vtkUnsignedCharArray;
00065 class vtkVertex;
00066 class vtkVoxel;
00067 class vtkWedge;
00068 class vtkTriQuadraticHexahedron;
00069 class vtkQuadraticLinearWedge;
00070 class vtkQuadraticLinearQuad;
00071 class vtkBiQuadraticQuad;
00072 class vtkBiQuadraticQuadraticWedge;
00073 class vtkBiQuadraticQuadraticHexahedron;
00074 class vtkBiQuadraticTriangle;
00075 class vtkCubicLine;
00076 class vtkPolyhedron;
00077 class vtkIdTypeArray;
00078 
00079 class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGrid : public vtkPointSet
00080 {
00081 public:
00082   static vtkUnstructuredGrid *New();
00083 
00084   vtkTypeMacro(vtkUnstructuredGrid,vtkPointSet);
00085   void PrintSelf(ostream& os, vtkIndent indent);
00086 
00088   int GetDataObjectType() {return VTK_UNSTRUCTURED_GRID;};
00089 
00094   virtual void Allocate(vtkIdType numCells=1000, int extSize=1000);
00095 
00104   vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds);
00105 
00112   vtkIdType InsertNextCell(int type, vtkIdList *ptIds);
00113 
00114   // Desciption:
00115   // Insert/create a polyhedron cell. npts is the number of unique points in
00116   // the cell. pts is the list of the unique cell point Ids. nfaces is the
00117   // number of faces in the cell. faces is the face-stream
00118   // [numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...].
00119   // All point Ids are global.
00120   vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds,
00121                            vtkIdType nfaces, vtkIdType *faces);
00122 
00124 
00125   void Reset();
00126   virtual void CopyStructure(vtkDataSet *ds);
00127   vtkIdType GetNumberOfCells();
00128   virtual vtkCell *GetCell(vtkIdType cellId);
00129   virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00130   virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
00131   virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00132   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00134 
00135   int GetCellType(vtkIdType cellId);
00136   vtkUnsignedCharArray* GetCellTypesArray() { return this->Types; }
00137   vtkIdTypeArray* GetCellLocationsArray() { return this->Locations; }
00138   void Squeeze();
00139   void Initialize();
00140   int GetMaxCellSize();
00141   void BuildLinks();
00142   vtkCellLinks *GetCellLinks() {return this->Links;};
00143   virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts,
00144                              vtkIdType* &pts);
00145 
00151   void GetFaceStream(vtkIdType cellId, vtkIdList *ptIds);
00152 
00158   void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType* &ptIds);
00159 
00161 
00173   void SetCells(int type, vtkCellArray *cells);
00174   void SetCells(int *types, vtkCellArray *cells);
00175   void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations,
00176                 vtkCellArray *cells);
00177   void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations,
00178                 vtkCellArray *cells, vtkIdTypeArray *faceLocations,
00179                 vtkIdTypeArray *faces);
00181 
00182   vtkCellArray *GetCells() {return this->Connectivity;};
00183   void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
00184   vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00185   void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00186   void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00187   void ResizeCellList(vtkIdType ptId, int size);
00188 
00190 
00193   virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00194                                 vtkIdList *cellIds);
00196 
00198 
00200   virtual int GetPiece();
00201   virtual int GetNumberOfPieces();
00203 
00205   virtual int GetGhostLevel();
00206 
00212   unsigned long GetActualMemorySize();
00213 
00215 
00216   virtual void ShallowCopy(vtkDataObject *src);
00217   virtual void DeepCopy(vtkDataObject *src);
00219 
00223   void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array);
00224 
00226   int IsHomogeneous();
00227 
00230   void RemoveGhostCells(int level);
00231 
00232   //BTX
00234 
00235   static vtkUnstructuredGrid* GetData(vtkInformation* info);
00236   static vtkUnstructuredGrid* GetData(vtkInformationVector* v, int i=0);
00237   //ETX
00239 
00241   vtkIdType      *GetFaces(vtkIdType cellId);
00242 
00244 
00245   vtkIdTypeArray* GetFaces(){return this->Faces;};
00246   vtkIdTypeArray* GetFaceLocations(){return this->FaceLocations;};
00248 
00255   int InitializeFacesRepresentation(vtkIdType numPrevCells);
00256 
00258 
00267   static void DecomposeAPolyhedronCell(vtkCellArray *polyhedronCellArray,
00268                                        vtkIdType & nCellpts,
00269                                        vtkIdType & nCellfaces,
00270                                        vtkCellArray *cellArray,
00271                                        vtkIdTypeArray *faces);
00273 
00274   static void DecomposeAPolyhedronCell(vtkIdType * polyhedronCellStream,
00275                                        vtkIdType & nCellpts,
00276                                        vtkIdType & nCellfaces,
00277                                        vtkCellArray *cellArray,
00278                                        vtkIdTypeArray *faces);
00279 
00281 
00290   static void DecomposeAPolyhedronCell(vtkIdType nCellFaces,
00291                                        vtkIdType * inFaceStream,
00292                                        vtkIdType & nCellpts,
00293                                        vtkCellArray * cellArray,
00294                                        vtkIdTypeArray * faces);
00296 
00298 
00302   static void ConvertFaceStreamPointIds(vtkIdList * faceStream,
00303                                         vtkIdType * idMap);
00305 
00307 
00311   static void ConvertFaceStreamPointIds(vtkIdType nfaces,
00312                                         vtkIdType * faceStream,
00313                                         vtkIdType * idMap);
00315 
00316 
00317 protected:
00318   vtkUnstructuredGrid();
00319   ~vtkUnstructuredGrid();
00320 
00321   // used by GetCell method
00322   vtkVertex                         *Vertex;
00323   vtkPolyVertex                     *PolyVertex;
00324   vtkLine                           *Line;
00325   vtkPolyLine                       *PolyLine;
00326   vtkTriangle                       *Triangle;
00327   vtkTriangleStrip                  *TriangleStrip;
00328   vtkPixel                          *Pixel;
00329   vtkQuad                           *Quad;
00330   vtkPolygon                        *Polygon;
00331   vtkTetra                          *Tetra;
00332   vtkVoxel                          *Voxel;
00333   vtkHexahedron                     *Hexahedron;
00334   vtkWedge                          *Wedge;
00335   vtkPyramid                        *Pyramid;
00336   vtkPentagonalPrism                *PentagonalPrism;
00337   vtkHexagonalPrism                 *HexagonalPrism;
00338   vtkQuadraticEdge                  *QuadraticEdge;
00339   vtkQuadraticTriangle              *QuadraticTriangle;
00340   vtkQuadraticQuad                  *QuadraticQuad;
00341   vtkQuadraticTetra                 *QuadraticTetra;
00342   vtkQuadraticHexahedron            *QuadraticHexahedron;
00343   vtkQuadraticWedge                 *QuadraticWedge;
00344   vtkQuadraticPyramid               *QuadraticPyramid;
00345   vtkQuadraticLinearQuad            *QuadraticLinearQuad;
00346   vtkBiQuadraticQuad                *BiQuadraticQuad;
00347   vtkTriQuadraticHexahedron         *TriQuadraticHexahedron;
00348   vtkQuadraticLinearWedge           *QuadraticLinearWedge;
00349   vtkBiQuadraticQuadraticWedge      *BiQuadraticQuadraticWedge;
00350   vtkBiQuadraticQuadraticHexahedron *BiQuadraticQuadraticHexahedron;
00351   vtkBiQuadraticTriangle            *BiQuadraticTriangle;
00352   vtkCubicLine                      *CubicLine;
00353   vtkConvexPointSet                 *ConvexPointSet;
00354   vtkPolyhedron                     *Polyhedron;
00355   vtkEmptyCell                      *EmptyCell;
00356 
00357   // points inherited
00358   // point data (i.e., scalars, vectors, normals, tcoords) inherited
00359   vtkCellArray *Connectivity;
00360   vtkCellLinks *Links;
00361   vtkUnsignedCharArray *Types;
00362   vtkIdTypeArray *Locations;
00363 
00364   // Special support for polyhedra/cells with explicit face representations.
00365   // The Faces class represents polygonal faces using a modified vtkCellArray
00366   // structure. Each cell face list begins with the total number of faces in
00367   // the cell, followed by a vtkCellArray data organization
00368   // (n,i,j,k,n,i,j,k,...).
00369   vtkIdTypeArray *Faces;
00370   vtkIdTypeArray *FaceLocations;
00371 
00372 private:
00373   // Hide these from the user and the compiler.
00374   vtkUnstructuredGrid(const vtkUnstructuredGrid&);  // Not implemented.
00375   void operator=(const vtkUnstructuredGrid&);  // Not implemented.
00376 
00377   void Cleanup();
00378 
00380 
00381   VTK_LEGACY(void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds));
00382 };
00384 
00385 #endif