diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h index 311c397ddfa..270693f2fb9 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Plane_3_intersection.h @@ -97,6 +97,19 @@ intersection( std::vector> neighbor_ids(14, {-1,-1}); + auto add_neighbor = [&neighbor_ids](int i, int j) + { + if (neighbor_ids[i][0] == -1 ) { + neighbor_ids[i][0] = j; + } + else { + if (neighbor_ids[i][0]!=j && neighbor_ids[i][1]==-1) + { + neighbor_ids[i][1] = j; + } + } + }; + int start_id = -1; int solo_id = -1; // for each face of the bbox, we look for intersection of the plane with its edges @@ -155,18 +168,8 @@ intersection( case 2: { if (start_id == -1) start_id = ids[0]; - if (neighbor_ids[ids[0]][0] == -1) { - neighbor_ids[ids[0]][0] = ids[1]; - } - else { - neighbor_ids[ids[0]][1] = ids[1]; - } - if (neighbor_ids[ids[1]][0] == -1) { - neighbor_ids[ids[1]][0] = ids[0]; - } - else { - neighbor_ids[ids[1]][1] = ids[0]; - } + add_neighbor(ids[0], ids[1]); + add_neighbor(ids[1], ids[0]); break; } case 1: diff --git a/Intersections_3/test/Intersections_3/test_intersections_3.cpp b/Intersections_3/test/Intersections_3/test_intersections_3.cpp index 7247a3c472e..ea68b96e871 100644 --- a/Intersections_3/test/Intersections_3/test_intersections_3.cpp +++ b/Intersections_3/test/Intersections_3/test_intersections_3.cpp @@ -907,7 +907,7 @@ struct Test { //edge check_intersection (cub, Pl(P(1,1,1), P(1,2,1), P(1.5,0,0)), - S(P(1,2,1), P(1,1,1))); + S(P(1,1,1), P(1,2,1))); //face @@ -924,6 +924,7 @@ struct Test { assert(p.x() == 1); } res = CGAL::intersection(cub, Pl(P(1,1,1), P(1,2,1), P(2,2,2))); + poly = boost::get >(&*res); assert(poly != nullptr); assert(poly->size() == 4); @@ -940,8 +941,8 @@ struct Test { check_intersection (cub, Pl(P(2, 1.66, 2), P(1.66,2,2), P(2,2,1.66)), - Tr(P(2, 2, 1.66), - P(1.66,2,2), + Tr(P(1.66,2,2), + P(2, 2, 1.66), P(2,1.66,2))); //other edge