From ef262c9d24d433b67300fc40ea12e35fc9ae64bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 14 Apr 2017 16:53:18 +0200 Subject: [PATCH] Fixed Bare_point / Weighted_point usage in Triangulation_2 --- .../include/CGAL/Regular_traits_adaptor_2.h | 19 +++++------------- .../include/CGAL/Regular_triangulation_2.h | 4 ++++ .../include/CGAL/Triangulation_hierarchy_2.h | 20 +++++++++++++------ .../CGAL/_test_cls_regular_triangulation_2.h | 13 +++++++----- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Triangulation_2/include/CGAL/Regular_traits_adaptor_2.h b/Triangulation_2/include/CGAL/Regular_traits_adaptor_2.h index 93c39899d26..80e736ce748 100644 --- a/Triangulation_2/include/CGAL/Regular_traits_adaptor_2.h +++ b/Triangulation_2/include/CGAL/Regular_traits_adaptor_2.h @@ -27,9 +27,7 @@ #include -#include #include -#include namespace CGAL { @@ -43,19 +41,12 @@ class Regular_traits_adaptor_2 typedef Functor_ Functor; typedef typename RTraits::FT FT; -#if 0 - typedef typename boost::mpl::eval_if_c< - internal::Has_nested_type_Bare_point::value, - typename internal::Bare_point_type, - boost::mpl::identity - >::type Point_2; -#else - typedef typename RTT::Point_2 Point_2; -#endif - typedef typename RTraits::Triangle_2 Triangle_2; - typedef typename RTraits::Segment_2 Segment_2; + typedef typename RTraits::Triangle_2 Triangle_2; + typedef typename RTraits::Segment_2 Segment_2; typedef typename RTraits::Circle_2 Circle_2; - typedef typename RTraits::Weighted_point_2 Weighted_point_2; + + typedef typename RTT::Point_2 Point_2; + typedef typename RTT::Weighted_point_2 Weighted_point_2; template struct Conv_wp_to_p diff --git a/Triangulation_2/include/CGAL/Regular_triangulation_2.h b/Triangulation_2/include/CGAL/Regular_triangulation_2.h index 46869519512..04c1187f7cb 100644 --- a/Triangulation_2/include/CGAL/Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Regular_triangulation_2.h @@ -191,12 +191,16 @@ public: typedef Self Triangulation; typedef Tds Triangulation_data_structure; typedef internal::RegTraits_2 Geom_traits; + + // Traits are not supposed to define Bare_point, but leaving below + // for backward compatibility typedef typename boost::mpl::eval_if_c< internal::Has_nested_type_Bare_point::value, typename internal::Bare_point_type, boost::mpl::identity >::type Bare_point; typedef typename Gt::Weighted_point_2 Weighted_point; + typedef typename Gt::FT Weight; typedef typename Gt::Construct_weighted_point_2 Construct_weighted_point_2; typedef typename Base::size_type size_type; diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index 99f7fd9d581..a00b6928b31 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -26,12 +26,15 @@ #include +#include #include #include #include #include +#include +#include #include #include #include @@ -52,20 +55,25 @@ class Triangulation_hierarchy_2 public: typedef Tr_ Tr_Base; typedef typename Tr_Base::Geom_traits Geom_traits; - typedef typename Tr_Base::Point Point; // this one may be weighted or not typedef typename Tr_Base::size_type size_type; typedef typename Tr_Base::Vertex_handle Vertex_handle; typedef typename Tr_Base::Face_handle Face_handle; typedef typename Tr_Base::Vertex Vertex; typedef typename Tr_Base::Locate_type Locate_type; typedef typename Tr_Base::Finite_vertices_iterator Finite_vertices_iterator; - //typedef typename Tr_Base::Finite_faces_iterator Finite_faces_iterator; - typedef typename Geom_traits::Point_2 Bare_point; - typedef typename Geom_traits::Weighted_point_2 Weighted_point; - + // this one may be weighted or not + typedef typename Tr_Base::Point Point; - typedef typename Tr_Base::Weighted_tag Weighted_tag; + // If the triangulation has defined the `Bare_point` typename, use it. + typedef typename boost::mpl::eval_if_c< + internal::Has_nested_type_Bare_point::value, + typename internal::Bare_point_type, + boost::mpl::identity + >::type Bare_point; + + typedef typename Geom_traits::Weighted_point_2 Weighted_point; + typedef typename Tr_Base::Weighted_tag Weighted_tag; #ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2 using Tr_Base::geom_traits; diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h index 9322a68f06c..25371b9099b 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h @@ -41,13 +41,16 @@ _test_regular_duality( const Del &T ); template < class Triangulation, class Point, class Face_handle > bool _test_is_to_the_left( const Triangulation &T, - const Point &p, - const Face_handle &f, - const int li) + const Point &p, + const Face_handle &f, + const int li) { + typename Triangulation::Geom_traits::Construct_weighted_point_2 p2wp = + T.geom_traits().construct_weighted_point_2_object(); + return( T.orientation(f->vertex(f->ccw(li))->point(), - f->vertex(f->cw(li))->point(), - typename Triangulation::Weighted_point(p)) == CGAL::LEFT_TURN ); + f->vertex(f->cw(li))->point(), + p2wp(p)) == CGAL::LEFT_TURN ); } template