From 223e3a20b63d7f34bf56a9d76c75f830261f3f4e Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 6 Mar 2017 13:54:29 +0100 Subject: [PATCH] make constructors of Weighted_point explicit and fix compilation errors --- .../include/CGAL/Cartesian/Weighted_point_3.h | 1 + .../CGAL/Homogeneous/Weighted_point_3.h | 1 + .../CGAL/Mesh_3/Mesh_global_optimizer.h | 2 +- Mesh_3/include/CGAL/Mesh_3/Mesher_level.h | 12 ++++-- Mesh_3/include/CGAL/Mesh_3/Odt_move.h | 12 ++++-- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 24 ++++++------ Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 39 ++++++++----------- .../include/CGAL/_test_cls_delaunay_3.h | 3 +- 8 files changed, 51 insertions(+), 43 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h index 847177367ee..377879eb387 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h @@ -53,6 +53,7 @@ public: Weighted_pointC3(const Origin &o) : base(o,0) {} + explicit Weighted_pointC3 (const Point_3 &p) : base(p,0) {} diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h index 6ef318eb682..ffc21663e2c 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h @@ -53,6 +53,7 @@ public: Weighted_pointH3(const Origin &o) : base(o,0) {} + explicit Weighted_pointH3 (const Point_3 &p) : base(p,0) {} diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h index 0dea83b8e84..4241cfcf352 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h @@ -877,7 +877,7 @@ compute_move(const Vertex_handle& v) if ( c3t3_.in_dimension(v) == 2 ) { Bare_point new_position = translate(wp2p(v->point()),move); - move = vector(wp2p(v->point()), helper_.project_on_surface(wp2p(new_position),v)); + move = vector(wp2p(v->point()), helper_.project_on_surface(new_position, v)); } FT local_sq_size = min_circumradius_sq_length(v, incident_cells); diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesher_level.h b/Mesh_3/include/CGAL/Mesh_3/Mesher_level.h index 056dbea272f..96d0f4c9969 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesher_level.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesher_level.h @@ -148,6 +148,8 @@ public: typedef Tr Triangulation; /** Type of point that are inserted into the triangulation. */ typedef typename Triangulation::Point Point; + /** Type of point with no weight */ + typedef typename Triangulation::Geom_traits::Bare_point Bare_point; /** Type of vertex handles that are returns by insertions into the triangulation. */ typedef typename Triangulation::Vertex_handle Vertex_handle; @@ -308,7 +310,7 @@ public: } /** Gives the point that should be inserted to refine the element \c e */ - Point refinement_point(const Element& e) + Bare_point refinement_point(const Element& e) { return derived().refinement_point_impl(e); } @@ -562,7 +564,9 @@ public: Mesher_level_conflict_status try_to_refine_element(Element e, Mesh_visitor visitor) { - const Point& p = this->refinement_point(e); + const Tr& tr = derived().triangulation_ref_impl(); + const Point& p = tr.geom_traits().construct_weighted_point_3_object()( + this->refinement_point(e)); #ifdef CGAL_MESH_3_VERY_VERBOSE std::cerr << "Trying to insert point: " << p << @@ -946,7 +950,9 @@ public: Mesher_level_conflict_status try_to_refine_element(Element e, Mesh_visitor visitor) { - const Point& p = this->refinement_point(e); + const Tr& tr = derived().triangulation_ref_impl(); + const Point& p = tr.geom_traits().construct_weighted_point_3_object()( + this->refinement_point(e)); #ifdef CGAL_MESH_3_VERY_VERBOSE std::cerr << "Trying to insert point: " << p << diff --git a/Mesh_3/include/CGAL/Mesh_3/Odt_move.h b/Mesh_3/include/CGAL/Mesh_3/Odt_move.h index 4f5d34b900a..be835bd121a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Odt_move.h +++ b/Mesh_3/include/CGAL/Mesh_3/Odt_move.h @@ -59,6 +59,8 @@ class Odt_move typedef typename Gt::FT FT; typedef typename Gt::Vector_3 Vector_3; + + typedef typename Gt::Construct_point_3 Construct_point_3; public: typedef SizingField Sizing_field; @@ -81,8 +83,10 @@ public: const Tr& tr = c3t3.triangulation(); Vector_3 move = CGAL::NULL_VECTOR; FT sum_volume(0); - - const Weighted_point& p = v->point(); + + Construct_point_3 cp = + c3t3.triangulation().geom_traits().construct_point_3_object(); + const Bare_point p = cp(v->point()); for ( typename Cell_vector::const_iterator cit = incident_cells.begin() ; cit != incident_cells.end() ; @@ -95,8 +99,8 @@ public: continue; // Get points - Weighted_point circumcenter = tr.dual(cell); - + Bare_point circumcenter = tr.dual(cell); + // Compute move Vector_3 p_circum = vector(p,circumcenter); FT volume = volume_quadrature(cell, tr, sizing_field); diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index e7199d7a5af..e27c8d7bc01 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -334,15 +334,17 @@ public: typedef Container_ Container; // Because we need it in Mesher_level typedef typename Container::Element Container_element; - typedef typename Tr::Point Point; + typedef typename Tr::Weighted_point Weighted_point; typedef typename Tr::Cell Cell; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Criteria::Cell_quality Cell_quality; typedef typename Triangulation_mesher_level_traits_3::Zone Zone; typedef Complex3InTriangulation3 C3T3; +protected: + typedef typename Tr::Geom_traits::Bare_point Bare_point; - +public: // Constructor // For sequential Refine_cells_3(Tr& triangulation, @@ -371,7 +373,7 @@ public: int number_of_bad_elements_impl(); - Point circumcenter_impl(const Cell_handle& cell) const + Bare_point circumcenter_impl(const Cell_handle& cell) const { return r_tr_.dual(cell); } @@ -391,7 +393,7 @@ public: } // Gets the point to insert from the element to refine - Point refinement_point_impl(const Cell_handle& cell) const + Bare_point refinement_point_impl(const Cell_handle& cell) const { this->set_last_vertex_index( r_oracle_.index_from_subdomain_index(cell->subdomain_index()) ); @@ -402,16 +404,16 @@ public: } // Returns the conflicts zone - Zone conflicts_zone_impl(const Point& point + Zone conflicts_zone_impl(const Weighted_point& point , const Cell_handle& cell , bool &facet_is_in_its_cz) const; - Zone conflicts_zone_impl(const Point& point + Zone conflicts_zone_impl(const Weighted_point& point , const Cell_handle& cell , bool &facet_is_in_its_cz , bool &could_lock_zone) const; // Job to do before insertion - void before_insertion_impl(const Cell_handle&, const Point&, Zone& zone) + void before_insertion_impl(const Cell_handle&, const Weighted_point&, Zone& zone) { before_insertion_handle_cells_in_conflict_zone(zone); } @@ -425,7 +427,7 @@ public: #endif // Insertion implementation ; returns the inserted vertex - Vertex_handle insert_impl(const Point& p, const Zone& zone); + Vertex_handle insert_impl(const Weighted_point& p, const Zone& zone); // Updates cells incident to vertex, and add them to queue if needed void update_star(const Vertex_handle& vertex); @@ -757,7 +759,7 @@ number_of_bad_elements_impl() template typename Refine_cells_3::Zone Refine_cells_3:: -conflicts_zone_impl(const Point& point +conflicts_zone_impl(const Weighted_point& point , const Cell_handle& cell , bool &facet_is_in_its_cz) const { @@ -781,7 +783,7 @@ conflicts_zone_impl(const Point& point template typename Refine_cells_3::Zone Refine_cells_3:: -conflicts_zone_impl(const Point& point +conflicts_zone_impl(const Weighted_point& point , const Cell_handle& cell , bool &facet_is_in_its_cz , bool &could_lock_zone @@ -934,7 +936,7 @@ compute_badness(const Cell_handle& cell) template typename Refine_cells_3::Vertex_handle Refine_cells_3:: -insert_impl(const Point& point, +insert_impl(const Weighted_point& point, const Zone& zone) { // TODO: look at this diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 0575e4ed9e2..446c1f90e7a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -276,6 +276,8 @@ class Refine_facets_3_base typedef typename Gt::Segment_3 Segment_3; typedef typename Gt::Ray_3 Ray_3; typedef typename Gt::Line_3 Line_3; +protected: + typedef typename Gt::Bare_point Bare_point; public: Refine_facets_3_base(Tr& tr, Complex3InTriangulation3& c3t3, @@ -290,7 +292,7 @@ public: void scan_triangulation_impl_amendement() const {} /// Gets the point to insert from the element to refine - Point refinement_point_impl(const Facet& facet) const + Bare_point refinement_point_impl(const Facet& facet) const { #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS const Cell_handle c = facet.first; @@ -394,10 +396,9 @@ protected: typedef typename Get_Is_facet_bad::Type Is_facet_bad; typedef typename MeshDomain::Surface_patch_index Surface_patch_index; typedef typename MeshDomain::Index Index; - typedef typename Gt::Bare_point Bare_point; typedef typename boost::optional< - CGAL::cpp11::tuple > + CGAL::cpp11::tuple > Facet_properties; @@ -422,23 +423,20 @@ protected: /// Sets facet f and it's mirror one surface center to point p void set_facet_surface_center(const Facet& f, - const Point& p, + const Bare_point& p, const Index& index) const { - typename Gt::Construct_point_3 cp = - r_tr_.geom_traits().construct_point_3_object(); - const Facet mirror = mirror_facet(f); - f.first->set_facet_surface_center(f.second, cp(p)); - mirror.first->set_facet_surface_center(mirror.second, cp(p)); + f.first->set_facet_surface_center(f.second, p); + mirror.first->set_facet_surface_center(mirror.second, p); f.first->set_facet_surface_center_index(f.second,index); mirror.first->set_facet_surface_center_index(mirror.second,index); } /// Returns facet surface center of \c f - Point get_facet_surface_center(const Facet& f) const + Bare_point get_facet_surface_center(const Facet& f) const { return f.first->get_facet_surface_center(f.second); } @@ -1121,7 +1119,7 @@ number_of_bad_elements_impl() const Surface_patch_index& surface_index = CGAL::cpp11::get<0>(*properties); const Index& surface_center_index = CGAL::cpp11::get<1>(*properties); - const Point& surface_center = CGAL::cpp11::get<2>(*properties); + const Bare_point& surface_center = CGAL::cpp11::get<2>(*properties); // Facet is on surface: set facet properties //set_facet_surface_center(facet, surface_center, surface_center_index); @@ -1306,7 +1304,7 @@ conflicts_zone_impl(const Point& point { const Surface_patch_index& surface_index = CGAL::cpp11::get<0>(*properties); const Index& surface_center_index = CGAL::cpp11::get<1>(*properties); - const Point& surface_center = CGAL::cpp11::get<2>(*properties); + const Bare_point& surface_center = CGAL::cpp11::get<2>(*properties); // Facet is on surface: set facet properties this->set_facet_surface_center(facet, surface_center, surface_center_index); @@ -1368,7 +1366,7 @@ conflicts_zone_impl(const Point& point { const Surface_patch_index& surface_index = CGAL::cpp11::get<0>(*properties); const Index& surface_center_index = CGAL::cpp11::get<1>(*properties); - const Point& surface_center = CGAL::cpp11::get<2>(*properties); + const Bare_point& surface_center = CGAL::cpp11::get<2>(*properties); // Facet is on surface: set facet properties this->set_facet_surface_center(facet, surface_center, surface_center_index); @@ -1542,7 +1540,7 @@ treat_new_facet(Facet& facet) { const Surface_patch_index& surface_index = CGAL::cpp11::get<0>(*properties); const Index& surface_center_index = CGAL::cpp11::get<1>(*properties); - const Point& surface_center = CGAL::cpp11::get<2>(*properties); + const Bare_point& surface_center = CGAL::cpp11::get<2>(*properties); // Facet is on surface: set facet properties set_facet_surface_center(facet, surface_center, surface_center_index); @@ -1718,9 +1716,6 @@ compute_facet_properties(const Facet& facet, r_oracle_.do_intersect_surface_object(); #endif // not CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 - - typedef typename Gt::Bare_point Bare_point; - Cell_handle c = facet.first; int i = facet.second; Cell_handle n = c->neighbor(i); @@ -1762,7 +1757,7 @@ compute_facet_properties(const Facet& facet, #endif // CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 fp = Facet_properties(CGAL::cpp11::make_tuple(*surface, CGAL::cpp11::get<1>(intersect), - Point(CGAL::cpp11::get<0>(intersect)))); + CGAL::cpp11::get<0>(intersect))); } } // If the dual is a ray @@ -1801,7 +1796,7 @@ compute_facet_properties(const Facet& facet, { fp = Facet_properties(CGAL::cpp11::make_tuple(*surface, CGAL::cpp11::get<1>(intersect), - Point(CGAL::cpp11::get<0>(intersect)))); + CGAL::cpp11::get<0>(intersect))); } } } @@ -1821,17 +1816,15 @@ is_facet_encroached(const Facet& facet, typename Gt::Compare_power_distance_3 compare_distance = r_tr_.geom_traits().compare_power_distance_3_object(); - typename Gt::Construct_point_3 cp = - r_tr_.geom_traits().construct_point_3_object(); const Cell_handle& cell = facet.first; const int& facet_index = facet.second; - const Point& center = get_facet_surface_center(facet); + const Bare_point& center = get_facet_surface_center(facet); const Point& reference_point = cell->vertex((facet_index+1)&3)->point(); // facet is encroached if the new point is near from center than // one vertex of the facet - return ( compare_distance(cp(center), reference_point, point) != CGAL::SMALLER ); + return ( compare_distance(center, reference_point, point) != CGAL::SMALLER ); } template diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h index 2c2e05c61d3..e5b9db0d9d4 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h @@ -185,6 +185,7 @@ _test_cls_delaunay_3(const Triangulation &) //typedef typename If::type::Point Point; typedef typename Cls::Point Point; + typedef typename Cls::Geom_traits::Point_3 Bare_point; typedef typename Cls::Segment Segment; typedef typename Cls::Triangle Triangle; @@ -914,7 +915,7 @@ _test_cls_delaunay_3(const Triangulation &) // We only test return types and instantiation, basically. { Cell_handle c = T4.finite_cells_begin(); - Point p = T4.dual(c); + Bare_point p = T4.dual(c); (void)p; Facet f = Facet(c, 2); CGAL::Object o = T4.dual(f);