From 44d0fa4d6f1683cbcbb31293c6de0b3f2a2a94e1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Apr 2016 09:43:07 +0200 Subject: [PATCH] fix the 2D triangulations --- BGL/examples/BGL_polyhedron_3/CMakeLists.txt | 3 +++ .../include/CGAL/Cartesian/function_objects.h | 9 +++++++++ .../include/CGAL/Homogeneous/function_objects.h | 9 +++++++++ Kernel_23/include/CGAL/Weighted_point_2.h | 2 +- .../include/CGAL/Triangulation_hierarchy_2.h | 17 ++++++++++------- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt index 22f23a37c9f..2ae9344907e 100644 --- a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt +++ b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt @@ -65,8 +65,11 @@ create_single_source_cgal_program( "range.cpp" ) create_single_source_cgal_program( "transform_iterator.cpp" ) +create_single_source_cgal_program( "change.cpp" ) + create_single_source_cgal_program( "copy_polyhedron.cpp" ) + if(OpenMesh_FOUND) target_link_libraries( copy_polyhedron ${OPENMESH_LIBRARIES} ) endif() diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index b01a5395474..c4b904cd63a 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -2932,6 +2932,11 @@ namespace CartesianKernelFunctors { typedef const Point_2& type; }; + template + struct result { + typedef const Point_2& type; + }; + Rep // Point_2 operator()(Return_base_tag, Origin o) const { return Rep(o); } @@ -2962,6 +2967,10 @@ namespace CartesianKernelFunctors { return construct_point_2(x,y); } + const Point_2& + operator()(const Point_2 & p) const + { return p; } + const Point_2& operator()(const Weighted_point_2 & p) const { return p.rep().point(); } diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index e0e71b78b23..c8d332698cb 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -3065,6 +3065,11 @@ namespace HomogeneousKernelFunctors { typedef const Point_2& type; }; + template + struct result { + typedef const Point_2& type; + }; + Rep // Point_2 operator()(Return_base_tag, Origin o) const { return Rep(o); } @@ -3100,6 +3105,10 @@ namespace HomogeneousKernelFunctors { } + const Point_2& + operator()(const Point_2 & p) const + { return p; } + const Point_2& operator()(const Weighted_point_2 & p) const { return p.rep().point(); } diff --git a/Kernel_23/include/CGAL/Weighted_point_2.h b/Kernel_23/include/CGAL/Weighted_point_2.h index ff5f5bd3388..aec5fcb805e 100644 --- a/Kernel_23/include/CGAL/Weighted_point_2.h +++ b/Kernel_23/include/CGAL/Weighted_point_2.h @@ -149,7 +149,7 @@ public: CGAL_kernel_precondition( (i >= 0) || (i <= 2) ); if (i==0) return hx(); if (i==1) return hy(); - return hz(); + return hw(); } typename cpp11::result_of::type diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index 17c0c0f0132..95e29f5882d 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -681,9 +681,12 @@ locate_in_all(const Point& p, Face_handle position; Vertex_handle nearest; int level = Triangulation_hierarchy_2__maxlevel; - typename Geom_traits::Compare_distance_2 + typename Geom_traits::Compare_distance_2 closer = this->geom_traits().compare_distance_2_object(); + typename Geom_traits::Construct_point_2 + construct_point = this->geom_traits().construct_point_2_object(); + // find the highest level with enough vertices that is at the same time 2D while ( (hierarchy[--level]->number_of_vertices() < static_cast (Triangulation_hierarchy_2__minsize )) @@ -706,9 +709,9 @@ locate_in_all(const Point& p, } else if (hierarchy[level]->is_infinite(position->vertex(1))){ nearest = position->vertex(0); -} else if ( closer(p, - position->vertex(0)->point(), - position->vertex(1)->point()) == SMALLER){ + } else if ( closer(construct_point(p), + construct_point(position->vertex(0)->point()), + construct_point(position->vertex(1)->point())) == SMALLER){ nearest = position->vertex(0); } else{ @@ -716,9 +719,9 @@ locate_in_all(const Point& p, } // compare to vertex 2, but only if the triangulation is 2D, because otherwise vertex(2) is NULL if ( (hierarchy[level]->dimension()==2) && (! hierarchy[level]->is_infinite(position->vertex(2)))){ - if ( closer( p, - position->vertex(2)->point(), - nearest->point()) == SMALLER ){ + if ( closer( construct_point(p), + construct_point(position->vertex(2)->point()), + construct_point(nearest->point())) == SMALLER ){ nearest = position->vertex(2); } }