From a91c0ed052299fd32568223d42b2557da51b2887 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Fri, 14 May 2021 18:17:01 +0100 Subject: [PATCH] Replace implementation with traits --- Nef_3/include/CGAL/Nef_3/bounded_side_3.h | 105 ++++------------------ 1 file changed, 16 insertions(+), 89 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h index 9cd7a5eba2e..691965fac24 100644 --- a/Nef_3/include/CGAL/Nef_3/bounded_side_3.h +++ b/Nef_3/include/CGAL/Nef_3/bounded_side_3.h @@ -18,109 +18,36 @@ #include -#include +#include #include -#include -#include -#include - -#undef CGAL_NEF_DEBUG -#define CGAL_NEF_DEBUG 17 -#include +#include +#include +#include namespace CGAL { -template -Point_2 point_3_get_x_y_point_2(const Point_3& p, const Homogeneous_tag&) { - return( Point_2(p.hx(), p.hy(), p.hw()) ); -} - -template -Point_2 point_3_get_y_z_point_2(const Point_3& p, const Homogeneous_tag&) { - return( Point_2(p.hy(), p.hz(), p.hw()) ); -} - -template -Point_2 point_3_get_z_x_point_2(const Point_3& p, const Homogeneous_tag&) { - return( Point_2(p.hz(), p.hx(), p.hw()) ); -} - -template -Point_2 point_3_get_x_y_point_2(const Point_3& p, const Cartesian_tag&) { - return( Point_2(p.x(), p.y()) ); -} - -template -Point_2 point_3_get_y_z_point_2(const Point_3& p, const Cartesian_tag&) { - return( Point_2(p.y(), p.z()) ); -} - -template -Point_2 point_3_get_z_x_point_2(const Point_3& p, const Cartesian_tag&) { - return( Point_2(p.z(), p.x()) ); -} - -template -Point_2 point_3_get_x_y_point_2(const Point_3& p) { - return point_3_get_x_y_point_2(p,typename R::Kernel_tag()); -} - -template -Point_2 point_3_get_y_z_point_2(const Point_3& p) { - return point_3_get_y_z_point_2(p,typename R::Kernel_tag()); -} - -template -Point_2 point_3_get_z_x_point_2(const Point_3& p) { - return point_3_get_z_x_point_2(p,typename R::Kernel_tag()); -} - template Bounded_side bounded_side_3(IteratorForward first, IteratorForward last, const Point_3& point, - typename R::Plane_3 plane = typename R::Plane_3(0,0,0,0)) { - typedef typename R::Point_2 Point_2; - typedef typename R::Point_3 Point_3; - typedef typename R::Plane_3 Plane_3; + const Plane_3& plane) +{ + typedef typename CGAL::Projection_traits_yz_3 YZ; + typedef typename CGAL::Projection_traits_xz_3 XZ; + typedef typename CGAL::Projection_traits_xy_3 XY; - if(plane == Plane_3(0,0,0,0)) { - // TO TEST: code never tested - IteratorForward p(first); - Point_3 p0(*(p++)); - CGAL_assertion(p != last); - Point_3 p1(*(p++)); - CGAL_assertion(p != last); - Point_3 p2(*(p++)); - plane = Plane_3(p0, p1, p2); - - /* since we just need to project the points to a non-perpendicular plane - we don't need to care about the plane orientation */ - } + CGAL_assertion(!plane.is_degenerate()); typename R::Non_zero_dimension_3 non_zero_dimension_3; int dir = non_zero_dimension_3(plane.orthogonal_vector()); - - CGAL_assertion(!plane.is_degenerate()); - Point_2 (*t)(const Point_3&); - - if(dir == 0){ - t = &point_3_get_y_z_point_2< Point_2, Point_3, R>; - }else if(dir == 1){ - t = &point_3_get_z_x_point_2< Point_2, Point_3, R>; - }else{ - t = &point_3_get_x_y_point_2< Point_2, Point_3, R>; + if(dir == 0) { + return bounded_side_2(first, last, point, YZ()); + } else if(dir == 1) { + return bounded_side_2(first, last, point, XZ()); + } else { + return bounded_side_2(first, last, point, XY()); } - - std::vector< Point_2> points; - CGAL_NEF_TRACEN("facet:"); - for( ; first != last; ++first ) { - CGAL_NEF_TRACEN(t(*first)<<" "<<*first); - points.push_back( t(*first)); - } - Bounded_side side = bounded_side_2( points.begin(), points.end(), t(point)); - return side; } } //namespace CGAL