VTK
dox/Filtering/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 "vtkPointSet.h"
00036 
00037 class vtkCellArray;
00038 class vtkCellLinks;
00039 class vtkConvexPointSet;
00040 class vtkEmptyCell;
00041 class vtkHexahedron;
00042 class vtkIdList;
00043 class vtkIdTypeArray;
00044 class vtkLine;
00045 class vtkPixel;
00046 class vtkPolyLine;
00047 class vtkPolyVertex;
00048 class vtkPolygon;
00049 class vtkPyramid;
00050 class vtkPentagonalPrism;
00051 class vtkHexagonalPrism;
00052 class vtkQuad;
00053 class vtkQuadraticEdge;
00054 class vtkQuadraticHexahedron;
00055 class vtkQuadraticWedge;
00056 class vtkQuadraticPyramid;
00057 class vtkQuadraticQuad;
00058 class vtkQuadraticTetra;
00059 class vtkQuadraticTriangle;
00060 class vtkTetra;
00061 class vtkTriangle;
00062 class vtkTriangleStrip;
00063 class vtkUnsignedCharArray;
00064 class vtkVertex;
00065 class vtkVoxel;
00066 class vtkWedge;
00067 class vtkTriQuadraticHexahedron;
00068 class vtkQuadraticLinearWedge;
00069 class vtkQuadraticLinearQuad;
00070 class vtkBiQuadraticQuad;
00071 class vtkBiQuadraticQuadraticWedge;
00072 class vtkBiQuadraticQuadraticHexahedron;
00073 class vtkBiQuadraticTriangle;
00074 class vtkCubicLine;
00075 class vtkPolyhedron;
00076 class vtkIdTypeArray;
00077 
00078 class VTK_FILTERING_EXPORT vtkUnstructuredGrid : public vtkPointSet 
00079 {
00080 public:
00081   static vtkUnstructuredGrid *New();
00082 
00083   vtkTypeMacro(vtkUnstructuredGrid,vtkPointSet);
00084   void PrintSelf(ostream& os, vtkIndent indent);
00085 
00087 
00088   int GetDataObjectType() {return VTK_UNSTRUCTURED_GRID;};
00089   virtual void Allocate(vtkIdType numCells=1000, int extSize=1000);
00091   
00100   vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds);
00101   
00108   vtkIdType InsertNextCell(int type, vtkIdList *ptIds);
00109   
00110   // Desciption:
00111   // Insert/create a polyhedron cell. npts is the number of unique points in 
00112   // the cell. pts is the list of the unique cell point Ids. nfaces is the 
00113   // number of faces in the cell. faces is the face-stream 
00114   // [numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...]. 
00115   // All point Ids are global.
00116   vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds, 
00117                            vtkIdType nfaces, vtkIdType *faces);
00118 
00120 
00121   void Reset();
00122   virtual void CopyStructure(vtkDataSet *ds);
00123   vtkIdType GetNumberOfCells();
00124   virtual vtkCell *GetCell(vtkIdType cellId);
00125   virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00126   virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
00127   virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00128   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00130 
00131   int GetCellType(vtkIdType cellId);
00132   vtkUnsignedCharArray* GetCellTypesArray() { return this->Types; }
00133   vtkIdTypeArray* GetCellLocationsArray() { return this->Locations; }
00134   void Squeeze();
00135   void Initialize();
00136   int GetMaxCellSize();
00137   void BuildLinks();
00138   vtkCellLinks *GetCellLinks() {return this->Links;};
00139   virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts,
00140                              vtkIdType* &pts);
00141   
00147   void GetFaceStream(vtkIdType cellId, vtkIdList *ptIds);
00148 
00154   void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType* &ptIds);
00155 
00157 
00169   void SetCells(int type, vtkCellArray *cells);
00170   void SetCells(int *types, vtkCellArray *cells);
00171   void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations, 
00172                 vtkCellArray *cells);
00173   void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations,
00174                 vtkCellArray *cells, vtkIdTypeArray *faceLocations, 
00175                 vtkIdTypeArray *faces);
00177   
00178   vtkCellArray *GetCells() {return this->Connectivity;};
00179   void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
00180   vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00181   void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00182   void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00183   void ResizeCellList(vtkIdType ptId, int size);
00184 
00186 
00189   virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, 
00190                                 vtkIdList *cellIds);
00192 
00196   void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
00197 
00199 
00200   virtual int* GetUpdateExtent();
00201   virtual void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
00202                                int& z0, int& z1);
00203   virtual void GetUpdateExtent(int extent[6]);
00205 
00207 
00209   virtual int GetPiece();
00210   virtual int GetNumberOfPieces();
00212 
00214   virtual int GetGhostLevel();
00215   
00221   unsigned long GetActualMemorySize();
00222     
00224 
00225   virtual void ShallowCopy(vtkDataObject *src);  
00226   virtual void DeepCopy(vtkDataObject *src);
00228 
00232   void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array);
00233 
00235   int IsHomogeneous();
00236 
00239   void RemoveGhostCells(int level);
00240 
00241   //BTX
00243 
00244   static vtkUnstructuredGrid* GetData(vtkInformation* info);
00245   static vtkUnstructuredGrid* GetData(vtkInformationVector* v, int i=0);
00246   //ETX
00248 
00250   vtkIdType      *GetFaces(vtkIdType cellId);
00251 
00253 
00254   vtkIdTypeArray* GetFaces(){return this->Faces;};
00255   vtkIdTypeArray* GetFaceLocations(){return this->FaceLocations;};
00257   
00264   int InitializeFacesRepresentation(vtkIdType numPrevCells);
00265 
00267 
00276   static void DecomposeAPolyhedronCell(vtkCellArray *polyhedronCellArray,
00277                                        vtkIdType & nCellpts,
00278                                        vtkIdType & nCellfaces,
00279                                        vtkCellArray *cellArray,
00280                                        vtkIdTypeArray *faces);
00282 
00283   static void DecomposeAPolyhedronCell(vtkIdType * polyhedronCellStream,
00284                                        vtkIdType & nCellpts,
00285                                        vtkIdType & nCellfaces,
00286                                        vtkCellArray *cellArray,
00287                                        vtkIdTypeArray *faces);
00288 
00290 
00299   static void DecomposeAPolyhedronCell(vtkIdType nCellFaces,
00300                                        vtkIdType * inFaceStream,
00301                                        vtkIdType & nCellpts,
00302                                        vtkCellArray * cellArray,
00303                                        vtkIdTypeArray * faces);
00305 
00307 
00311   static void ConvertFaceStreamPointIds(vtkIdList * faceStream,
00312                                         vtkIdType * idMap);
00314 
00316 
00320   static void ConvertFaceStreamPointIds(vtkIdType nfaces,
00321                                         vtkIdType * faceStream,
00322                                         vtkIdType * idMap);
00324 
00325     
00326 protected:
00327   vtkUnstructuredGrid();
00328   ~vtkUnstructuredGrid();
00329 
00330   // used by GetCell method
00331   vtkVertex                         *Vertex;
00332   vtkPolyVertex                     *PolyVertex;
00333   vtkLine                           *Line;
00334   vtkPolyLine                       *PolyLine;
00335   vtkTriangle                       *Triangle;
00336   vtkTriangleStrip                  *TriangleStrip;
00337   vtkPixel                          *Pixel;
00338   vtkQuad                           *Quad;
00339   vtkPolygon                        *Polygon;
00340   vtkTetra                          *Tetra;
00341   vtkVoxel                          *Voxel;
00342   vtkHexahedron                     *Hexahedron;
00343   vtkWedge                          *Wedge;
00344   vtkPyramid                        *Pyramid;
00345   vtkPentagonalPrism                *PentagonalPrism;
00346   vtkHexagonalPrism                 *HexagonalPrism;
00347   vtkQuadraticEdge                  *QuadraticEdge;
00348   vtkQuadraticTriangle              *QuadraticTriangle;
00349   vtkQuadraticQuad                  *QuadraticQuad;
00350   vtkQuadraticTetra                 *QuadraticTetra;
00351   vtkQuadraticHexahedron            *QuadraticHexahedron;
00352   vtkQuadraticWedge                 *QuadraticWedge;
00353   vtkQuadraticPyramid               *QuadraticPyramid;
00354   vtkQuadraticLinearQuad            *QuadraticLinearQuad;
00355   vtkBiQuadraticQuad                *BiQuadraticQuad;
00356   vtkTriQuadraticHexahedron         *TriQuadraticHexahedron;
00357   vtkQuadraticLinearWedge           *QuadraticLinearWedge;
00358   vtkBiQuadraticQuadraticWedge      *BiQuadraticQuadraticWedge;
00359   vtkBiQuadraticQuadraticHexahedron *BiQuadraticQuadraticHexahedron;
00360   vtkBiQuadraticTriangle            *BiQuadraticTriangle;
00361   vtkCubicLine                      *CubicLine;
00362   vtkConvexPointSet                 *ConvexPointSet;
00363   vtkPolyhedron                     *Polyhedron;
00364   vtkEmptyCell                      *EmptyCell;
00365   
00366   // points inherited
00367   // point data (i.e., scalars, vectors, normals, tcoords) inherited
00368   vtkCellArray *Connectivity;
00369   vtkCellLinks *Links;
00370   vtkUnsignedCharArray *Types;
00371   vtkIdTypeArray *Locations;
00372 
00373   // Special support for polyhedra/cells with explicit face representations.
00374   // The Faces class represents polygonal faces using a modified vtkCellArray
00375   // structure. Each cell face list begins with the total number of faces in
00376   // the cell, followed by a vtkCellArray data organization
00377   // (n,i,j,k,n,i,j,k,...).
00378   vtkIdTypeArray *Faces;
00379   vtkIdTypeArray *FaceLocations;
00380 
00381 private:
00382   // Hide these from the user and the compiler.
00383   vtkUnstructuredGrid(const vtkUnstructuredGrid&);  // Not implemented.
00384   void operator=(const vtkUnstructuredGrid&);  // Not implemented.
00385 
00386   void Cleanup();
00387   
00389 
00390   VTK_LEGACY(void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds));
00391 };
00393 
00394 #endif