even more test cases

This commit is contained in:
Laurent Rineau 2023-05-09 12:35:09 +02:00
parent 4a0b1477f9
commit 6325190a73
1 changed files with 106 additions and 70 deletions

View File

@ -36,26 +36,14 @@ void insert(DT& dt, Point_it first, Point_it end) {
dt.insert(*first); dt.insert(*first);
} }
} }
// trick to avoid a conflict with CGAL-5.6
// -> specialization of Output_rep for `CC_iterator` *and* `My`
struct My {};
template <class DSC, bool Const >
class CGAL::Output_rep<CGAL::internal::CC_iterator<DSC, Const>, My > {
protected:
using CC_iterator = CGAL::internal::CC_iterator<DSC, Const>;
using Compact_container = typename CC_iterator::CC;
using Time_stamper = typename Compact_container::Time_stamper;
CC_iterator it;
public:
Output_rep( const CC_iterator it) : it(it) {}
std::ostream& operator()( std::ostream& out) const {
return out << '#' << it->time_stamp();
}
};
auto display_vert(Vertex_handle v) { auto display_vert(Vertex_handle v) {
std::stringstream os; std::stringstream os;
os.precision(17); os.precision(17);
os << CGAL::IO::oformat(v, My()) << "=(" << v->point() << ")"; if(v->time_stamp() == 0) {
os << "inf";
} else {
os << '#' << v->time_stamp() << "=(" << v->point() << ")";
}
return os.str(); return os.str();
}; };
template <typename Simplex> template <typename Simplex>
@ -108,14 +96,14 @@ auto debug_simplex(Simplex simplex) {
static const std::vector<Point_3> bbox_points = static const std::vector<Point_3> bbox_points =
{ {
{ -10.1, -10, -10 }, { -10.1, -10, -10.08 },
{ -10.2, 10, -10 }, { -10.2, 10, -10.07 },
{ 10.3, 10, -10 }, { 10.3, 10, -10.06 },
{ 10.4, -10, -10 }, { 10.4, -10, -10.05 },
{ -10.5, -10, 10 }, { -10.5, -10, 10.04 },
{ -10.6, 10, 10 }, { -10.6, 10, 10.03 },
{ 10.7, 10, 10 }, { 10.7, 10, 10.02 },
{ 10.8, -10, 10 }, { 10.8, -10, 10.01 },
}; };
DT dt; DT dt;
@ -172,57 +160,105 @@ bool test_vfefv(bool with_bbox = false)
bool test_a_simple_tetrahedron() { bool test_a_simple_tetrahedron() {
std::cerr << "## test_a_simple_tetrahedron()\n"; std::cerr << "## test_a_simple_tetrahedron()\n";
DT dt2;
dt2.insert({0, 0, 0});
dt2.insert({1, 0, 0});
dt2.insert({0, 1, 0});
dt2.insert({0, 0, 1});
bool ok = true; bool ok = true;
auto test = [&](Point_3 a, Point_3 b, bool with_bbox, std::string expected_result) { auto test = [&](Point_3 a, Point_3 b, std::string expected_result) {
bool exception_thrown = false; // This test function calls `do_test` with four configurations:
dt.clear(); // - with [ab] and [ba],
dt.insert({0, 0, 0}); // - and with or without a bbox around the central tetrahedron.
dt.insert({1, 0, 0}); dt = dt2;
dt.insert({0, 1, 0}); auto do_test = [&](Point_3 a, Point_3 b, bool with_bbox, std::string expected_result) {
dt.insert({0, 0, 1}); std::cerr << "### Case " << expected_result;
if(with_bbox) insert(dt, bbox_points.begin(), bbox_points.end()); if(with_bbox) std::cerr << " with bbox";
result_string.clear(); std::cerr << '\n';
std::cerr << "### Case " << expected_result; std::cerr << "from (" << a << ") to (" << b << ")\n";
if(with_bbox) std::cerr << " with bbox"; bool exception_thrown = false;
std::cerr << '\n'; result_string.clear();
try { try {
for(auto s: dt.segment_traverser_simplices(a, b)) { for(auto s: dt.segment_traverser_simplices(a, b)) {
visit_simplex(s); visit_simplex(s);
}
} catch(const CGAL::Assertion_exception& e) {
CGAL::get_static_warning_handler()("Assertion", e.expression().c_str(),
e.filename().c_str(),
e.line_number(),
e.message().c_str());
exception_thrown = true;
} }
} catch(const CGAL::Assertion_exception& e) { if(result_string != expected_result || exception_thrown) {
CGAL::get_static_warning_handler()("Assertion", e.expression().c_str(), std::cerr << "test_a_simple_tetrahedron failed on case " << expected_result
e.filename().c_str(), << (with_bbox ? " with bbox\n" : "\n");
e.line_number(), ok = false;
e.message().c_str()); }
exception_thrown = true; if(result_string != expected_result) {
} std::cerr << " result_string is " << result_string << " instead of "
if(result_string != expected_result) { << expected_result << '\n';
std::cerr << "test_a_simple_tetrahedron failed\n"; }
std::cerr << " result_string is " << result_string << " instead of " if(exception_thrown) {
<< expected_result << '\n'; std::cerr << " exception thrown\n";
ok = false; }
} };
if(exception_thrown) { std::string expected_result_reversed{expected_result.rbegin(), expected_result.rend()};
std::cerr << "test_a_simple_tetrahedron failed\n"; do_test(a, b, false, expected_result);
std::cerr << " exception thrown\n"; do_test(b, a, false, expected_result_reversed);
ok = false; std::replace(expected_result.begin(), expected_result.end(), 'I', '3');
} std::replace(expected_result_reversed.begin(), expected_result_reversed.end(), 'I', '3');
insert(dt, bbox_points.begin(), bbox_points.end());
do_test(a, b, true, expected_result);
do_test(b, a, true, expected_result_reversed);
}; };
test({ 0, 0, 0}, { 1, 0, 0}, false, "010"); // queries entering by a vertex and exiting by a vertex, on the line (x,0,0)
test({ 0, 0, 0}, { 2, 0, 0}, false, "010I"); test({ 0, 0, 0}, {.5, 0, 0}, "01");
test({-1, 0, 0}, { 2, 0, 0}, false, "I010I"); test({ 0, 0, 0}, { 1, 0, 0}, "010");
test({ 0, 0, 0}, {.5, .5, 0}, false, "021"); test({ 0, 0, 0}, { 2, 0, 0}, "010I");
test({ 0, 0, 0}, { 1, 1, 0}, false, "021I"); test({-1, 0, 0}, { 2, 0, 0}, "I010I");
test({-1, -1, 0}, { 1, 1, 0}, false, "I021I"); test({-1, 0, 0}, { 1, 0, 0}, "I010");
test({-1, 0, 0}, {.5, 0, 0}, "I01");
test({ 0, 0, 0}, { 1, 0, 0}, true, "010"); // queries entering by a vertex and exiting by an edge, on the line (x,x,0) (y==x)
test({ 0, 0, 0}, { 2, 0, 0}, true, "0103"); test({ 0, 0, 0}, {.2, .2, 0}, "02");
test({-1, 0, 0}, { 2, 0, 0}, true, "30103"); test({ 0, 0, 0}, {.5, .5, 0}, "021");
test({ 0, 0, 0}, {.5, .5, 0}, true, "021"); test({ 0, 0, 0}, { 1, 1, 0}, "021I");
test({ 0, 0, 0}, { 1, 1, 0}, true, "0213"); test({-1, -1, 0}, { 1, 1, 0}, "I021I");
test({-1, -1, 0}, { 1, 1, 0}, true, "30213"); test({-1, -1, 0}, {.5, .5, 0}, "I021");
test({-1, -1, 0}, {.2, .2, 0}, "I02");
// queries entering by a vertex and exiting by a facet, one the line x==y==0.25-0.25z
test({ 0, 0, 1}, { .25, .25, .25}, "03");
test({ 0, 0, 1}, { .25, .25, 0}, "032");
test({ 0, 0, 1}, { .5, .5, -1 }, "032I");
test({-.25,-.25, 2}, { .5, .5, -1 }, "I032I");
test({-.25,-.25, 2}, { .25, .25, 0}, "I032");
test({-.25,-.25, 2}, { .05, .05, .8}, "I03");
// queries entering by an edge and exiting by an edge, on the line (x,.5,0)
test({ 0, .5, 0}, {.2, .5, 0}, "12");
test({ 0, .5, 0}, {.5, .5, 0}, "121");
test({ 0, .5, 0}, { 1, .5, 0}, "121I");
test({-1, .5, 0}, { 1, .5, 0}, "I121I");
test({-1, .5, 0}, {.5, .5, 0}, "I121");
test({-1, .5, 0}, {.2, .5, 0}, "I12");
// 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");
test({ 0, .25, 0}, { .25, 0, .25}, "132");
test({ 0, .25, 0}, { .5 ,-.25, .5 }, "132I");
test({-.5, .75,-.5}, { .5 ,-.25, .5 }, "I132I");
test({-.5, .75,-.5}, { .25, 0, .25}, "I132");
test({-.5, .75,-.5}, { .20, .05, .20}, "I13");
// queries entering by a facet and exiting by a facet, on the line (x,.5-x,.2)
test({ 0, .5, .2}, {.2, .3, .2}, "23");
test({ 0, .5, .2}, {.5, 0, .2}, "232");
test({ 0, .5, .2}, { 1,-.5, .2}, "232I");
test({-1,1.5, .2}, { 1, .5, .2}, "I232I");
test({-1,1.5, .2}, {.5, 0, .2}, "I232");
test({-1,1.5, .2}, {.2, .3, .2}, "I23");
return ok; return ok;
} }