Commit 7ab35a68 authored by sumpfralle's avatar sumpfralle

better progress visualization for 2D model offsetting


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@890 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 073da262
......@@ -485,7 +485,7 @@ class ContourModel(BaseModel):
def get_offset_model(self, offset, callback=None):
result = ContourModel(plane=self._plane)
for group in self.get_polygons():
new_groups = group.get_offset_polygons(offset)
new_groups = group.get_offset_polygons(offset, callback=callback)
result.extend(new_groups)
if callback and callback():
return None
......
......@@ -582,7 +582,7 @@ class Polygon(TransformableContainer):
self._cached_offset_polygons[offset] = result_polygons
return result_polygons
def get_offset_polygons(self, offset):
def get_offset_polygons(self, offset, callback=None):
def get_shifted_vertex(index, offset):
p1 = self._points[index]
p2 = self._points[(index + 1) % len(self._points)]
......@@ -697,6 +697,8 @@ class Polygon(TransformableContainer):
p1 = points[index]
p2 = points[(index + 1) % len(points)]
new_lines.append(Line(p1, p2))
if callback and callback():
return None
cleaned_line_groups = simplify_polygon_intersections(new_lines)
if cleaned_line_groups is None:
log.debug("Skipping offset polygon: intersections could not be " \
......@@ -710,6 +712,8 @@ class Polygon(TransformableContainer):
self_is_outer = self.is_outer()
groups = []
for lines in cleaned_line_groups:
if callback and callback():
return None
group = Polygon(self.plane)
for line in lines:
group.append(line)
......@@ -734,6 +738,8 @@ class Polygon(TransformableContainer):
for group in groups:
inside = False
for group_test in groups:
if callback and callback():
return None
if group_test is group:
continue
if group_test.is_polygon_inside(group):
......
......@@ -218,12 +218,8 @@ def generate_toolpath(model, tool_settings=None,
if (not contour_model is None) and (engrave_offset != 0):
if not callback is None:
callback(text="Preparing contour model with offset ...")
progress_callback = ProgressCounter(
len(contour_model.get_polygons()), callback).increment
else:
progress_callback = None
contour_model = contour_model.get_offset_model(engrave_offset,
callback=progress_callback)
callback=callback)
if contour_model is None:
return "Failed to calculate offset polygons"
if not callback is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment