Merge pull request #2891 from sloriot/PMP-handle_deg_tri_self_inter

Handle degenerate faces in self-intersection tests
This commit is contained in:
Laurent Rineau 2018-03-06 16:23:32 +01:00
commit caca4d67de
2 changed files with 29 additions and 5 deletions

View File

@ -244,7 +244,10 @@ self_intersections( const FaceRange& face_range,
* @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters"
*
* @param tmesh the triangulated surface mesh to be checked
* @param out output iterator to be filled with all pairs of non-adjacent faces that intersect
* @param out output iterator to be filled with all pairs of non-adjacent faces that intersect.
In case `tmesh` contains some degenerate faces, for each degenerate face `f` a pair `(f,f)`
will be put in `out` before any other self intersection between non-degenerate faces.
These are the only pairs where degenerate faces will be reported.
* @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
@ -343,10 +346,15 @@ self_intersections( const FaceRange& face_range,
BOOST_FOREACH(face_descriptor f, face_range)
{
boxes.push_back(Box( get(vpmap, target(halfedge(f,tmesh),tmesh)).bbox()
+ get(vpmap, target(next(halfedge(f, tmesh), tmesh), tmesh)).bbox()
+ get(vpmap, target(next(next(halfedge(f, tmesh), tmesh), tmesh), tmesh)).bbox(),
f));
typename boost::property_traits<VertexPointMap>::reference
p = get(vpmap, target(halfedge(f,tmesh),tmesh)),
q = get(vpmap, target(next(halfedge(f, tmesh), tmesh), tmesh)),
r = get(vpmap, target(next(next(halfedge(f, tmesh), tmesh), tmesh), tmesh));
if ( collinear(p, q, r) )
*out++= std::make_pair(f,f);
else
boxes.push_back(Box(p.bbox() + q.bbox() + r.bbox(), f));
}
// generate box pointers
std::vector<const Box*> box_ptr;

View File

@ -115,5 +115,21 @@ int main(int argc, char** argv)
std::cout << "Third test (Epec):" << std::endl;
r += test_self_intersections<Epec>(filename, expected);
// Fourth test ----------------------------------------------------------------
expected = true;
filename = (argc > 7) ? argv[7] : "data_degeneracies/degtri_single.off";
if(argc > 7) {
assert(argc > 8);
std::stringstream ss(argv[8]);
ss >> std::boolalpha >> expected;
assert(!ss.fail());
}
std::cout << "Fourth test (Epic):" << std::endl;
r += test_self_intersections<Epic>(filename, expected);
std::cout << "Fourth test (Epec):" << std::endl;
r += test_self_intersections<Epec>(filename, expected);
return r;
}