diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h index 3cfcf3326fd..489bbd963aa 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h @@ -79,7 +79,7 @@ struct Intersect_coplanar_faces_3{ //constructor for intersection of edges. prev and curr are two points on an edge of the first facet (preserving the //orientation of the facet). This edge is intersected by h2 from the second facet. // - //The rational is the following: we first check whether curr and prev are on the same edge. I so we create + //The rational is the following: we first check whether curr and prev are on the same edge. If so we create //an intersection point between two edges. Otherwise, the point is a vertex of the second facet included into //the first facet. // @@ -102,9 +102,25 @@ struct Intersect_coplanar_faces_3{ res.info_2=h2; if (ipt_prev.type_1==ON_VERTEX && next(ipt_prev.info_1, tm1) == ipt_curr.info_1){ - CGAL_assertion(ipt_curr.type_1!=ON_FACE); - res.type_1=ON_EDGE; - res.info_1=ipt_curr.info_1; + if(ipt_curr.type_1!=ON_FACE) + { + res.type_1=ON_EDGE; + res.info_1=ipt_curr.info_1; + } + else + { + CGAL_assertion( ipt_curr.type_2==ON_VERTEX); + res.type_1=ON_FACE; + res.info_1=h1; + res.type_2=ON_VERTEX; + typename Exact_kernel::Collinear_3 is_collinear = Exact_kernel().collinear_3_object(); + if ( !is_collinear(ipt_prev.point,ipt_curr.point,to_exact(get(vpm2,target(res.info_2,tm2)) ) ) ){ + res.info_2=prev(res.info_2,tm2); + CGAL_assertion( is_collinear(ipt_prev.point,ipt_curr.point,to_exact(get(vpm2,target(res.info_2,tm2))) ) ); + } + res.point = to_exact( get(vpm2, target(res.info_2,tm2)) ); + return res; + } } else{ if(ipt_curr.type_1==ON_VERTEX && ipt_prev.info_1 == ipt_curr.info_1){ diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off new file mode 100644 index 00000000000..692c64e5c3d --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off @@ -0,0 +1,6 @@ +OFF +3 1 0 +0 5310 100 +0 5400 100 +0 5310 150 +3 0 2 1 diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off new file mode 100644 index 00000000000..21bb089ace4 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off @@ -0,0 +1,6 @@ +OFF +3 1 0 +0 5375 105 +0 5350 110 +0 5375 110 +3 1 2 0 diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd index a173eef4b20..e7e5fb3547b 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cmd @@ -64,6 +64,7 @@ data-coref/coplanar_triangles/all_cases/deg/tr15-1.off data-coref/coplanar_trian data-coref/coplanar_triangles/all_cases/deg/tr16-1.off data-coref/coplanar_triangles/all_cases/deg/tr16-2.off data-coref/coplanar_triangles/all_cases/deg/tr17-1.off data-coref/coplanar_triangles/all_cases/deg/tr17-2.off data-coref/coplanar_triangles/all_cases/bugreport/tr1-1.off data-coref/coplanar_triangles/all_cases/bugreport/tr1-2.off +data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off data-coref/coplanar_triangles/all_cases/tr1-1.off data-coref/coplanar_triangles/all_cases/tr1-2.off data-coref/coplanar_triangles/all_cases/tr2-1.off data-coref/coplanar_triangles/all_cases/tr2-2.off data-coref/coplanar_triangles/all_cases/tr3-1.off data-coref/coplanar_triangles/all_cases/tr3-2.off