Brim separation from object, follow up to 82373334bc

1) Changed the name of the variable "brim_offset" to "brim_separation"
   for clarity.
2) Added legacy conversion after loading an old 3MF that does not define
   then new "brim_separation" variable: The "brim_separation" is being
   filled in with the "elefant_foot_compensation" value to produce
   equal brim separation to the old PrusaSlicer that saved that 3MF file.
This commit is contained in:
Vojtech Bubnik 2021-08-31 12:22:38 +02:00
parent 4cc729b312
commit 5f26bfd397
12 changed files with 46 additions and 31 deletions

View file

@ -134,10 +134,10 @@ static Polygons top_level_outer_brim_islands(const ConstPrintObjectPtrs &top_lev
Polygons islands;
for (const PrintObject *object : top_level_objects_with_brim) {
//FIXME how about the brim type?
auto brim_offset = float(scale_(object->config().brim_offset.value));
auto brim_separation = float(scale_(object->config().brim_separation.value));
Polygons islands_object;
for (const ExPolygon &ex_poly : get_print_object_bottom_layer_expolygons(*object)) {
Polygons contour_offset = offset(ex_poly.contour, brim_offset);
Polygons contour_offset = offset(ex_poly.contour, brim_separation);
for (Polygon &poly : contour_offset)
poly.douglas_peucker(SCALED_RESOLUTION);
@ -166,7 +166,7 @@ static ExPolygons top_level_outer_brim_area(const Print &print
for(size_t print_object_idx = 0; print_object_idx < print.objects().size(); ++print_object_idx) {
const PrintObject *object = print.objects()[print_object_idx];
const BrimType brim_type = object->config().brim_type.value;
const float brim_offset = scale_(object->config().brim_offset.value);
const float brim_separation = scale_(object->config().brim_separation.value);
const float brim_width = scale_(object->config().brim_width.value);
const bool is_top_outer_brim = top_level_objects_idx.find(object->id().id) != top_level_objects_idx.end();
@ -174,7 +174,7 @@ static ExPolygons top_level_outer_brim_area(const Print &print
ExPolygons no_brim_area_object;
for (const ExPolygon &ex_poly : bottom_layers_expolygons[print_object_idx]) {
if ((brim_type == BrimType::btOuterOnly || brim_type == BrimType::btOuterAndInner) && is_top_outer_brim)
append(brim_area_object, diff_ex(offset(ex_poly.contour, brim_width + brim_offset), offset(ex_poly.contour, brim_offset)));
append(brim_area_object, diff_ex(offset(ex_poly.contour, brim_width + brim_separation), offset(ex_poly.contour, brim_separation)));
if (brim_type == BrimType::btOuterOnly || brim_type == BrimType::btNoBrim)
append(no_brim_area_object, offset_ex(ex_poly.holes, -no_brim_offset));
@ -183,7 +183,7 @@ static ExPolygons top_level_outer_brim_area(const Print &print
append(no_brim_area_object, diff_ex(offset(ex_poly.contour, no_brim_offset), ex_poly.holes));
if (brim_type != BrimType::btNoBrim)
append(no_brim_area_object, offset_ex(ExPolygon(ex_poly.contour), brim_offset));
append(no_brim_area_object, offset_ex(ExPolygon(ex_poly.contour), brim_separation));
no_brim_area_object.emplace_back(ex_poly.contour);
}
@ -212,11 +212,11 @@ static ExPolygons inner_brim_area(const Print &print,
ExPolygons no_brim_area;
Polygons holes;
for(size_t print_object_idx = 0; print_object_idx < print.objects().size(); ++print_object_idx) {
const PrintObject *object = print.objects()[print_object_idx];
const BrimType brim_type = object->config().brim_type.value;
const float brim_offset = scale_(object->config().brim_offset.value);
const float brim_width = scale_(object->config().brim_width.value);
const bool top_outer_brim = top_level_objects_idx.find(object->id().id) != top_level_objects_idx.end();
const PrintObject *object = print.objects()[print_object_idx];
const BrimType brim_type = object->config().brim_type.value;
const float brim_separation = scale_(object->config().brim_separation.value);
const float brim_width = scale_(object->config().brim_width.value);
const bool top_outer_brim = top_level_objects_idx.find(object->id().id) != top_level_objects_idx.end();
ExPolygons brim_area_object;
ExPolygons no_brim_area_object;
@ -226,11 +226,11 @@ static ExPolygons inner_brim_area(const Print &print,
if (top_outer_brim)
no_brim_area_object.emplace_back(ex_poly);
else
append(brim_area_object, diff_ex(offset(ex_poly.contour, brim_width + brim_offset), offset(ex_poly.contour, brim_offset)));
append(brim_area_object, diff_ex(offset(ex_poly.contour, brim_width + brim_separation), offset(ex_poly.contour, brim_separation)));
}
if (brim_type == BrimType::btInnerOnly || brim_type == BrimType::btOuterAndInner)
append(brim_area_object, diff_ex(offset_ex(ex_poly.holes, -brim_offset), offset_ex(ex_poly.holes, -brim_width - brim_offset)));
append(brim_area_object, diff_ex(offset_ex(ex_poly.holes, -brim_separation), offset_ex(ex_poly.holes, -brim_width - brim_separation)));
if (brim_type == BrimType::btInnerOnly || brim_type == BrimType::btNoBrim)
append(no_brim_area_object, diff_ex(offset(ex_poly.contour, no_brim_offset), ex_poly.holes));
@ -240,7 +240,7 @@ static ExPolygons inner_brim_area(const Print &print,
append(holes_object, ex_poly.holes);
}
append(no_brim_area_object, offset_ex(bottom_layers_expolygons[print_object_idx], brim_offset));
append(no_brim_area_object, offset_ex(bottom_layers_expolygons[print_object_idx], brim_separation));
for (const PrintInstance &instance : object->instances()) {
append_and_translate(brim_area, brim_area_object, instance);