cgma
TetFacetorTool.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Class         : TetFacetorTool
00003 //
00004 // Filename      : TetFacetorTool.hpp
00005 //
00006 // Purpose       : 3D Delaunay Tesselator.  Given a set of 3D points, will define 
00007 //                 a Delaunay tesselation.  Does not currently support boundary 
00008 //                 constraints.  Result will be the convex hull of the points
00009 //
00010 // Description   : TetFacetorTool is a template class that currently accepts 
00011 //                 MeshEntity classes.  Any other data structure that satisfies
00012 //                 the appropriate member functions should also be handled.
00013 //                 see also FacetorTool  
00014 //
00015 //                 Following is the list of required members of the TET and 
00016 //                 NODE classes to use this template
00017 //                 
00018 //                 TET: add_TD, get_TD, tet_nodes, get_connected_tet, 
00019 //                      new, delete
00020 //                 NODE: number_edges, coordinates, add_tet, remove_tet
00021 //                       new, delete
00022 //
00023 // Creator       : Steve Owen
00024 //
00025 // Creation Date : 8/2/2003
00026 //
00027 // Owner         : Steve Owen
00028 //-------------------------------------------------------------------------
00029 
00030 #ifndef TET_FACETOR_TOOL_HPP
00031 #define TET_FACETOR_TOOL_HPP
00032 
00033 //#define DEBUG_TET_FACETOR
00034 
00035 #include "CubitBox.hpp"
00036 
00037 #ifdef DEBUG_TET_FACETOR
00038 #define TET CubitTet
00039 #define SUBTET NodeTet
00040 #define NODE CubitNode
00041 class TET;
00042 class SUBTET;
00043 class NODE;
00044 #else
00045 template<class TET, class SUBTET, class NODE>
00046 #endif 
00047 class TetFacetorTool
00048 {
00049 public:
00050   TetFacetorTool();
00051     // constructor
00052 
00053   ~TetFacetorTool(void);
00054     // destructor
00055 
00056   int initialize(CubitBox &bounding_box);
00057     //- initialize the Delaunay domain with initial tets.  Use if
00058     //- point-by-point insertion will be performed.  (Don't use
00059     //- with tesselate())
00060 
00061   int insert_one_node( NODE *node_ptr );
00062     //- insert a single node into tesselation
00063 
00064   int finish();
00065     //- complete the tesselation - remove bounding box nodes
00066 
00067   int get_tets( std::vector<TET *> &tet_list );
00068     //- retreive the current list of tets 
00069 
00070   TET *get_outside_tet();
00071     //- get one tet that is on the outside of the boundary
00072 
00073   int get_interior_tets( std::vector<TET *> &tet_list );
00074     //- get tets that are not connected to a bounding box node
00075 
00076   int tesselate(std::vector<NODE *> &node_list, std::vector<TET *> &tet_list);
00077     //- given a list of points, form a Delaunay tesselation.  Does
00078     //- initializion and finish (All-in-one function)
00079 
00080   int read_data( const char *filename, std::vector<NODE *>&node_list );
00081     //- read data from a file and create list of NODEs
00082 
00083   int circumsphere( TET *tet_ptr, CubitVector &center, double &radius2 );
00084     // get the circumsphere info for the tet
00085 
00086   int natural_neighbor_tets( CubitVector &xx, std::vector<TET *> &neighbor_tet_list, 
00087                              NODE *&duplicate_node );
00088     // get all tets whose circumsphere contain the point
00089 
00090   int watson_insert( NODE *node_ptr, std::vector<TET *> &neighbor_tet_list );
00091     // insert using Bowyer-Watson algrithm
00092 
00093   double get_tol(){return csTol;}
00094   void set_tol(double tol){csTol=tol;}
00095     // get and set circumsphere comparison tolerance.  csTol is 
00096     // computed by default in create_bbox_tets
00097 
00098 private:
00099 
00100   std::vector<TET *> tetList;
00101     // current set of tets in the set
00102 
00103   TET *lastTet;
00104     // last tet inserted/visited
00105 
00106   int tetVisited;
00107     // flag keeps track current iteration of Delaunay insertion
00108 
00109   CubitBox bBox;
00110     // the bounding box of the nodes
00111 
00112   double csTol;
00113     // circumsphere tolerance
00114 
00115   NODE *boxNodes[8];
00116     // nodes on the bounding box of the tet
00117 
00118   int mDebug;
00119     // debug flag;
00120 
00121   int init_box(std::vector<NODE *> &node_list);
00122     // create the initial tets where all subsequent nodes will be inserted
00123 
00124   int create_bbox_tets();
00125     // create the initial tets for the Delaunay domain.
00126 
00127   int remove_bbox_tets();
00128     // remove the tets at the bounding box
00129 
00130   int is_bbox(NODE *n);
00131     // return if this is a node on the bounding box;
00132 
00133   int insert_nodes( std::vector<NODE *> &node_list );
00134     // insert nodes into existing tesselation
00135 
00136   int locate_point( CubitVector &xx, NODE *&exact_node, TET *&containing_tet );
00137     // return the tet the point is located in.  Do a walking
00138     // algorithm starting from the lastTet.
00139 
00140   int exhaustive_locate_point( CubitVector &xx, NODE *&exact_node, 
00141                                TET *&containing_tet );
00142     // Try all tets in the list (that haven't already been tried)
00143     // This is called only when locate_point fails
00144 
00145   CubitBoolean point_in_circumsphere( TET *adj_tet, CubitVector &xx, 
00146                                      std::vector<TET *> &neighbor_tet_list );
00147     // recursive function, determines if the point is within the
00148     // circumsphere of the given tet and then recurses to its
00149     // neighbors if it is.  Add to the neighbor_tet_list as we go.
00150 
00151   void set_tet_visited( TET *tet_ptr, int new_visit_flag );
00152     // set the tet visited flag
00153 
00154   int tet_visited( TET *tet_ptr  );
00155     // return the visited flag
00156 
00157   double tet_volume( const CubitVector &a, 
00158                      const CubitVector &b, 
00159                      const CubitVector &c, 
00160                      const CubitVector &d );
00161     // compute signed volume of tet
00162   
00163 };
00164 
00165 #ifndef DEBUG_TET_FACETOR
00166 #include "TetFacetorTool.cpp"
00167 #endif
00168 
00169 
00170 #endif // TET_FACETOR_TOOL_HPP
00171 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines