Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenricoturri1966 <enricoturri@seznam.cz>2021-05-20 13:53:47 +0300
committerenricoturri1966 <enricoturri@seznam.cz>2021-05-20 13:53:47 +0300
commitf0ef5e409dd15d12efdbe447bc68505ddf1dc802 (patch)
tree68a96fe6df20d8028daec58f9a3915eac57b2a15 /tests/libslic3r
parenta218e0ef1860df6865f0bbcead02a4f1993147ab (diff)
Added unit test for calculation of 2D convex hull of sinking object
Diffstat (limited to 'tests/libslic3r')
-rw-r--r--tests/libslic3r/test_3mf.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/libslic3r/test_3mf.cpp b/tests/libslic3r/test_3mf.cpp
index fb41ef93b..d6d3686d9 100644
--- a/tests/libslic3r/test_3mf.cpp
+++ b/tests/libslic3r/test_3mf.cpp
@@ -85,3 +85,43 @@ SCENARIO("Export+Import geometry to/from 3mf file cycle", "[3mf]") {
}
}
}
+
+SCENARIO("2D convex hull of sinking object", "[3mf]") {
+ GIVEN("model") {
+ // load a model
+ Model model;
+ std::string src_file = std::string(TEST_DATA_DIR) + "/test_3mf/Prusa.stl";
+ load_stl(src_file.c_str(), &model);
+ model.add_default_instances();
+
+ WHEN("model is rotated, scaled and set as sinking") {
+ ModelObject* object = model.objects[0];
+ object->center_around_origin(false);
+
+ // set instance's attitude so that it is rotated, scaled and sinking
+ ModelInstance* instance = object->instances[0];
+ instance->set_rotation(Y, -M_PI / 4.0);
+ instance->set_offset(Vec3d::Zero());
+ instance->set_scaling_factor({ 2.0, 2.0, 2.0 });
+
+ // calculate 2D convex hull
+ Polygon hull_2d = object->convex_hull_2d(instance->get_transformation().get_matrix());
+
+ // verify result
+ Points result = {
+ { -4242641, -16299551 },
+ { -4241, -19502998 },
+ { 66824768, -19502998 },
+ { 66824768, 19502998 },
+ { -4244, 19502998 },
+ { -4242640, -8537523 }
+ };
+ bool res = hull_2d.points == result;
+
+ THEN("2D convex hull should match with reference") {
+ REQUIRE(res);
+ }
+ }
+ }
+}
+