Browse Source

Fix failing tests

still the arrange is broken
tamasmeszaros 1 year ago
parent
commit
aea278ab55

+ 4 - 6
src/libslic3r/Arrange/SceneBuilder.cpp

@@ -90,12 +90,10 @@ BoundingBoxf3 instance_bounding_box(const ModelInstance &mi, bool dont_translate
 
 bool check_coord_bounds(const BoundingBoxf &bb)
 {
-    constexpr double hi = 1000.;
-
-    return std::abs(bb.min.x()) < hi &&
-           std::abs(bb.min.y()) < hi &&
-           std::abs(bb.max.x()) < hi &&
-           std::abs(bb.max.y()) < hi;
+    return std::abs(bb.min.x()) < UnscaledCoordLimit &&
+           std::abs(bb.min.y()) < UnscaledCoordLimit &&
+           std::abs(bb.max.x()) < UnscaledCoordLimit &&
+           std::abs(bb.max.y()) < UnscaledCoordLimit;
 }
 
 ExPolygons extract_full_outline(const ModelInstance &inst, const Transform3d &tr)

+ 2 - 0
src/libslic3r/Arrange/SceneBuilder.hpp

@@ -381,6 +381,8 @@ BoundingBoxf3 instance_bounding_box(const ModelInstance &mi,
                                     const Transform3d &tr,
                                     bool dont_translate = false);
 
+constexpr double UnscaledCoordLimit = 1000.;
+
 ExPolygons extract_full_outline(const ModelInstance &inst,
                                 const Transform3d &tr = Transform3d::Identity());
 

+ 4 - 3
tests/arrange/test_arrange_integration.cpp

@@ -49,8 +49,8 @@ static Slic3r::Model get_example_model_with_random_cube_objects(size_t N = 0)
     for (size_t i = 0; i < cube_count; ++i) {
         ModelInstance *inst = new_object->add_instance();
         arr2::transform_instance(*inst,
-                                 Vec2d{random_value(-200., 200.),
-                                       random_value(-200., 200.)},
+                                 Vec2d{random_value(-arr2::UnscaledCoordLimit / 10., arr2::UnscaledCoordLimit / 10.),
+                                       random_value(-arr2::UnscaledCoordLimit / 10., arr2::UnscaledCoordLimit / 10.)},
                                  random_value(0., 2 * PI));
     }
 
@@ -168,7 +168,8 @@ TEMPLATE_TEST_CASE("Writing arrange transformations into ModelInstance should be
 {
     auto [tx, ty, rot] = GENERATE(map(
         [](int i) {
-            return std::make_tuple(-500. + i * 20., -500. + i * 20.,
+            return std::make_tuple(-Slic3r::arr2::UnscaledCoordLimit / 2. + i * Slic3r::arr2::UnscaledCoordLimit / 100.,
+                                   -Slic3r::arr2::UnscaledCoordLimit / 2. + i * Slic3r::arr2::UnscaledCoordLimit / 100.,
                                    -PI + i * (2 * PI / 100.));
         },
         range(0, 100)));