From dfa85c2c37297f1d75f4a756a1c5f4ee3a79de67 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 21 May 2021 15:37:25 +0200 Subject: [PATCH] Another attempt to fix unit test for 2D convex hull of sinking object on RasperryPi --- tests/libslic3r/test_3mf.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/libslic3r/test_3mf.cpp b/tests/libslic3r/test_3mf.cpp index e865b1d78..d988deffb 100644 --- a/tests/libslic3r/test_3mf.cpp +++ b/tests/libslic3r/test_3mf.cpp @@ -110,14 +110,18 @@ SCENARIO("2D convex hull of sinking object", "[3mf]") { { -4242640, -8537523 } }; - bool res = hull_2d.points == result; - - std::cout << "hull_2d vertices count: " << hull_2d.points.size() << "\n"; - std::cout << "hull_2d vertices:\n"; - for (size_t i = 0; i < hull_2d.points.size(); ++i) { - std::cout << hull_2d.points[i].x() << ", " << hull_2d.points[i].y() << "\n"; + bool res = hull_2d.points.size() == result.size(); + if (res) { + for (size_t i = 0; i < result.size(); ++i) { + Vec3d hull_p(unscale(hull_2d.points[i].x()), unscale(hull_2d.points[i].y()), 0.0); + Vec3d res_p(unscale(result[i].x()), unscale(result[i].y()), 0.0); + res &= res_p.isApprox(hull_p); + } } + // this does not work on RaspberryPi for float precision problem: the x of 1st vertex ending up being -4242640 instead of -4242641 +// bool res = hull_2d.points == result; + THEN("2D convex hull should match with reference") { REQUIRE(res); }