Browse Source

Expand convex hull by horizontal expansion

The getSetting call doesn't seem to work at the moment, but the rest of the routine works if I replace the getSetting call with an actual value.

Contributes to issue CURA-2407.
Ghostkeeper 8 years ago
parent
commit
6affb80189
1 changed files with 10 additions and 3 deletions
  1. 10 3
      cura/ConvexHullDecorator.py

+ 10 - 3
cura/ConvexHullDecorator.py

@@ -199,9 +199,16 @@ class ConvexHullDecorator(SceneNodeDecorator):
                         # First, calculate the normal convex hull around the points
                         convex_hull = hull.getConvexHull()
 
-                        # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull.
-                        # This is done because of rounding errors.
-                        rounded_hull = convex_hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32)))
+                        #Then, offset the convex hull with the horizontal expansion value, since that is always added to the mesh.
+                        #Use a minimum of 0.5mm to outset and round the normal convex hull if there is no horizontal expansion, because of edge cases.
+                        horizontal_expansion = max(0.5, self._getSettingProperty("xy_offset", "value"))
+                        expansion_polygon = Polygon(numpy.array([
+                            [-horizontal_expansion, -horizontal_expansion],
+                            [-horizontal_expansion, horizontal_expansion],
+                            [horizontal_expansion, horizontal_expansion],
+                            [horizontal_expansion, -horizontal_expansion]
+                        ], numpy.float32))
+                        rounded_hull = convex_hull.getMinkowskiHull(expansion_polygon)
 
             # Store the result in the cache
             self._2d_convex_hull_mesh = mesh