From c37857bd9e9b65c31ec28ed6286b63875e3dcb5c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 11 May 2017 12:43:54 +0200 Subject: [PATCH] really use the GT given as a parameter When the geom_traits given as parameter of `circumcenter` and/or `weighted_circumcenter` was deriving from the cell base GT (first template parameter), the gt was up-casted to the cell base GT, and the function construct_circumcenter_3_object() (or construct_weighted_circumcenter_3_object()) not called on the right geom traits type --> possibly missing the actual input of the function (the robust_circumcenter_traits in Mesh_3) we add a static assert to check at compile time that both geom traits are compatible --- .../include/CGAL/Compact_mesh_cell_base_3.h | 20 ++++++++++++++-- .../CGAL/Delaunay_triangulation_cell_base_3.h | 3 +++ .../CGAL/Regular_triangulation_cell_base_3.h | 23 +++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index fa8ab769dc1..35b99d12fec 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -38,6 +38,9 @@ #include #include +#include +#include + #ifdef CGAL_LINKED_WITH_TBB # include #endif @@ -474,9 +477,18 @@ public: V[3] = v3; } - const Bare_point & - weighted_circumcenter(const Geom_traits& gt = Geom_traits()) const + template + const Bare_point& weighted_circumcenter(const GT_& gt) const { + std::cout << "Point : " << typeid(Bare_point).name() << std::endl; + std::cout << "GT_ : " << typeid(GT_).name() << std::endl; + std::cout << "GT_::Construct_weighted_circumcenter_3 : " + << typeid(GT_::Construct_weighted_circumcenter_3).name() << std::endl; + std::cout << "result_type : " << typeid(GT_::Construct_weighted_circumcenter_3::result_type).name() << std::endl; + + //BOOST_STATIC_ASSERT(boost::is_same::value); + if (circumcenter_ == NULL) { this->try_to_set_circumcenter( new Bare_point(gt.construct_weighted_circumcenter_3_object() @@ -494,6 +506,10 @@ public: return *circumcenter_; } + const Bare_point & weighted_circumcenter() const + { + return weighted_circumcenter(Geom_traits()); + } // Returns the index of the cell of the input complex that contains the cell Subdomain_index subdomain_index() const { return subdomain_index_; } diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_3.h index 18e32ef5aa7..b089c48d9d6 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_3.h @@ -32,6 +32,9 @@ #include #include +#include +#include + namespace CGAL { template < typename GT, typename Cb = Triangulation_ds_cell_base_3<> > diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_cell_base_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_cell_base_3.h index 875cfe6f16e..c334745542f 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_cell_base_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_cell_base_3.h @@ -32,6 +32,9 @@ #include +#include +#include + namespace CGAL { template < typename GT, @@ -121,8 +124,11 @@ public: //note this function is not requested by the RegularTriangulationCellBase_3 //it should be replaced everywhere by weighted_circumcenter() // but remains here for backward compatibility - Point_3 circumcenter(const Geom_traits& gt = Geom_traits()) const + template + Point_3 circumcenter(const GT_& gt) const { + BOOST_STATIC_ASSERT(boost::is_same::value); return gt.construct_weighted_circumcenter_3_object() (this->vertex(0)->point(), this->vertex(1)->point(), @@ -130,8 +136,16 @@ public: this->vertex(3)->point()); } - Point_3 weighted_circumcenter(const Geom_traits& gt = Geom_traits()) const + Point_3 circumcenter() const { + return circumcenter(Geom_traits()); + } + + template + Point_3 weighted_circumcenter(const GT_& gt) const + { + BOOST_STATIC_ASSERT(boost::is_same::value); return gt.construct_weighted_circumcenter_3_object() (this->vertex(0)->point(), this->vertex(1)->point(), @@ -139,6 +153,11 @@ public: this->vertex(3)->point()); } + Point_3 weighted_circumcenter() const + { + return weighted_circumcenter(Geom_traits()); + } + private: Point_container _hidden; };