From 6554279e9a254b22da2610eee81a7a07fe73746a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 May 2015 10:21:53 +0200 Subject: [PATCH] fix the test for the dimension of the affine hull of the dual points --- .../dual/halfspace_intersection_3.h | 25 ++++++++----------- .../test_halfspace_intersections.cpp | 3 ++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h index 1f9061d44c2..15cf91f451a 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h @@ -211,31 +211,26 @@ namespace CGAL if (size < 4) return false; - // Collinear + // Look for two non-parallel planes PlaneIterator plane1_it = planes.begin(); - PlaneIterator plane2_it = planes.begin(); - ++plane2_it; + PlaneIterator plane2_it = cpp11::next(planes.begin()); - PlaneIterator plane3_it = planes.end(); - --plane3_it; while (plane2_it != planes.end() && collinear_plane(*plane1_it, *plane2_it)) { ++plane2_it; } - if (plane2_it == planes.end()) { - return false; - } + if (plane2_it == planes.end()) return false; - // Coplanar - while (plane2_it != planes.end() && + PlaneIterator plane3_it = cpp11::next(plane2_it); + + // Look for a triple of planes intersecting in a point + while (plane3_it != planes.end() && coplanar_plane(*plane1_it, *plane2_it, *plane3_it)) { - plane2_it++; + ++plane3_it; } - if (plane2_it == planes.end()) { - return false; - } + if (plane3_it == planes.end()) return false; return true; } @@ -249,7 +244,7 @@ namespace CGAL void halfspace_intersection_3 (PlaneIterator begin, PlaneIterator end, Polyhedron &P, boost::optional const& origin = boost::none) { - // Checks whether the intersection if a polyhedron + // Checks whether the intersection is a polyhedron CGAL_assertion_msg(Convex_hull_3::internal::is_intersection_dim_3(begin, end), "halfspace_intersection_3: intersection not a polyhedron"); // Types diff --git a/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp b/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp index 4a851b6fe29..5c818d20e26 100644 --- a/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp +++ b/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp @@ -16,12 +16,13 @@ int main (void) { // generates supporting planes of the facets of a cube std::vector planes; + planes.push_back( Plane( 1, 0, 0,-1) ); // x= 1 - planes.push_back( Plane(-1, 0, 0,-1) ); // x=-1 planes.push_back( Plane( 0, 1, 0,-1) ); // y= 1 planes.push_back( Plane( 0,-1, 0,-1) ); // y=-1 planes.push_back( Plane( 0, 0, 1,-1) ); // z= 1 planes.push_back( Plane( 0, 0,-1,-1) ); // z=-1 + planes.push_back( Plane(-1, 0, 0,-1) ); // x=-1 // define polyhedron to hold the intersection Polyhedron_3 P1, P2, P3, P4, P5;