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 "vtkGenericCellTessellator.h" 00051 00052 class vtkTriangleTile; 00053 class vtkTetraTile; 00054 class vtkCellArray; 00055 class vtkDoubleArray; 00056 class vtkGenericEdgeTable; 00057 class vtkGenericSubdivisionErrorMetric; 00058 class vtkGenericAttributeCollection; 00059 class vtkGenericAdaptorCell; 00060 class vtkGenericCellIterator; 00061 class vtkPointData; 00062 class vtkOrderedTriangulator; 00063 class vtkPolygon; 00064 class vtkIdList; 00065 00066 //----------------------------------------------------------------------------- 00067 // 00068 // The tessellation object 00069 class VTK_FILTERING_EXPORT vtkSimpleCellTessellator : public vtkGenericCellTessellator 00070 { 00071 public: 00072 static vtkSimpleCellTessellator *New(); 00073 vtkTypeMacro(vtkSimpleCellTessellator,vtkGenericCellTessellator); 00074 void PrintSelf(ostream& os, vtkIndent indent); 00075 00077 00078 vtkGetObjectMacro(GenericCell, vtkGenericAdaptorCell); 00080 00082 00089 void TessellateFace(vtkGenericAdaptorCell *cell, 00090 vtkGenericAttributeCollection *att, 00091 vtkIdType index, 00092 vtkDoubleArray *points, 00093 vtkCellArray *cellArray, 00094 vtkPointData *internalPd); 00096 00098 00104 void Tessellate(vtkGenericAdaptorCell *cell, 00105 vtkGenericAttributeCollection *att, 00106 vtkDoubleArray *points, 00107 vtkCellArray *cellArray, 00108 vtkPointData *internalPd ); 00110 00112 00118 void Triangulate(vtkGenericAdaptorCell *cell, 00119 vtkGenericAttributeCollection *att, 00120 vtkDoubleArray *points, 00121 vtkCellArray *cellArray, 00122 vtkPointData *internalPd); 00124 00126 void Reset(); 00127 00128 00130 void Initialize(vtkGenericDataSet *ds); 00131 00141 int GetFixedSubdivisions(); 00142 00149 int GetMaxSubdivisionLevel(); 00150 00153 int GetMaxAdaptiveSubdivisions(); 00154 00159 void SetFixedSubdivisions(int level); 00160 00165 void SetMaxSubdivisionLevel(int level); 00166 00168 00174 void SetSubdivisionLevels(int fixed, 00175 int maxLevel); 00177 00178 00179 protected: 00180 vtkSimpleCellTessellator(); 00181 ~vtkSimpleCellTessellator(); 00182 00185 void CopyPoint(vtkIdType pointId); 00186 00188 vtkGenericEdgeTable *EdgeTable; 00189 00190 void InsertEdgesIntoEdgeTable( vtkTriangleTile &tri ); 00191 void RemoveEdgesFromEdgeTable( vtkTriangleTile &tri ); 00192 void InsertPointsIntoEdgeTable( vtkTriangleTile &tri ); 00193 00194 void InsertEdgesIntoEdgeTable( vtkTetraTile &tetra ); 00195 void RemoveEdgesFromEdgeTable( vtkTetraTile &tetra ); 00196 00198 00208 void InitTetraTile(vtkTetraTile &root, 00209 vtkIdType *localIds, 00210 vtkIdType *ids, 00211 int *edgeIds, 00212 int *faceIds); 00214 00216 00225 void TriangulateTriangle(vtkGenericAdaptorCell *cell, 00226 vtkIdType *localIds, 00227 vtkIdType *ids, 00228 int *edgeIds, 00229 vtkGenericAttributeCollection *att, 00230 vtkDoubleArray *points, 00231 vtkCellArray *cellArray, 00232 vtkPointData *internalPd); 00234 00236 vtkGenericAdaptorCell *GenericCell; 00237 00240 void AllocateScalars(int size); 00241 00246 // Scalar buffer that stores the global coordinates, parametric coordinates, 00247 // attributes at left, mid and right point. The format is: 00248 // lxlylz lrlslt [lalb lcldle...] mxmymz mrmsmt [mamb mcmdme...] 00249 // rxryrz rrrsrt [rarb rcrdre...] 00250 // The ScalarsCapacity>=(6+attributeCollection->GetNumberOfComponents())*3 00251 00252 double *Scalars; 00253 int ScalarsCapacity; 00254 00257 int PointOffset; 00258 00260 vtkGenericCellIterator *CellIterator; 00261 00263 vtkGenericAttributeCollection *AttributeCollection; 00264 00266 00267 vtkDoubleArray *TessellatePoints; //Allow to use GetPointer 00268 vtkCellArray *TessellateCellArray; 00269 vtkPointData *TessellatePointData; 00271 00272 int FindEdgeReferenceCount(double p1[3], double p2[3], 00273 vtkIdType &e1, vtkIdType &e2); 00274 00275 int GetNumberOfCellsUsingFace( int faceId ); 00276 int GetNumberOfCellsUsingEdge( int edgeId ); 00277 00283 int IsEdgeOnFace(double p1[3], double p2[3]); 00284 00290 int FindEdgeParent2D(double p1[3], double p2[3], int &localId); 00291 00298 int FindEdgeParent(double p1[3], double p2[3], int &localId); 00299 00302 void AllocatePointIds(int size); 00303 00305 00308 int FacesAreEqual(int *originalFace, 00309 int face[3]); 00311 00313 vtkGenericDataSet *DataSet; 00314 00316 vtkIdType NumberOfPoints; 00317 00318 int FixedSubdivisions; 00319 int MaxSubdivisionLevel; 00320 int CurrentSubdivisionLevel; 00321 00324 int *EdgeIds; 00327 int *FaceIds; 00328 00329 // The following variables are for complex cells. 00330 00331 // Used to create tetra from more complex cells, because the tessellator 00332 // is supposed to deal with simplices only. 00333 vtkOrderedTriangulator *Triangulator; 00334 00335 // Used to store the sub-tetra during the tessellation of complex 00336 // cells. 00337 vtkCellArray *Connectivity; 00338 00339 // Used to create triangles from a face of a complex cell. 00340 vtkPolygon *Polygon; 00341 00342 // Used to store the sub-triangles during the tessellation of complex cells. 00343 vtkIdList *TriangleIds; 00344 00345 vtkIdType *PointIds; 00346 int PointIdsCapacity; 00347 00348 private: 00349 vtkSimpleCellTessellator(const vtkSimpleCellTessellator&); // Not implemented. 00350 void operator=(const vtkSimpleCellTessellator&); // Not implemented. 00351 00352 //BTX 00353 friend class vtkTetraTile; 00354 friend class vtkTriangleTile; 00355 //ETX 00356 }; 00357 00358 #endif