FIX: filament shrinkage causing color loss

jira: STUDIO-10837 & STUDIO-10960
Change-Id: I379ad68dd821208a8de4b2c462a1bb324235f8d3
This commit is contained in:
zhimin.zeng 2025-03-19 19:00:20 +08:00 committed by lane.wei
parent ad1f6bdca4
commit 6fc5643353
1 changed files with 17 additions and 15 deletions

View File

@ -1017,21 +1017,6 @@ void PrintObject::slice_volumes()
PrintObject::clip_multipart_objects,
throw_on_cancel_callback);
// SuperSlicer: filament shrink
for (const std::unique_ptr<PrintRegion> &pr : m_shared_regions->all_regions) {
if (pr.get()) {
std::vector<ExPolygons> &region_polys = region_slices[pr->print_object_region_id()];
const size_t extruder_id = pr->extruder(FlowRole::frPerimeter) - 1;
double scale = print->config().filament_shrink.values[extruder_id] * 0.01;
if (scale != 1) {
scale = 1 / scale;
for (ExPolygons &polys : region_polys)
for (ExPolygon &poly : polys) poly.scale(scale);
}
}
}
for (size_t region_id = 0; region_id < region_slices.size(); ++ region_id) {
std::vector<ExPolygons> &by_layer = region_slices[region_id];
for (size_t layer_id = 0; layer_id < by_layer.size(); ++ layer_id)
@ -1074,6 +1059,23 @@ void PrintObject::slice_volumes()
InterlockingGenerator::generate_interlocking_structure(this);
m_print->throw_if_canceled();
// SuperSlicer: filament shrink
for (Layer *layer : m_layers) {
for (size_t i = 0; i < layer->region_count(); ++i) {
LayerRegion *region = layer->get_region(i);
ExPolygons ex_polys = to_expolygons(region->slices.surfaces);
int filament_id = region->region().extruder(FlowRole::frPerimeter) - 1;
double scale = print->config().filament_shrink.values[filament_id] * 0.01;
if (scale != 1) {
scale = 1 / scale;
for (ExPolygon &poly : ex_polys)
poly.scale(scale);
}
region->slices.set(std::move(ex_polys), stInternal);
}
}
BOOST_LOG_TRIVIAL(debug) << "Slicing volumes - make_slices in parallel - begin";
{
// Compensation value, scaled. Only applying the negative scaling here, as the positive scaling has already been applied during slicing.