mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-30 00:45:26 -05:00
By object: keep rotated copies of an object in their list order (#17286)
* By object: order rotated copies of an object by their list position Copies of one object that differ in rotation get one PrintObject each, and print.objects() lists those groups by transformation. sequential_print_ clearance_valid() keyed the instances by their object's index, which all copies share, so std::stable_sort kept the transformation grouping and every second copy on a rotated plate printed out of place. Key each instance by its position in the model's object and instance lists instead. No key repeats, so the sort no longer depends on being stable, and arrange_order is then the list order the G-code export and the sequence labels already print in. Fixes #17260. * Keep the sequential printed-copy tests in step with the list order The new by-object test rotated a cube centred on its corner, which moved the footprint by half the cube and closed the 12 mm grid gap under the 2 mm clearance distance, so validation rejected the plate. Centre the mesh on the object origin so the rotation turns the footprint in place. Sequential clearance warned the copy that print.objects() listed first, which for a plate of rotated copies was the rotated one. Copies now print in object list order, so print validation warns the first copy in the list; expect that copy from the preview as well, and drop the now incorrect header comment.
This commit is contained in:
1 parent
2ec1a0732f
commit
719fdcf4dd
4 files changed
+83
-23
No files matched your search
@@ -83,7 +83,7 @@ TEST_CASE("Sequential clearance allows the last object up to printable height",
|
||||
CHECK_THAT(warnings.front().second, WithinAbs(200., 1e-6));
|
||||
}
|
||||
|
||||
TEST_CASE("Sequential clearance warns the same rotated copy as print validation", "[SequentialClearance][Regression]")
|
||||
TEST_CASE("Sequential clearance warns the same copy as print validation", "[SequentialClearance][Regression]")
|
||||
{
|
||||
constexpr double rod_height = 10.;
|
||||
constexpr double lid_height = 30.;
|
||||
@@ -116,15 +116,17 @@ TEST_CASE("Sequential clearance warns the same rotated copy as print validation"
|
||||
Slic3r::Polygon hull = object->convex_hull_2d(object->instances[i]->get_matrix());
|
||||
instances.push_back({object->get_instance_max_z(i), hull.bounding_box(), hull, object->instances[i]->id()});
|
||||
}
|
||||
const Slic3r::Polygon expected_warning = instances[1].hull_polygon;
|
||||
// Copies print in object-list order, so the first copy is the one held to the rod height: the later
|
||||
// copy shares its Y band. Print validation warns about that copy, and the clearance preview must
|
||||
// warn about the same one.
|
||||
REQUIRE(validation_warnings.size() == 1);
|
||||
CHECK(validation_warnings.front().first.bounding_box().contains(instances[1].bounding_box.center()));
|
||||
CHECK_FALSE(validation_warnings.front().first.bounding_box().contains(instances[0].bounding_box.center()));
|
||||
CHECK(validation_warnings.front().first.bounding_box().contains(instances[0].bounding_box.center()));
|
||||
CHECK_FALSE(validation_warnings.front().first.bounding_box().contains(instances[1].bounding_box.center()));
|
||||
|
||||
sort_sequential_clearance_instances(instances.begin(), instances.end(), print_order);
|
||||
const auto warnings = sequential_clearance_height_polygons(instances, printable_height, lid_height, rod_height);
|
||||
REQUIRE(warnings.size() == 1);
|
||||
CHECK(warnings.front().first == expected_warning);
|
||||
CHECK(warnings.front().first == instances[0].hull_polygon);
|
||||
CHECK_THAT(warnings.front().second, WithinAbs(rod_height, 1e-6));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user