VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkSimpleCellTessellator.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 __vtkSimpleCellTessellator_h 00048 #define __vtkSimpleCellTessellator_h 00049 00050 #include "vtkCommonDataModelModule.h" // For export macro 00051 #include "vtkGenericCellTessellator.h" 00052 00053 class vtkTriangleTile; 00054 class vtkTetraTile; 00055 class vtkCellArray; 00056 class vtkDoubleArray; 00057 class vtkGenericEdgeTable; 00058 class vtkGenericSubdivisionErrorMetric; 00059 class vtkGenericAttributeCollection; 00060 class vtkGenericAdaptorCell; 00061 class vtkGenericCellIterator; 00062 class vtkPointData; 00063 class vtkOrderedTriangulator; 00064 class vtkPolygon; 00065 class vtkIdList; 00066 00067 //----------------------------------------------------------------------------- 00068 // 00069 // The tessellation object 00070 class VTKCOMMONDATAMODEL_EXPORT vtkSimpleCellTessellator : public vtkGenericCellTessellator 00071 { 00072 public: 00073 static vtkSimpleCellTessellator *New(); 00074 vtkTypeMacro(vtkSimpleCellTessellator,vtkGenericCellTessellator); 00075 void PrintSelf(ostream& os, vtkIndent indent); 00076 00078 00079 vtkGetObjectMacro(GenericCell, vtkGenericAdaptorCell); 00081 00083 00090 void TessellateFace(vtkGenericAdaptorCell *cell, 00091 vtkGenericAttributeCollection *att, 00092 vtkIdType index, 00093 vtkDoubleArray *points, 00094 vtkCellArray *cellArray, 00095 vtkPointData *internalPd); 00097 00099 00105 void Tessellate(vtkGenericAdaptorCell *cell, 00106 vtkGenericAttributeCollection *att, 00107 vtkDoubleArray *points, 00108 vtkCellArray *cellArray, 00109 vtkPointData *internalPd ); 00111 00113 00119 void Triangulate(vtkGenericAdaptorCell *cell, 00120 vtkGenericAttributeCollection *att, 00121 vtkDoubleArray *points, 00122 vtkCellArray *cellArray, 00123 vtkPointData *internalPd); 00125 00127 void Reset(); 00128 00129 00131 void Initialize(vtkGenericDataSet *ds); 00132 00142 int GetFixedSubdivisions(); 00143 00150 int GetMaxSubdivisionLevel(); 00151 00154 int GetMaxAdaptiveSubdivisions(); 00155 00160 void SetFixedSubdivisions(int level); 00161 00166 void SetMaxSubdivisionLevel(int level); 00167 00169 00175 void SetSubdivisionLevels(int fixed, 00176 int maxLevel); 00178 00179 00180 protected: 00181 vtkSimpleCellTessellator(); 00182 ~vtkSimpleCellTessellator(); 00183 00186 void CopyPoint(vtkIdType pointId); 00187 00189 vtkGenericEdgeTable *EdgeTable; 00190 00191 void InsertEdgesIntoEdgeTable( vtkTriangleTile &tri ); 00192 void RemoveEdgesFromEdgeTable( vtkTriangleTile &tri ); 00193 void InsertPointsIntoEdgeTable( vtkTriangleTile &tri ); 00194 00195 void InsertEdgesIntoEdgeTable( vtkTetraTile &tetra ); 00196 void RemoveEdgesFromEdgeTable( vtkTetraTile &tetra ); 00197 00199 00209 void InitTetraTile(vtkTetraTile &root, 00210 vtkIdType *localIds, 00211 vtkIdType *ids, 00212 int *edgeIds, 00213 int *faceIds); 00215 00217 00226 void TriangulateTriangle(vtkGenericAdaptorCell *cell, 00227 vtkIdType *localIds, 00228 vtkIdType *ids, 00229 int *edgeIds, 00230 vtkGenericAttributeCollection *att, 00231 vtkDoubleArray *points, 00232 vtkCellArray *cellArray, 00233 vtkPointData *internalPd); 00235 00237 vtkGenericAdaptorCell *GenericCell; 00238 00241 void AllocateScalars(int size); 00242 00247 // Scalar buffer that stores the global coordinates, parametric coordinates, 00248 // attributes at left, mid and right point. The format is: 00249 // lxlylz lrlslt [lalb lcldle...] mxmymz mrmsmt [mamb mcmdme...] 00250 // rxryrz rrrsrt [rarb rcrdre...] 00251 // The ScalarsCapacity>=(6+attributeCollection->GetNumberOfComponents())*3 00252 00253 double *Scalars; 00254 int ScalarsCapacity; 00255 00258 int PointOffset; 00259 00261 vtkGenericCellIterator *CellIterator; 00262 00264 vtkGenericAttributeCollection *AttributeCollection; 00265 00267 00268 vtkDoubleArray *TessellatePoints; //Allow to use GetPointer 00269 vtkCellArray *TessellateCellArray; 00270 vtkPointData *TessellatePointData; 00272 00273 int FindEdgeReferenceCount(double p1[3], double p2[3], 00274 vtkIdType &e1, vtkIdType &e2); 00275 00276 int GetNumberOfCellsUsingFace( int faceId ); 00277 int GetNumberOfCellsUsingEdge( int edgeId ); 00278 00284 int IsEdgeOnFace(double p1[3], double p2[3]); 00285 00291 int FindEdgeParent2D(double p1[3], double p2[3], int &localId); 00292 00299 int FindEdgeParent(double p1[3], double p2[3], int &localId); 00300 00303 void AllocatePointIds(int size); 00304 00306 00309 int FacesAreEqual(int *originalFace, 00310 int face[3]); 00312 00314 vtkGenericDataSet *DataSet; 00315 00317 vtkIdType NumberOfPoints; 00318 00319 int FixedSubdivisions; 00320 int MaxSubdivisionLevel; 00321 int CurrentSubdivisionLevel; 00322 00325 int *EdgeIds; 00328 int *FaceIds; 00329 00330 // The following variables are for complex cells. 00331 00332 // Used to create tetra from more complex cells, because the tessellator 00333 // is supposed to deal with simplices only. 00334 vtkOrderedTriangulator *Triangulator; 00335 00336 // Used to store the sub-tetra during the tessellation of complex 00337 // cells. 00338 vtkCellArray *Connectivity; 00339 00340 // Used to create triangles from a face of a complex cell. 00341 vtkPolygon *Polygon; 00342 00343 // Used to store the sub-triangles during the tessellation of complex cells. 00344 vtkIdList *TriangleIds; 00345 00346 vtkIdType *PointIds; 00347 int PointIdsCapacity; 00348 00349 private: 00350 vtkSimpleCellTessellator(const vtkSimpleCellTessellator&); // Not implemented. 00351 void operator=(const vtkSimpleCellTessellator&); // Not implemented. 00352 00353 //BTX 00354 friend class vtkTetraTile; 00355 friend class vtkTriangleTile; 00356 //ETX 00357 }; 00358 00359 #endif