make sure face index maps are identical when clipping with a plane

This commit is contained in:
Sébastien Loriot 2018-06-05 13:45:23 +02:00
parent 2601581096
commit 38c44cf11b
1 changed files with 24 additions and 5 deletions

View File

@ -456,6 +456,26 @@ clip( TriangleMesh& tm,
return internal::clip_open_impl(tm, clipper, np_tm, np_c);
}
namespace internal{
template <class TriangleMesh, class NamedParameters>
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<std::size_t>(), tm)),
parameters::face_index_map(get(CGAL::dynamic_face_property_t<std::size_t>(), clipper)));
}
template <class TriangleMesh, class NamedParameters>
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<TriangleMesh, CGAL::face_index_t>());
}
/// \cond SKIP_IN_MANUAL
// convenience overloads
template <class TriangleMesh,
class NamedParameters>