fix test case 131I

This commit is contained in:
Laurent Rineau 2023-06-15 16:41:07 +02:00
parent 4f20dc0f44
commit c7130e0c58
2 changed files with 25 additions and 19 deletions

View File

@ -26,6 +26,7 @@
#include <CGAL/Triangulation_vertex_base_3.h>
#include <CGAL/Triangulation_simplex_3.h>
#include <boost/optional.hpp>
// If defined, type casting is done statically,
// reducing type-safety overhead.
@ -913,8 +914,11 @@ public:
_curr_simplex = Simplex_3();//should not be reached
else if (triangulation()->is_infinite(chnext) && is_same_edge(get_edge(), e_exit))
_curr_simplex = chnext;
else
_curr_simplex = shared_facet(get_edge(), e_exit);
else {
auto facet_opt = shared_facet(get_edge(), e_exit);
if(static_cast<bool>(facet_opt)) _curr_simplex = *facet_opt;
else _curr_simplex = shared_cell(get_edge(), e_exit);
}
break;
}
@ -1204,7 +1208,7 @@ private:
&& edge_has_vertex(e1, e2.first->vertex(e2.third));
}
Vertex_handle shared_vertex(const Edge& e1, const Edge& e2) const
std::optional<Vertex_handle> shared_vertex(const Edge& e1, const Edge& e2) const
{
Vertex_handle v1a = e1.first->vertex(e1.second);
Vertex_handle v1b = e1.first->vertex(e1.third);
@ -1215,18 +1219,18 @@ private:
return v1a;
else if (v1b == v2a || v1b == v2b)
return v1b;
std::cerr << "There is no vertex shared by e1 and e2" << std::endl;
CGAL_unreachable();
return Vertex_handle();
else
return {};
}
Facet shared_facet(const Edge& e1, const Edge& e2) const
std::optional<Facet> shared_facet(const Edge& e1, const Edge& e2) const
{
Vertex_handle v2a = e2.first->vertex(e2.second);
Vertex_handle v2b = e2.first->vertex(e2.third);
Vertex_handle sv = shared_vertex(e1, e2);
auto sv_opt = shared_vertex(e1, e2);
if(!sv_opt) return {};
Vertex_handle sv = *sv_opt;
Vertex_handle nsv2 = (sv == v2a) ? v2b : v2a;
typename Tr::Facet_circulator circ
@ -1242,9 +1246,7 @@ private:
}
} while (++circ != end);
std::cerr << "There is no facet shared by e1 and e2" << std::endl;
CGAL_unreachable();
return Facet(Cell_handle(), 0);
return {};
}
Facet shared_facet(const Edge& e, const Vertex_handle v) const
@ -1295,6 +1297,11 @@ private:
}
}
Cell_handle shared_cell(const Edge e1, const Edge e2) const {
auto facet = shared_facet(e1, e2.first->vertex(e2.second));
return shared_cell(facet, e2.first->vertex(e2.third));
}
};//class Triangulation_segment_simplex_iterator_3
} // namespace CGAL

View File

@ -373,18 +373,17 @@ bool test_a_simple_tetrahedron() {
test({-.1, .5, 0}, {.5 , .5, 0}, "I121");
test({-.1, .5, 0}, {.25, .5, 0}, "I12");
// x [130] (entering by an edge and exiting by a non-incident vertex) is not possible
// because that would have passed by the common face -> see [120] ([021] in reverse)
// [131] entering by an edge and exiting by the opposite edge in the cell,
// on the line x==y==0.5-z, also known as (.5-z, .5-z, z)
test({ 0, 0, .5 }, { .25, .25, .25}, "13");
test({ 0, 0, .5 }, { .5, .5, 0 }, "131");
test({ 0, 0, .5 }, { .55, .55, -.05}, "131I");
test({ -.05, -.05, .55}, { .55, .55, -.05}, "I131I");
test({ -.05, -.05, .55}, { .5 , .5 , 0 }, "I131");
test({ -.05, -.05, .55}, { .2 , .2 , .3 }, "I13");
test({ 0, 0, .5 }, { .25, .25, .25 }, "13");
test({ 0, 0, .5 }, { .5, .5, 0 }, "131");
test({ 0, 0, .5 }, { .625, .625, -.125}, "131I");
test({ -.05, -.05, .55}, { .625, .625, -.125}, "I131I");
test({ -.05, -.05, .55}, { .5 , .5 , 0 }, "I131");
test({ -.05, -.05, .55}, { .25, .25, .25 }, "I13");
// [132] queries entering by an edge and exiting by a facet, on the line (x, .25-x, x)
test({ 0, .25, 0}, { .20, .05, .20}, "13");