diff options
author | Rijk van Manen <r.vanmanen@ultimaker.com> | 2022-11-10 14:33:31 +0300 |
---|---|---|
committer | Rijk van Manen <r.vanmanen@ultimaker.com> | 2022-11-10 14:33:31 +0300 |
commit | 0cdbcc52dda3e075dbeb00fa0ef9df51bb4f8bdc (patch) | |
tree | 3bf1730187c61fc86e6a5e815805108e12565af1 | |
parent | 4a331a74c709f1aa541f609a2dce76b4768cbe62 (diff) |
gradually reduce hole horizontal expansion for large holesCURA-8890-hole-horizontal-expansion-max-diameter
The hole horizontal expansion is only applied to holes which are smaller then the hole_xy_offset_max_diameter. For these small holes the expansion is proportional to their size to ensure smooth transition between small and large holes. CURA-8890
-rw-r--r-- | src/layerPart.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/layerPart.cpp b/src/layerPart.cpp index 554ddc323..0234aa1ff 100644 --- a/src/layerPart.cpp +++ b/src/layerPart.cpp @@ -59,6 +59,7 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl result = layer->polygons.splitIntoParts(union_layers || union_all_remove_holes); } const coord_t hole_offset = settings.get<coord_t>("hole_xy_offset"); + const coord_t hole_offset_max_diameter = settings.get<coord_t>("hole_xy_offset_max_diameter"); for(auto & part : result) { storageLayer.parts.emplace_back(); @@ -75,7 +76,23 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl } else { - holes.add(poly.offset(hole_offset)); + if (hole_offset_max_diameter > 0) + { + // only apply offset to small holes + const coord_t hole_size = poly.polygonLength(); + if (hole_size < hole_offset_max_diameter * 3.1415) + { + holes.add(poly.offset(hole_offset * (1 - hole_size / (hole_offset_max_diameter * 3.1415)))); + } + else + { + holes.add(poly); + } + } + else + { + holes.add(poly.offset(hole_offset)); + } } } storageLayer.parts.back().outline.add(outline.difference(holes.unionPolygons())); |