Merge pull request #3639 from sgiraudot/OTR-Fix_copy_star-GF

OTR: Fix validity of triangulation
This commit is contained in:
Laurent Rineau 2019-02-13 15:38:50 +01:00
commit 5cc356a888
2 changed files with 41 additions and 6 deletions

View File

@ -921,6 +921,22 @@ public:
return true; return true;
} }
bool check_validity_test () const
{
for(Finite_faces_iterator it = Base::finite_faces_begin();
it != Base::finite_faces_end(); it++)
{
typename Traits_::Orientation s
= orientation(it->vertex(0)->point(),
it->vertex(1)->point(),
it->vertex(2)->point());
if (s != LEFT_TURN)
return false;
}
return true;
}
// COLLAPSE // // COLLAPSE //
// (s,a,b) + (s,b,c) -> (s,a,c) + (a,b,c) // (s,a,b) + (s,b,c) -> (s,a,c) + (a,b,c)

View File

@ -606,19 +606,34 @@ public:
ok = copy.make_collapsible(copy_edge, copy_hull.begin(), ok = copy.make_collapsible(copy_edge, copy_hull.begin(),
copy_hull.end(), m_verbose); copy_hull.end(), m_verbose);
if (!ok) { if (!ok) {
// std::cerr << "simulation: failed (make collapsible)" << std::endl; if (m_verbose > 1)
std::cerr << "simulation: failed (make collapsible)" << std::endl;
return false;
}
ok = copy.check_validity_test();
if (!ok) {
if (m_verbose > 1)
std::cerr << "simulation: failed (validity test)" << std::endl;
return false; return false;
} }
} }
ok = copy.check_kernel_test(copy_edge); ok = copy.check_kernel_test(copy_edge);
if (!ok) { if (!ok) {
std::cerr << "simulation: failed (kernel test)" << std::endl; if (m_verbose > 1)
std::cerr << "simulation: failed (kernel test)" << std::endl;
return false; return false;
} }
copy.collapse(copy_edge, m_verbose); copy.collapse(copy_edge, m_verbose);
ok = copy.check_validity_test();
if (!ok) {
if (m_verbose > 1)
std::cerr << "simulation: failed (validity test)" << std::endl;
return false;
}
Sample_vector samples; Sample_vector samples;
m_dt.collect_samples_from_vertex(s, samples, false); m_dt.collect_samples_from_vertex(s, samples, false);
@ -926,6 +941,9 @@ public:
// edge must not be pinned or have cyclic target // edge must not be pinned or have cyclic target
Edge copy_star(const Edge& edge, Triangulation& copy) { Edge copy_star(const Edge& edge, Triangulation& copy) {
copy.tds().clear();
Vertex_handle vinf = copy.tds().create_vertex();
copy.set_infinite_vertex (vinf);
copy.tds().set_dimension(2); copy.tds().set_dimension(2);
copy.infinite_vertex()->pinned() = true; copy.infinite_vertex()->pinned() = true;
@ -944,10 +962,9 @@ public:
{ {
Vertex_handle v = vcirc; Vertex_handle v = vcirc;
CGAL_assertion(v!=m_dt.infinite_vertex()); CGAL_assertion(v!=m_dt.infinite_vertex());
if (cvmap.find(v) == cvmap.end()) { CGAL_assertion (cvmap.find(v) == cvmap.end());
Vertex_handle cv = copy.tds().create_vertex(); Vertex_handle cv = copy.tds().create_vertex();
cvmap[v] = copy_vertex(v, cv); cvmap[v] = copy_vertex(v, cv);
}
} }
// copy faces // copy faces
@ -994,7 +1011,9 @@ public:
{ {
for (unsigned int i = 0; i < 3; ++i) { for (unsigned int i = 0; i < 3; ++i) {
Vertex_handle v0i = f0->vertex(i); Vertex_handle v0i = f0->vertex(i);
CGAL_assertion (vmap.find(v0i) != vmap.end());
Vertex_handle v1i = vmap[v0i]; Vertex_handle v1i = vmap[v0i];
CGAL_assertion (v1i != Vertex_handle());
f1->set_vertex(i, v1i); f1->set_vertex(i, v1i);
v1i->set_face(f1); v1i->set_face(f1);
} }