Commit cc3235a1 authored by sumpfralle's avatar sumpfralle

use the configured bounds for each task

fix bounds handling for simulations


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@412 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent d78821d4
...@@ -851,7 +851,7 @@ class ProjectGui: ...@@ -851,7 +851,7 @@ class ProjectGui:
# this shoudl only happen, if we were called in batch mode (command line) # this shoudl only happen, if we were called in batch mode (command line)
print >>sys.stderr, "The given task ID (%d) does not exist. Valid values are: %s." % (task_index, range(len(self.task_list))) print >>sys.stderr, "The given task ID (%d) does not exist. Valid values are: %s." % (task_index, range(len(self.task_list)))
return return
self.generate_toolpath(task["tool"], task["process"]) self.generate_toolpath(task["tool"], task["process"], task["bounds"])
def process_multiple_tasks(self, task_list=None): def process_multiple_tasks(self, task_list=None):
if task_list is None: if task_list is None:
...@@ -867,7 +867,8 @@ class ProjectGui: ...@@ -867,7 +867,8 @@ class ProjectGui:
progress_bar.set_fraction(float(index) / len(enabled_tasks)) progress_bar.set_fraction(float(index) / len(enabled_tasks))
progress_bar.set_text("Toolpath %d/%d" % (index, len(enabled_tasks))) progress_bar.set_text("Toolpath %d/%d" % (index, len(enabled_tasks)))
task = enabled_tasks[index] task = enabled_tasks[index]
if not self.generate_toolpath(task["tool"], task["process"]): if not self.generate_toolpath(task["tool"], task["process"],
task["bounds"]):
# break out of the loop, if cancel was requested # break out of the loop, if cancel was requested
break break
progress_bar.hide() progress_bar.hide()
...@@ -1879,8 +1880,10 @@ class ProjectGui: ...@@ -1879,8 +1880,10 @@ class ProjectGui:
# calculate steps # calculate steps
detail_level = self.gui.get_object("SimulationDetailsValue").get_value() detail_level = self.gui.get_object("SimulationDetailsValue").get_value()
grid_size = 100 * pow(2, detail_level - 1) grid_size = 100 * pow(2, detail_level - 1)
proportion = (self.settings.get("maxx") - self.settings.get("minx")) \ bounding_box = toolpath.get_toolpath_settings().get_bounds()
/ (self.settings.get("maxy") - self.settings.get("miny")) # proportion = dimension_x / dimension_y
proportion = (bounding_box["maxx"] - bounding_box["minx"]) \
/ (bounding_box["maxy"] - bounding_box["miny"])
x_steps = int(math.sqrt(grid_size) * proportion) x_steps = int(math.sqrt(grid_size) * proportion)
y_steps = int(math.sqrt(grid_size) / proportion) y_steps = int(math.sqrt(grid_size) / proportion)
simulation_backend = pycam.Simulation.ODEBlocks.ODEBlocks( simulation_backend = pycam.Simulation.ODEBlocks.ODEBlocks(
...@@ -1933,7 +1936,7 @@ class ProjectGui: ...@@ -1933,7 +1936,7 @@ class ProjectGui:
self.finish_toolpath_simulation() self.finish_toolpath_simulation()
@progress_activity_guard @progress_activity_guard
def generate_toolpath(self, tool_settings, process_settings): def generate_toolpath(self, tool_settings, process_settings, bounds):
start_time = time.time() start_time = time.time()
self.update_progress_bar("Preparing toolpath generation") self.update_progress_bar("Preparing toolpath generation")
parent = self parent = self
...@@ -1965,7 +1968,8 @@ class ProjectGui: ...@@ -1965,7 +1968,8 @@ class ProjectGui:
self.update_progress_bar("Generating collision model") self.update_progress_bar("Generating collision model")
# turn the toolpath settings into a dict # turn the toolpath settings into a dict
toolpath_settings = self.get_toolpath_settings(tool_settings, process_settings) toolpath_settings = self.get_toolpath_settings(tool_settings,
process_settings, bounds)
if toolpath_settings is None: if toolpath_settings is None:
# behave as if "cancel" was requested # behave as if "cancel" was requested
return True return True
...@@ -2003,7 +2007,7 @@ class ProjectGui: ...@@ -2003,7 +2007,7 @@ class ProjectGui:
# return "False" if the action was cancelled # return "False" if the action was cancelled
return not self._progress_cancel_requested return not self._progress_cancel_requested
def get_toolpath_settings(self, tool_settings, process_settings): def get_toolpath_settings(self, tool_settings, process_settings, bounds):
toolpath_settings = pycam.Gui.Settings.ToolpathSettings() toolpath_settings = pycam.Gui.Settings.ToolpathSettings()
# this offset allows to cut a model with a minimal boundary box correctly # this offset allows to cut a model with a minimal boundary box correctly
...@@ -2022,12 +2026,14 @@ class ProjectGui: ...@@ -2022,12 +2026,14 @@ class ProjectGui:
# this should never happen # this should never happen
print >>sys.stderr, "Assertion failed: invalid boundary_mode (%s)" % str(self.settings.get("boundary_mode")) print >>sys.stderr, "Assertion failed: invalid boundary_mode (%s)" % str(self.settings.get("boundary_mode"))
minx = float(self.settings.get("minx"))-offset abs_bounds = self._get_bounds_limits_absolute(bounds)
maxx = float(self.settings.get("maxx"))+offset
miny = float(self.settings.get("miny"))-offset minx = float(abs_bounds["x_low"])-offset
maxy = float(self.settings.get("maxy"))+offset maxx = float(abs_bounds["x_high"])+offset
minz = float(self.settings.get("minz")) miny = float(abs_bounds["y_low"])-offset
maxz = float(self.settings.get("maxz")) maxy = float(abs_bounds["y_high"])+offset
minz = float(abs_bounds["z_low"])
maxz = float(abs_bounds["z_high"])
toolpath_settings.set_bounds(minx, maxx, miny, maxy, minz, maxz) toolpath_settings.set_bounds(minx, maxx, miny, maxy, minz, maxz)
# check if the boundary limits are valid # check if the boundary limits are valid
......
...@@ -58,7 +58,7 @@ class ToolPath: ...@@ -58,7 +58,7 @@ class ToolPath:
return Point(0, 0, safety_height) return Point(0, 0, safety_height)
def get_bounding_box(self): def get_bounding_box(self):
box = self.toolpath_settings.get_bounding_box() box = self.toolpath_settings.get_bounds()
return (box["minx"], box["maxx"], box["miny"], box["maxy"], box["minz"], return (box["minx"], box["maxx"], box["miny"], box["maxy"], box["minz"],
box["maxz"]) box["maxz"])
......
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