From ded42572e9eb436442c3bbbf3dc0cc4b2f16e11a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 8 Apr 2002 12:12:28 +0000 Subject: [PATCH] Mesh is now templated by a triangulation --- Packages/Mesh_2/Mesh.h | 201 ++++++++++++++++++++------------------- Packages/Mesh_2/viewer.h | 5 +- 2 files changed, 109 insertions(+), 97 deletions(-) diff --git a/Packages/Mesh_2/Mesh.h b/Packages/Mesh_2/Mesh.h index 03d60773c8c..6227ef497fd 100644 --- a/Packages/Mesh_2/Mesh.h +++ b/Packages/Mesh_2/Mesh.h @@ -29,34 +29,43 @@ CGAL_BEGIN_NAMESPACE // }; -template -class Mesh: -public Constrained_Delaunay_triangulation_2 +template +class Mesh: public Tr { public: // QWidget *viewer; - typedef Gt Triangulation_geom_traits; - typedef Tds Triangulation_data_structure; - typedef typename Gt::FT FT; + typedef Tr Triangulation; + typedef typename Triangulation::Geom_traits Geom_traits; + typedef typename Tr::Triangulation_data_structure Tds; + typedef typename Geom_traits::FT FT; typedef FT Length; typedef FT Square_length; - typedef CGAL::Triangulation_2 Tr; - typedef CGAL::Constrained_triangulation_2 Ct; // used for + typedef Tr Ct; + // typedef CGAL::Constrained_triangulation_2 Ct; // used for // special_insert_in_edge TODO: is it necessar? - typedef CGAL::Constrained_Delaunay_triangulation_2 CDt; + typedef Tr CDt; + // typedef CGAL::Constrained_Delaunay_triangulation_2 CDt; // typedef typename CDt::Constraint Constraint; - typedef typename CDt::Vertex Vertex; - typedef typename CDt::Edge Edge; - typedef typename CDt::Face_handle Face_handle; - typedef typename CDt::Vertex_handle Vertex_handle; - typedef typename CDt::Finite_faces_iterator Finite_faces_iterator; + typedef typename Tr::Vertex Vertex; + typedef typename Tr::Edge Edge; + typedef typename Tr::Edge_iterator Edge_iterator; + typedef typename Tr::Edge_circulator Edge_circulator; + typedef typename Tr::Face_handle Face_handle; + typedef typename Tr::Face_iterator Face_iterator; + typedef typename Tr::Face_circulator Face_circulator; + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Vertex_circulator Vertex_circulator; + typedef typename Tr::Vertex_iterator Vertex_iterator; + typedef typename Tr::Finite_faces_iterator Finite_faces_iterator; + + typedef typename Tr::Locate_type Locate_type; typedef std::pair Constrained_edge; - typedef typename Gt::Point_2 Point; + typedef typename Tr::Point Point; typedef std::pair Constraint; typedef std::list List_constraints; @@ -95,9 +104,9 @@ public: - Mesh(/*const Geom_traits& gt=Geom_traits()*/):CDt(/*gt*/){}; + Mesh(/*const Geom_traits& gt=Geom_traits()*/):Tr(/*gt*/){}; - Mesh(List_constraints& lc, const Geom_traits& gt=Geom_traits()):CDt(gt) + Mesh(List_constraints& lc, const Geom_traits& gt=Geom_traits()):Tr(gt) { typename List_constraints::iterator lcit=lc.begin(); for( ; lcit != lc.end(); ++lcit) @@ -108,8 +117,8 @@ public: } template - Mesh(InputIterator first, InputIterator last/*, const Geom_traits& - gt=Gt()*/):CDt(/*gt*/) + Mesh(InputIterator first, InputIterator last, const Geom_traits& + gt=Geom_traits()):Tr(gt) { while(first != last){ insert((*first).first, (*first).second); @@ -265,8 +274,8 @@ bool is_infinite(Edge e) { }; // end of Mesh -template -bool Mesh:: +template +bool Mesh:: find_cluster(Vertex_handle va, Vertex_handle vb, Cluster &c) { // check if vb is in any cluster of va @@ -286,8 +295,8 @@ find_cluster(Vertex_handle va, Vertex_handle vb, Cluster &c) } //the function that writes a file -template -void Mesh:: +template +void Mesh:: write(ostream &f) { int nedges = 0; @@ -312,8 +321,8 @@ write(ostream &f) //the function that reads a file -template -void Mesh:: +template +void Mesh:: read(istream &f) { int nedges = 0; @@ -326,8 +335,8 @@ read(istream &f) } } -template -void Mesh:: +template +void Mesh:: fill_edge_queue() { Edge_iterator ei = edges_begin(); @@ -345,8 +354,8 @@ fill_edge_queue() } //it is necessarry for process_facette_map -template -void Mesh:: +template +void Mesh:: fill_facette_map() { Face_iterator fit = faces_begin(); @@ -365,8 +374,8 @@ fill_facette_map() //is used by process_edge_queue -template -void Mesh:: +template +void Mesh:: process_edge_queue() { while(! c_edge_queue.empty() ) @@ -398,8 +407,8 @@ process_edge_queue() -template -void Mesh:: +template +void Mesh:: process_facette_map() { if(Bad_faces.empty()) @@ -427,8 +436,8 @@ process_facette_map() //this function split all the segments that are encroached -template -void Mesh:: +template +void Mesh:: refine_edge(Vertex_handle va, Vertex_handle vb) { // UPDATE; @@ -461,8 +470,8 @@ refine_edge(Vertex_handle va, Vertex_handle vb) } //split all the bad faces -template -void Mesh:: +template +void Mesh:: refine_face(Face_handle f) { Point pc; @@ -527,8 +536,8 @@ refine_face(Face_handle f) } -template -void Mesh:: +template +void Mesh:: create_clusters() { Vertex_iterator vit = vertices_begin(); @@ -538,8 +547,8 @@ create_clusters() } } -template -void Mesh:: +template +void Mesh:: create_clusters_of_vertex(Vertex_handle v) { // prerequisite: at least too vertices must exist in the triangulation @@ -594,8 +603,8 @@ create_clusters_of_vertex(Vertex_handle v) -template -void Mesh:: +template +void Mesh:: show_clusters() { /* multimap::iterator cmit = cluster_map.begin(); @@ -612,8 +621,8 @@ show_clusters() } //refine the cluster -template -void Mesh:: +template +void Mesh:: cut_cluster(Vertex_handle va, Vertex_handle vb) { Cluster c; @@ -631,8 +640,8 @@ cut_cluster(Vertex_handle va, Vertex_handle vb) //refine the reduced_cluster -template -void Mesh:: +template +void Mesh:: cut_reduced_cluster(Vertex_handle va, Vertex_handle vb) { Cluster c; @@ -648,8 +657,8 @@ cut_reduced_cluster(Vertex_handle va, Vertex_handle vb) //refine the cluster edges -template -void Mesh:: +template +void Mesh:: cut_cluster_edge(Vertex_handle va, Vertex_handle vb) { //seulement les constraints @@ -670,8 +679,8 @@ cut_cluster_edge(Vertex_handle va, Vertex_handle vb) } -template -Mesh::Vertex_handle Mesh:: +template +Mesh::Vertex_handle Mesh:: insert_middle(Vertex_handle va, Vertex_handle vb) { Point midpoint; @@ -681,8 +690,8 @@ insert_middle(Vertex_handle va, Vertex_handle vb) //insert in constraint edge the middle -template -Mesh::Vertex_handle Mesh:: +template +Mesh::Vertex_handle Mesh:: insert_in_c_edge(Vertex_handle va, Vertex_handle vb, Point p) { Face_handle f; @@ -698,8 +707,8 @@ insert_in_c_edge(Vertex_handle va, Vertex_handle vb, Point p) //update the encroached segments list -template -void Mesh:: +template +void Mesh:: update_c_edge_queue(Vertex_handle va, Vertex_handle vb, Vertex_handle vm) { //c_edge_queue.pop_back(); @@ -732,8 +741,8 @@ update_c_edge_queue(Vertex_handle va, Vertex_handle vb, Vertex_handle vm) } -template -void Mesh:: +template +void Mesh:: update_facette_map(Vertex_handle v) { Face_circulator fc = v->incident_faces(); @@ -751,8 +760,8 @@ update_facette_map(Vertex_handle v) //ok -template -void Mesh:: +template +void Mesh:: update_cluster(Vertex_handle va, Vertex_handle vb, Vertex_handle vm) { multimap::iterator it_va_cluster = @@ -791,9 +800,9 @@ update_cluster(Vertex_handle va, Vertex_handle vb, Vertex_handle vm) } } -template -inline Mesh::Edge -Mesh::edge_between(Vertex_handle va, Vertex_handle vb) { +template +inline Mesh::Edge +Mesh::edge_between(Vertex_handle va, Vertex_handle vb) { Edge_circulator ec = va->incident_edges(); Edge_circulator ecbegin = ec; do { @@ -817,8 +826,8 @@ Mesh::edge_between(Vertex_handle va, Vertex_handle vb) { //CHECK -template -bool Mesh:: +template +bool Mesh:: is_encroached(Vertex_handle va, Vertex_handle vb, Point p) { Point pm=midpoint(va->point(), vb->point()); @@ -830,8 +839,8 @@ is_encroached(Vertex_handle va, Vertex_handle vb, Point p) } -template -bool Mesh:: +template +bool Mesh:: is_encroached(Vertex_handle va, Vertex_handle vb) { Vertex_iterator vi=vertices_begin(); @@ -850,8 +859,8 @@ is_encroached(Vertex_handle va, Vertex_handle vb) } -template -bool Mesh:: +template +bool Mesh:: min_insertion_radius(Vertex_handle v, Cluster &c) { @@ -859,8 +868,8 @@ min_insertion_radius(Vertex_handle v, Cluster &c) //the measure of faces quality -template -bool Mesh:: +template +bool Mesh:: is_bad(Face_handle f) { FT quality = circumradius_to_shortest_edge_ratio(f); @@ -885,8 +894,8 @@ is_bad(Face_handle f) // -template -bool Mesh:: +template +bool Mesh:: is_small_angle(Vertex_handle vleft, Vertex_handle vmiddle, Vertex_handle vright) @@ -905,8 +914,8 @@ is_small_angle(Vertex_handle vleft, // -template -bool Mesh:: +template +bool Mesh:: is_cluster_reduced(const Cluster& c) { return c.status == REDUCED; @@ -914,8 +923,8 @@ is_cluster_reduced(const Cluster& c) -template -bool Mesh:: +template +bool Mesh:: is_cluster(Vertex_handle va, Vertex_handle vb) { // check if vb is in any cluster of va @@ -934,8 +943,8 @@ is_cluster(Vertex_handle va, Vertex_handle vb) } -template -typename Gt::FT Mesh:: +template +typename Mesh::FT Mesh:: shortest_edge_of_cluster(Vertex_handle v, Cluster &cluster) { map::iterator vit = cluster.vertices.begin(); @@ -954,8 +963,8 @@ shortest_edge_of_cluster(Vertex_handle v, Cluster &cluster) } // look if all edges have the same lenght -template -void Mesh:: +template +void Mesh:: check_cluster_status( Cluster& cluster) { Length initl; @@ -983,8 +992,8 @@ check_cluster_status( Cluster& cluster) -template -void Mesh:: +template +void Mesh:: bounds(FT &xmin, FT &ymin, FT &xmax, FT &ymax, FT &xcenter, FT &ycenter) @@ -1009,8 +1018,8 @@ bounds(FT &xmin, FT &ymin, //bounding box -template -void Mesh:: +template +void Mesh:: bounding_box() { @@ -1035,8 +1044,8 @@ bounding_box() //the angle that are between 2 edges from the triangulation -template -typename Gt::FT Mesh:: +template +typename Mesh::FT Mesh:: angle(Vertex_handle vleft, Vertex_handle vmiddle, Vertex_handle vright) { Point @@ -1053,8 +1062,8 @@ angle(Vertex_handle vleft, Vertex_handle vmiddle, Vertex_handle vright) //the shortest edge that are in a triangle -template -typename Gt::FT Mesh:: +template +typename Mesh::FT Mesh:: shortest_edge(Face_handle f) { Point @@ -1072,8 +1081,8 @@ shortest_edge(Face_handle f) //the triangle quality is represented by the //circumradius_to_shortest_edge_ratio value -template -typename Gt::FT Mesh:: +template +typename Mesh::FT Mesh:: circumradius_to_shortest_edge_ratio(Face_handle f) { Point p; @@ -1086,8 +1095,8 @@ circumradius_to_shortest_edge_ratio(Face_handle f) //insertion radius: the definition -template -typename Gt::FT Mesh:: +template +typename Mesh::FT Mesh:: insertion_radius(Vertex_handle v) { Vertex_handle v1 = nearest_incident_vertex(v); @@ -1096,8 +1105,8 @@ insertion_radius(Vertex_handle v) //this function must compute the vertex that are so close to our vertex. -template -Mesh::Vertex_handle Mesh:: +template +Mesh::Vertex_handle Mesh:: nearest_incident_vertex(Vertex_handle v) { Vertex_handle vbegin, vcurrent, vnearest; @@ -1118,8 +1127,8 @@ nearest_incident_vertex(Vertex_handle v) //the mesh refine function -template -void Mesh:: +template +void Mesh:: refine_mesh(/* QWidget *w */) { // viewer = w; diff --git a/Packages/Mesh_2/viewer.h b/Packages/Mesh_2/viewer.h index 34c21199b9a..45b7a279345 100644 --- a/Packages/Mesh_2/viewer.h +++ b/Packages/Mesh_2/viewer.h @@ -77,8 +77,11 @@ typedef K::Line_2 Line; typedef CGAL::Triangulation_vertex_base_2 Vb; typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; +typedef CGAL::Constrained_Delaunay_triangulation_2 Tr; -typedef CGAL::Mesh Msh; + +typedef CGAL::Mesh Msh; class TrViewer : public QWidget { Q_OBJECT