From 38c44cf11bd15f8907c8f985ec3f73699e8124c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 5 Jun 2018 13:45:23 +0200 Subject: [PATCH] make sure face index maps are identical when clipping with a plane --- .../CGAL/Polygon_mesh_processing/clip.h | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index 66c45b11b77..ff8fb03e910 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -456,6 +456,26 @@ clip( TriangleMesh& tm, return internal::clip_open_impl(tm, clipper, np_tm, np_c); } +namespace internal{ +template +bool dispatch_clip_call(TriangleMesh& tm, TriangleMesh& clipper, + const NamedParameters& np, Tag_false) +{ + return clip(tm, clipper, + np.face_index_map(get(CGAL::dynamic_face_property_t(), tm)), + parameters::face_index_map(get(CGAL::dynamic_face_property_t(), clipper))); +} + +template +bool dispatch_clip_call(TriangleMesh& tm, TriangleMesh& clipper, + const NamedParameters& np, Tag_true) +{ + return clip(tm, clipper, + np.face_index_map(get(face_index, tm)), + parameters::face_index_map(get(face_index, clipper))); +} +} + /** * \ingroup PMP_corefinement_grp * clips `tm` by keeping the part that is on the negative side of `plane` (side opposite to its normal vector). @@ -478,10 +498,6 @@ clip( TriangleMesh& tm, * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin - * \cgalParamBegin{face_index_map} a property map containing the index of each face of `tm`. - * Note that if the property map is writable, the indices of the faces - * of `tm` will be set after the refining of `tm` with the intersection with `plane`. - * \cgalParamEnd * \cgalParamBegin{new_face_visitor} a class model of `PMPCorefinementNewFaceVisitor` * that is used to track the creation of new faces. * \cgalParamEnd @@ -534,10 +550,13 @@ bool clip( TriangleMesh& tm, default: break; } - return clip(tm, clipper, np, parameters::all_default()); + // dispatch is needed because face index map for tm and clipper have to be of the same time + return internal::dispatch_clip_call(tm, clipper, + np, CGAL::graph_has_property()); } /// \cond SKIP_IN_MANUAL + // convenience overloads template