00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
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 
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   
00247   
00248   
00249   
00250   
00251   
00252   double *Scalars;
00253   int ScalarsCapacity;
00254   
00257   int PointOffset;
00258   
00260   vtkGenericCellIterator    *CellIterator;
00261 
00263   vtkGenericAttributeCollection *AttributeCollection;
00264 
00266 
00267   vtkDoubleArray     *TessellatePoints;  
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   
00323 
00325   int *EdgeIds;
00326   
00327   
00328   
00329   int *FaceIds;
00331   
00332   
00333   
00334   
00335   
00336   vtkOrderedTriangulator *Triangulator;
00337   
00338   
00339   
00340   vtkCellArray *Connectivity;
00341   
00342   
00343   vtkPolygon *Polygon;
00344   
00345   
00346   vtkIdList *TriangleIds;
00347   
00348   vtkIdType *PointIds;
00349   int PointIdsCapacity;
00350   
00351 private:
00352   vtkSimpleCellTessellator(const vtkSimpleCellTessellator&);  
00353   void operator=(const vtkSimpleCellTessellator&);  
00354   
00355   
00356   friend class vtkTetraTile;
00357   friend class vtkTriangleTile;
00358   
00359 };
00360 
00361 #endif