VTK
|
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 00107 vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds); 00108 00116 vtkIdType InsertNextCell(int type, vtkIdList *ptIds); 00117 00118 // Desciption: 00119 // Insert/create a polyhedron cell. npts is the number of unique points in 00120 // the cell. pts is the list of the unique cell point Ids. nfaces is the 00121 // number of faces in the cell. faces is the face-stream 00122 // [numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...]. 00123 // All point Ids are global. 00124 // Make sure you have called Allocate() before calling this method 00125 vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds, 00126 vtkIdType nfaces, vtkIdType *faces); 00127 00129 00130 void Reset(); 00131 virtual void CopyStructure(vtkDataSet *ds); 00132 vtkIdType GetNumberOfCells(); 00133 virtual vtkCell *GetCell(vtkIdType cellId); 00134 virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell); 00135 virtual void GetCellBounds(vtkIdType cellId, double bounds[6]); 00136 virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds); 00137 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds); 00138 vtkCellIterator* NewCellIterator(); 00140 00141 int GetCellType(vtkIdType cellId); 00142 vtkUnsignedCharArray* GetCellTypesArray() { return this->Types; } 00143 vtkIdTypeArray* GetCellLocationsArray() { return this->Locations; } 00144 void Squeeze(); 00145 void Initialize(); 00146 int GetMaxCellSize(); 00147 void BuildLinks(); 00148 vtkCellLinks *GetCellLinks() {return this->Links;}; 00149 virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts, 00150 vtkIdType* &pts); 00151 00157 void GetFaceStream(vtkIdType cellId, vtkIdList *ptIds); 00158 00164 void GetFaceStream(vtkIdType cellId, vtkIdType& nfaces, vtkIdType* &ptIds); 00165 00167 00179 void SetCells(int type, vtkCellArray *cells); 00180 void SetCells(int *types, vtkCellArray *cells); 00181 void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations, 00182 vtkCellArray *cells); 00183 void SetCells(vtkUnsignedCharArray *cellTypes, vtkIdTypeArray *cellLocations, 00184 vtkCellArray *cells, vtkIdTypeArray *faceLocations, 00185 vtkIdTypeArray *faces); 00187 00188 vtkCellArray *GetCells() {return this->Connectivity;}; 00189 void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts); 00190 vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts); 00191 void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId); 00192 void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId); 00193 void ResizeCellList(vtkIdType ptId, int size); 00194 00196 00199 virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, 00200 vtkIdList *cellIds); 00202 00204 00206 virtual int GetPiece(); 00207 virtual int GetNumberOfPieces(); 00209 00211 virtual int GetGhostLevel(); 00212 00218 unsigned long GetActualMemorySize(); 00219 00221 00222 virtual void ShallowCopy(vtkDataObject *src); 00223 virtual void DeepCopy(vtkDataObject *src); 00225 00229 void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array); 00230 00232 int IsHomogeneous(); 00233 00236 void RemoveGhostCells(int level); 00237 00238 //BTX 00240 00241 static vtkUnstructuredGrid* GetData(vtkInformation* info); 00242 static vtkUnstructuredGrid* GetData(vtkInformationVector* v, int i=0); 00243 //ETX 00245 00247 vtkIdType *GetFaces(vtkIdType cellId); 00248 00250 00251 vtkIdTypeArray* GetFaces(){return this->Faces;}; 00252 vtkIdTypeArray* GetFaceLocations(){return this->FaceLocations;}; 00254 00261 int InitializeFacesRepresentation(vtkIdType numPrevCells); 00262 00264 00273 static void DecomposeAPolyhedronCell(vtkCellArray *polyhedronCellArray, 00274 vtkIdType & nCellpts, 00275 vtkIdType & nCellfaces, 00276 vtkCellArray *cellArray, 00277 vtkIdTypeArray *faces); 00279 00280 static void DecomposeAPolyhedronCell(vtkIdType * polyhedronCellStream, 00281 vtkIdType & nCellpts, 00282 vtkIdType & nCellfaces, 00283 vtkCellArray *cellArray, 00284 vtkIdTypeArray *faces); 00285 00287 00296 static void DecomposeAPolyhedronCell(vtkIdType nCellFaces, 00297 vtkIdType * inFaceStream, 00298 vtkIdType & nCellpts, 00299 vtkCellArray * cellArray, 00300 vtkIdTypeArray * faces); 00302 00304 00308 static void ConvertFaceStreamPointIds(vtkIdList * faceStream, 00309 vtkIdType * idMap); 00311 00313 00317 static void ConvertFaceStreamPointIds(vtkIdType nfaces, 00318 vtkIdType * faceStream, 00319 vtkIdType * idMap); 00321 00322 00323 protected: 00324 vtkUnstructuredGrid(); 00325 ~vtkUnstructuredGrid(); 00326 00327 // used by GetCell method 00328 vtkVertex *Vertex; 00329 vtkPolyVertex *PolyVertex; 00330 vtkLine *Line; 00331 vtkPolyLine *PolyLine; 00332 vtkTriangle *Triangle; 00333 vtkTriangleStrip *TriangleStrip; 00334 vtkPixel *Pixel; 00335 vtkQuad *Quad; 00336 vtkPolygon *Polygon; 00337 vtkTetra *Tetra; 00338 vtkVoxel *Voxel; 00339 vtkHexahedron *Hexahedron; 00340 vtkWedge *Wedge; 00341 vtkPyramid *Pyramid; 00342 vtkPentagonalPrism *PentagonalPrism; 00343 vtkHexagonalPrism *HexagonalPrism; 00344 vtkQuadraticEdge *QuadraticEdge; 00345 vtkQuadraticTriangle *QuadraticTriangle; 00346 vtkQuadraticQuad *QuadraticQuad; 00347 vtkQuadraticPolygon *QuadraticPolygon; 00348 vtkQuadraticTetra *QuadraticTetra; 00349 vtkQuadraticHexahedron *QuadraticHexahedron; 00350 vtkQuadraticWedge *QuadraticWedge; 00351 vtkQuadraticPyramid *QuadraticPyramid; 00352 vtkQuadraticLinearQuad *QuadraticLinearQuad; 00353 vtkBiQuadraticQuad *BiQuadraticQuad; 00354 vtkTriQuadraticHexahedron *TriQuadraticHexahedron; 00355 vtkQuadraticLinearWedge *QuadraticLinearWedge; 00356 vtkBiQuadraticQuadraticWedge *BiQuadraticQuadraticWedge; 00357 vtkBiQuadraticQuadraticHexahedron *BiQuadraticQuadraticHexahedron; 00358 vtkBiQuadraticTriangle *BiQuadraticTriangle; 00359 vtkCubicLine *CubicLine; 00360 vtkConvexPointSet *ConvexPointSet; 00361 vtkPolyhedron *Polyhedron; 00362 vtkEmptyCell *EmptyCell; 00363 00364 // points inherited 00365 // point data (i.e., scalars, vectors, normals, tcoords) inherited 00366 vtkCellArray *Connectivity; 00367 vtkCellLinks *Links; 00368 vtkUnsignedCharArray *Types; 00369 vtkIdTypeArray *Locations; 00370 00371 // Special support for polyhedra/cells with explicit face representations. 00372 // The Faces class represents polygonal faces using a modified vtkCellArray 00373 // structure. Each cell face list begins with the total number of faces in 00374 // the cell, followed by a vtkCellArray data organization 00375 // (n,i,j,k,n,i,j,k,...). 00376 vtkIdTypeArray *Faces; 00377 vtkIdTypeArray *FaceLocations; 00378 00379 private: 00380 // Hide these from the user and the compiler. 00381 vtkUnstructuredGrid(const vtkUnstructuredGrid&); // Not implemented. 00382 void operator=(const vtkUnstructuredGrid&); // Not implemented. 00383 00384 void Cleanup(); 00385 00387 00388 VTK_LEGACY(void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)); 00389 }; 00391 00392 #endif