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
This commit is contained in:
Jane Tournois 2017-05-11 12:43:54 +02:00 committed by Mael Rouxel-Labbé
parent ecd7bbdc3e
commit c37857bd9e
3 changed files with 42 additions and 4 deletions

View File

@ -38,6 +38,9 @@
#include <CGAL/Regular_triangulation_cell_base_3.h> #include <CGAL/Regular_triangulation_cell_base_3.h>
#include <CGAL/Mesh_3/io_signature.h> #include <CGAL/Mesh_3/io_signature.h>
#include <boost/static_assert.hpp>
#include <boost/core/is_same.hpp>
#ifdef CGAL_LINKED_WITH_TBB #ifdef CGAL_LINKED_WITH_TBB
# include <tbb/atomic.h> # include <tbb/atomic.h>
#endif #endif
@ -474,9 +477,18 @@ public:
V[3] = v3; V[3] = v3;
} }
const Bare_point & template<typename GT_>
weighted_circumcenter(const Geom_traits& gt = Geom_traits()) const 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<Bare_point,
// typename GT_::Construct_weighted_circumcenter_3::result_type>::value);
if (circumcenter_ == NULL) { if (circumcenter_ == NULL) {
this->try_to_set_circumcenter( this->try_to_set_circumcenter(
new Bare_point(gt.construct_weighted_circumcenter_3_object() new Bare_point(gt.construct_weighted_circumcenter_3_object()
@ -494,6 +506,10 @@ public:
return *circumcenter_; 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 // Returns the index of the cell of the input complex that contains the cell
Subdomain_index subdomain_index() const { return subdomain_index_; } Subdomain_index subdomain_index() const { return subdomain_index_; }

View File

@ -32,6 +32,9 @@
#include <CGAL/Triangulation_ds_cell_base_3.h> #include <CGAL/Triangulation_ds_cell_base_3.h>
#include <CGAL/Triangulation_cell_base_3.h> #include <CGAL/Triangulation_cell_base_3.h>
#include <boost/core/is_same.hpp>
#include <boost/static_assert.hpp>
namespace CGAL { namespace CGAL {
template < typename GT, typename Cb = Triangulation_ds_cell_base_3<> > template < typename GT, typename Cb = Triangulation_ds_cell_base_3<> >

View File

@ -32,6 +32,9 @@
#include <list> #include <list>
#include <boost/core/is_same.hpp>
#include <boost/static_assert.hpp>
namespace CGAL { namespace CGAL {
template < typename GT, template < typename GT,
@ -121,8 +124,11 @@ public:
//note this function is not requested by the RegularTriangulationCellBase_3 //note this function is not requested by the RegularTriangulationCellBase_3
//it should be replaced everywhere by weighted_circumcenter() //it should be replaced everywhere by weighted_circumcenter()
// but remains here for backward compatibility // but remains here for backward compatibility
Point_3 circumcenter(const Geom_traits& gt = Geom_traits()) const template<typename GT_>
Point_3 circumcenter(const GT_& gt) const
{ {
BOOST_STATIC_ASSERT(boost::is_same<Point_3,
typename GT_::Construct_weighted_circumcenter_3::result_type>::value);
return gt.construct_weighted_circumcenter_3_object() return gt.construct_weighted_circumcenter_3_object()
(this->vertex(0)->point(), (this->vertex(0)->point(),
this->vertex(1)->point(), this->vertex(1)->point(),
@ -130,8 +136,16 @@ public:
this->vertex(3)->point()); this->vertex(3)->point());
} }
Point_3 weighted_circumcenter(const Geom_traits& gt = Geom_traits()) const Point_3 circumcenter() const
{ {
return circumcenter(Geom_traits());
}
template<typename GT_>
Point_3 weighted_circumcenter(const GT_& gt) const
{
BOOST_STATIC_ASSERT(boost::is_same<Point_3,
typename GT_::Construct_weighted_circumcenter_3::result_type>::value);
return gt.construct_weighted_circumcenter_3_object() return gt.construct_weighted_circumcenter_3_object()
(this->vertex(0)->point(), (this->vertex(0)->point(),
this->vertex(1)->point(), this->vertex(1)->point(),
@ -139,6 +153,11 @@ public:
this->vertex(3)->point()); this->vertex(3)->point());
} }
Point_3 weighted_circumcenter() const
{
return weighted_circumcenter(Geom_traits());
}
private: private:
Point_container _hidden; Point_container _hidden;
}; };