beziermesh.h

Go to the documentation of this file.
00001 
00008 #ifndef BEZIERMESH_H
00009 #define BEZIERMESH_H
00010 
00011 #include <iostream>
00012 #include <cstddef>
00013 #include <vector>
00014 #include <queue>
00015 #include <deque>
00016 
00017 #include "beziercomplex.h"
00018 #include "cell.h"
00019 #include "cellcomplex.h"
00020 #include "celltuple.h"
00021 #include "fibonacci_heap.h"
00022 #include "globals.h"
00023 #include "hash_classes.h"
00024 #include "hash_map.h"
00025 #include "hash_set.h"
00026 #include "util.h"
00027 
00028 /* forward declaration */
00029 class BoundaryMesh;
00030 class DataStore;
00031 
00046 class BezierMesh : public BezierComplex {
00047   private:
00053     int orient_edge_triangle(const BezierEdge *e, const BezierTriangle *t) const;
00054     void tri_cps_off_edge(BezierEdge *e, BezierTriangle *t, ControlPoint &cp3, ControlPoint &cp4, ControlPoint &cp5);
00055     void tri_param_to_edge_param(const BezierEdge *e, const BezierTriangle *t,  double& u, double alpha, double beta) const;
00056     void edge_param_to_tri_param(const BezierEdge *e, const BezierTriangle *t,  double u, double &alpha, double &beta) const;
00063     static bool robust_smooth( Point2D poly[], const Point2D &primary, const Point2D &secondary, Point2D &new_pt);
00064     static bool smooth_point( double x_ary[], double y_ary[], const Point2D &p, Point2D &new_pt);
00071 #ifdef false
00072     void reinterpolate(std::list<BezierTriangle*> new_triangles,std::list<GhostTriangle*> old_triangles);
00073 #endif
00074     void reinterpolate(BezierEdge* e, BezierTriangle **newt, GhostTriangle **oldt);
00075     bool interpolant_error(BezierTriangle *t, GhostTriangle **oldt, double alpha, double beta, LinearData &interp_err);
00076     double phi_evaluate(bool *tri_orientation, double alpha, double beta);
00083     int devillers(BezierVertex *v, std::list<BezierVertex*> &link, int stop_degree);
00084     void get_link(BezierTuple start_tup, std::list<BezierVertex*> &link);
00085     int check_bdry_vertex_removal_degeneracies(std::list<BezierVertex*> &link, BezierVertex *v);
00086     double ear_priority(BezierVertex *v, std::list<BezierVertex*>::iterator ear, const std::list<BezierVertex*> &link);
00087     void flip_out_cavity(std::list<BezierEdge*> &cavity, std::list<BezierEdge*> &new_cavity, BezierVertex *vert);
00094     BezierVertex* insert_point(BezierTriangle *t, double alpha, double beta);
00095     BezierVertex* insert_edge_midpoint(BezierEdge *e,double u);
00096     void get_edge_neighbor_cells( BezierEdge *e, BezierVertex* vs[], BezierEdge* es[], BezierTriangle* ts[] );
00097     void split_return_adjacent(BezierEdge *e, std::vector<BezierEdge*> &new_edges);
00098     void split_edge_near_unflippable(BezierEdge *e, std::vector<BezierEdge*> &new_edges );
00105  public:
00106     bool debug_flip(BezierEdge *e);
00107     bool debug_smooth(BezierEdge *e);
00108     void draw_smooth_error(const char *name, BezierEdge *e, Point2D poly[], const Point2D &prim, const Point2D &secd, BezierTriangle* ts[]);
00109     void draw_insert_error(const char* name, BezierTriangle* bt);
00110     void get_smooth_polygon(Point2D poly[], BezierVertex* vs[], BezierEdge* es[]);
00111     void get_flip_polygon(Point2D poly[], BezierVertex* vs[], BezierEdge* es[]);
00114  private:
00120     bool consistency_check_helper(const BezierTriangle *t, const BezierEdge *e,
00121                                   const int p[3]) const;
00122     bool print_check_inverted(const char *message, int expected = 0);
00134     std::vector<BezierTriangle*> sampler;
00135     hashers::hash_map<BezierTriangle*,int> sample_id_map;
00136     BezierTriangle* find_start_triangle(const Point2D &pt);
00137     int locate_point_in_quadratic_triangle(const Point2D&,
00138         BezierTriangle*, BezierTuple&, double& u, double& v);
00139     int locate_point_in_linear_mesh(const Point2D&, BezierTriangle*,
00140         bool allow_cross_bdry, BezierTuple&);
00148     typedef hashers::hash_map<BezierEdge*, double> EdgeLengthMapT;
00150     typedef hashers::hash_map<BezierVertex*, double> BallRadiusMapT;
00152     typedef hashers::hash_set<BezierVertex*> VertexSetT;
00154     typedef FHeap<BezierVertex> CoarsenQueueT;
00156     typedef std::list<BezierVertex*> CoarsenKillListT;
00164     void coarsen_calculate_edge_lengths(EdgeLengthMapT &edge_length);
00165     void coarsen_keep_boundary(double dp_epsilon, VertexSetT &keep);
00166     void coarsen_keep_large_function_angles(double angle_const, double min_area_const, VertexSetT &keep);
00167     void coarsen_approximate_sizing_func(double size_const, double nn_const, CoarsenQueueT &queue, VertexSetT &keep, EdgeLengthMapT &edge_length);
00168     void coarsen_make_lipshitz(double lip_const, CoarsenQueueT &queue, EdgeLengthMapT &edge_length, BallRadiusMapT &radius);
00169     void coarsen_find_verts_to_remove(VertexSetT &keep, EdgeLengthMapT &edge_length, BallRadiusMapT &radius, CoarsenKillListT &tokill);
00170     int  coarsen_remove_verts(CoarsenKillListT &tokill);
00171     void coarsen_draw_debug(VertexSetT &keep, BallRadiusMapT &radius, CoarsenKillListT &tokill);
00174   private:
00175     /* Define copy and assignment constructors as private to prevent thier use */
00176     BezierMesh( const BezierMesh &o);
00177     const BezierMesh& operator=( const BezierMesh &o);
00178 
00179  private:
00180     /* Data members. */
00181     BoundaryMesh *boundarymesh; 
00182     DataStore *datastore; 
00190     bool linear_flips;
00191 
00192 
00193  public:
00197     typedef Vertex_Hash_T Bezier_Vertex_Hash_T;
00199     typedef Edge_Hash_T Bezier_Edge_Hash_T;
00201     typedef Face_Hash_T Bezier_Face_Hash_T;
00205     BezierMesh(PersistantStore&, DataStore*);
00206     void set_bdry_mesh(BoundaryMesh*);
00207 
00209     ~BezierMesh();
00210 
00211     /*Member Functions */
00213     void set_linear_flips(bool val) { linear_flips=val; }
00214 
00226     /* use these to add an interior bezier vertex */
00227     BezierVertex* add_bezier_vertex(const Point2D &p);
00228     BezierVertex* add_bezier_vertex(const Point2D &p,const LinearData &d);
00229 
00230     /* use these to add an bezier vertex on the boundary
00231      * where cp is the cooresponding control point from the
00232      * boundary
00233      */
00234     BezierVertex* add_bezier_vertex(ControlPoint cp);
00235     BezierVertex* add_bezier_vertex(ControlPoint cp,const LinearData &d);
00236 
00237     /* Use these to add an interior edge */
00238     BezierEdge* add_bezier_edge(const Point2D &p, BezierVertex *v0, BezierVertex *v1);
00239     BezierEdge* add_bezier_edge(const Point2D &p,const LinearData &d, BezierVertex *v0, BezierVertex *v1);
00240     BezierEdge* add_straight_bezier_edge(BezierVertex*, BezierVertex*);
00241     BezierEdge* add_straight_bezier_edge(const LinearData&,
00242                                                 BezierVertex*, BezierVertex*);
00243 
00244     /* Use these to add an bezier edge on the boundary
00245      * where cp is the cooresponding control point from the spline
00246      */
00247     BezierEdge* add_bezier_edge(ControlPoint cp, BezierVertex *v0, BezierVertex *v1);
00248     BezierEdge* add_bezier_edge(ControlPoint cp,const LinearData &d, BezierVertex *v0, BezierVertex *v1);
00249 
00250     /* use this too add a new triangle */
00251     BezierTriangle* add_bezier_triangle(BoundaryFace *face,BezierEdge *e0,BezierEdge *e1,BezierEdge *e2, bool inverse_handed=false);
00263     virtual void delete_vertex(BezierVertex *vert);
00264     virtual void delete_edge(BezierEdge *edge);
00265     virtual void delete_face(BezierTriangle *face);
00269     /* Use these to replace the ControlPoints; mostly useful in the
00270      * bootstrapping phase. */
00271     void replace_control_point(BezierVertex*, const ControlPoint& newp);
00272     void replace_control_point(BezierEdge*, const ControlPoint& newp);
00285     BezierVertex* clean_insert_point(Point2D p,
00286                                      BezierTriangle* start_tri = NULL,
00287                                      bool over_bdry = true,
00288                                      bool force = true);
00289     BezierVertex* clean_insert_point(BezierTriangle *t, double alpha,
00290                                      double beta, bool force = false);
00291     BezierVertex* clean_insert_edge_midpoint(BezierEdge *e, double u,
00292                                              bool force = true);
00293     BezierVertex* clean_insert_circumcenter(BezierTriangle *t);
00294     BezierTuple remove_vertex(BezierVertex *v);
00295     bool smooth_edge(BezierEdge *e);
00296     bool flip(BezierEdge *e, BezierTuple &tup);
00301     int blind_locate_point(Point2D pt, BezierTuple&, double &u, double &v);
00302     int locate_point(Point2D pt, BezierTriangle *start_tri, bool over_bdry,
00303                      BezierTuple&, double &u, double &v);
00311     bool should_flip(BezierEdge *e);
00312     bool can_flip(BezierEdge *e);
00313     bool can_flip(BezierEdge *e, bool &is_typeA, bool &is_typeB);
00314     bool can_smooth(BezierEdge *e);
00315     bool should_refine_func_angle(BezierEdge *e, double angle_const, double min_area_const);
00316     double function_angle(BezierEdge *e, double u, int func_idx);
00317     int find_inverted_triangles(std::vector<BezierTriangle*> &inverted);
00318     int classify_inverted_triangles(std::vector<BezierTriangle*> &normal, std::vector<BezierTriangle*> &inverted, std::vector<BezierTriangle*> &unknown);
00322     bool check_consistency() const;
00323 
00329     int smooth_mesh(double jacobian_bound, int passes=1);
00330     int make_delaunay();
00331     int make_delaunay(double angle_const, double min_area_const);
00332     int make_delaunay(std::deque<BezierEdge*> flip_list);
00333     int make_delaunay(std::deque<BezierEdge*> flip_list, double angle_const, double min_area_const);
00334     int protect_boundarys();
00335     int remove_small_angles();
00336     int remove_large_triangles(double size_const);
00337     int function_angle_refine(double angle_const, double size_const);
00338     int coarsen_const_size(double size_const, double lip_const, double nn_const, double dp_epsilon);
00339     int coarsen_func_angle(double size_const, double lip_const, double nn_const, double dp_epsilon, double angle_const, double min_area_const);
00340     int coarsen_func_angle_debug(double size_const, double lip_const, double nn_const, double dp_epsilon, double angle_const, double min_area_const);
00343     /* TODO: make this private! Or an argument of coarsen_func_angle. */
00344     double func_angle_x_cuttoff;
00345 
00349     int data_length() const;
00350 
00351  protected:
00352     friend std::ostream& operator<<( std::ostream &stream, const BezierMesh &bm);
00353 };
00354 #endif /* BEZIERMESH_H */

Generated on Mon May 24 09:53:30 2010 for TUMBLE by  doxygen 1.5.2