Skip to content

Commit

Permalink
Fix #12916: Seams now respect per object settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SachCZ authored and lukasmatena committed Jul 10, 2024
1 parent 3c3591f commit fb47a62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/libslic3r/GCode/SeamPlacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ObjectSeams precalculate_seams(
ObjectSeams result;

for (auto &[print_object, layer_perimeters] : seam_data) {
switch (params.seam_preference) {
switch (print_object->config().seam_position.value) {
case spAligned: {
const Transform3d transformation{print_object->trafo_centered()};
const ModelVolumePtrs &volumes{print_object->model_object()->volumes};
Expand All @@ -97,7 +97,8 @@ ObjectSeams precalculate_seams(
break;
}
case spNearest: {
throw std::runtime_error("Cannot precalculate seams for nearest position!");
// Do not precalculate anything.
break;
}
}
throw_if_canceled();
Expand All @@ -122,7 +123,6 @@ Params Placer::get_params(const DynamicPrintConfig &config) {
params.perimeter.convex_threshold = Slic3r::Geometry::deg2rad(10.0);
params.perimeter.concave_threshold = Slic3r::Geometry::deg2rad(15.0);

params.seam_preference = config.opt_enum<SeamPosition>("seam_position");
params.staggered_inner_seams = config.opt_bool("staggered_inner_seams");

params.max_nearest_detour = 1.0;
Expand Down Expand Up @@ -159,15 +159,19 @@ void Placer::init(
}

ObjectLayerPerimeters perimeters{get_perimeters(objects, params, object_painting, throw_if_canceled)};
this->params = params;
ObjectLayerPerimeters perimeters_for_precalculation;

if (this->params.seam_preference != spNearest) {
this->seams_per_object =
precalculate_seams(params, std::move(perimeters), throw_if_canceled);
} else {
this->perimeters_per_layer = std::move(perimeters);
for (auto &[print_object, layer_perimeters] : perimeters) {
if (print_object->config().seam_position.value == spNearest) {
this->perimeters_per_layer[print_object] = std::move(layer_perimeters);
} else {
perimeters_for_precalculation[print_object] = std::move(layer_perimeters);
}
}

this->params = params;
this->seams_per_object = precalculate_seams(params, std::move(perimeters_for_precalculation), throw_if_canceled);

BOOST_LOG_TRIVIAL(debug) << "SeamPlacer: init: end";
}

Expand Down Expand Up @@ -360,7 +364,7 @@ Point Placer::place_seam(const Layer *layer, const ExtrusionLoop &loop, const Po
const double loop_width{loop.paths.empty() ? 0.0 : loop.paths.front().width()};


if (this->params.seam_preference == spNearest) {
if (po->config().seam_position.value == spNearest) {
const std::vector<Perimeters::BoundedPerimeter> &perimeters{this->perimeters_per_layer.at(po)[layer_index]};
const auto [seam_choice, perimeter_index] = place_seam_near(perimeters, loop, last_pos, this->params.max_nearest_detour);
return finalize_seam_position(loop_polygon, seam_choice, perimeters[perimeter_index].perimeter, loop_width, do_staggering);
Expand Down
1 change: 0 additions & 1 deletion src/libslic3r/GCode/SeamPlacer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct Params
double concave_visibility_modifier{};
Perimeters::PerimeterParams perimeter;
Slic3r::ModelInfo::Visibility::Params visibility;
SeamPosition seam_preference;
bool staggered_inner_seams;
};

Expand Down

0 comments on commit fb47a62

Please sign in to comment.