Commit f658ad2c authored by sumpfralle's avatar sumpfralle

allow non-square profiles for the support grid


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@390 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent a62b2801
Version 0.3.0 - UNRELEASED Version 0.3.0 - UNRELEASED
* added basic support for importing DXF contour files * added basic support for importing DXF contour files
* added basic support for engravings * added basic support for engravings
* allow non-square profiles for the support grid
Version 0.2.5 - 2010-06-10 Version 0.2.5 - 2010-06-10
* added support bridges for holding the object during cutting * added support bridges for holding the object during cutting
......
...@@ -232,12 +232,23 @@ class ProjectGui: ...@@ -232,12 +232,23 @@ class ProjectGui:
grid_distance.connect("value-changed", self.update_support_grid_controls) grid_distance.connect("value-changed", self.update_support_grid_controls)
self.settings.add_item("support_grid_distance", self.settings.add_item("support_grid_distance",
grid_distance.get_value, grid_distance.set_value) grid_distance.get_value, grid_distance.set_value)
grid_square_profile = self.gui.get_object("SupportGridSquare")
grid_square_profile.connect("toggled", self.update_support_grid_controls)
grid_thickness = self.gui.get_object("SupportGridThickness") grid_thickness = self.gui.get_object("SupportGridThickness")
grid_thickness.connect("value-changed", self.update_support_grid_controls) grid_thickness.connect("value-changed", self.update_support_grid_controls)
self.settings.add_item("support_grid_thickness", self.settings.add_item("support_grid_thickness",
grid_thickness.get_value, grid_thickness.set_value) grid_thickness.get_value, grid_thickness.set_value)
grid_height = self.gui.get_object("SupportGridHeight")
def get_support_grid_height():
if grid_square_profile.get_active():
return self.settings.get("support_grid_thickness")
else:
return grid_height.get_value()
self.settings.add_item("support_grid_height", get_support_grid_height, grid_height.set_value)
grid_height.connect("value-changed", self.update_support_grid_controls)
self.settings.set("support_grid_distance", 5.0) self.settings.set("support_grid_distance", 5.0)
self.settings.set("support_grid_thickness", 0.5) self.settings.set("support_grid_thickness", 0.5)
self.settings.set("support_grid_height", 0.5)
# visual and general settings # visual and general settings
for name, objname in (("show_model", "ShowModelCheckBox"), for name, objname in (("show_model", "ShowModelCheckBox"),
("show_support_grid", "ShowSupportGridCheckBox"), ("show_support_grid", "ShowSupportGridCheckBox"),
...@@ -455,9 +466,19 @@ class ProjectGui: ...@@ -455,9 +466,19 @@ class ProjectGui:
@gui_activity_guard @gui_activity_guard
def update_support_grid_controls(self, widget=None): def update_support_grid_controls(self, widget=None):
is_enabled = self.gui.get_object("SupportGridEnable").get_active() is_enabled = self.gui.get_object("SupportGridEnable").get_active()
grid_square = self.gui.get_object("SupportGridSquare")
details_box = self.gui.get_object("SupportGridDetailsBox") details_box = self.gui.get_object("SupportGridDetailsBox")
grid_height_box = self.gui.get_object("SupportGridHeightBox")
if is_enabled: if is_enabled:
details_box.show() details_box.show()
if grid_square.get_active():
grid_height_box.hide()
else:
if widget == grid_square:
# reset the current height to the thickness, if the
# "square" checkbox was just de-activated
self.settings.set("support_grid_height", self.settings.get("support_grid_thickness"))
grid_height_box.show()
else: else:
details_box.hide() details_box.hide()
self.update_support_grid_model() self.update_support_grid_model()
...@@ -468,13 +489,15 @@ class ProjectGui: ...@@ -468,13 +489,15 @@ class ProjectGui:
s = self.settings s = self.settings
if is_enabled \ if is_enabled \
and (s.get("support_grid_thickness") > 0) \ and (s.get("support_grid_thickness") > 0) \
and (s.get("support_grid_distance") > s.get("support_grid_thickness")): and (s.get("support_grid_distance") > s.get("support_grid_thickness")) \
and (s.get("support_grid_height") > 0):
s.set("support_grid", s.set("support_grid",
pycam.Toolpath.SupportGrid.get_support_grid(s.get("minx"), pycam.Toolpath.SupportGrid.get_support_grid(s.get("minx"),
s.get("maxx"), s.get("miny"), s.get("maxy"), s.get("maxx"), s.get("miny"), s.get("maxy"),
s.get("minz"), s.get("support_grid_distance"), s.get("minz"), s.get("support_grid_distance"),
s.get("support_grid_distance"), s.get("support_grid_distance"),
s.get("support_grid_thickness"))) s.get("support_grid_thickness"),
s.get("support_grid_height")))
else: else:
self.settings.set("support_grid", None) self.settings.set("support_grid", None)
...@@ -1690,9 +1713,11 @@ class ProjectGui: ...@@ -1690,9 +1713,11 @@ class ProjectGui:
if self.gui.get_object("SupportGridEnable").get_active(): if self.gui.get_object("SupportGridEnable").get_active():
support_grid_distance = self.settings.get("support_grid_distance") support_grid_distance = self.settings.get("support_grid_distance")
support_grid_thickness = self.settings.get("support_grid_thickness") support_grid_thickness = self.settings.get("support_grid_thickness")
support_grid_height = self.settings.get("support_grid_height")
else: else:
support_grid_distance = None support_grid_distance = None
support_grid_thickness = None support_grid_thickness = None
support_grid_height = None
# run the toolpath generation # run the toolpath generation
toolpath = pycam.Toolpath.Generator.generate_toolpath(self.model, toolpath = pycam.Toolpath.Generator.generate_toolpath(self.model,
tool_settings=tool_dict, bounds=bounds, tool_settings=tool_dict, bounds=bounds,
...@@ -1705,6 +1730,7 @@ class ProjectGui: ...@@ -1705,6 +1730,7 @@ class ProjectGui:
step_down=process_settings["step_down"], step_down=process_settings["step_down"],
support_grid_distance=support_grid_distance, support_grid_distance=support_grid_distance,
support_grid_thickness=support_grid_thickness, support_grid_thickness=support_grid_thickness,
support_grid_height=support_grid_height,
calculation_backend=calculation_backend, callback=draw_callback) calculation_backend=calculation_backend, callback=draw_callback)
print "Time elapsed: %f" % (time.time() - start_time) print "Time elapsed: %f" % (time.time() - start_time)
......
This diff is collapsed.
...@@ -37,7 +37,7 @@ def generate_toolpath(model, tool_settings=None, ...@@ -37,7 +37,7 @@ def generate_toolpath(model, tool_settings=None,
path_postprocessor="ZigZagCutter", material_allowance=0.0, path_postprocessor="ZigZagCutter", material_allowance=0.0,
safety_height=None, overlap=0.0, step_down=0.0, safety_height=None, overlap=0.0, step_down=0.0,
support_grid_distance=None, support_grid_thickness=None, support_grid_distance=None, support_grid_thickness=None,
calculation_backend=None, callback=None): support_grid_height=None, calculation_backend=None, callback=None):
""" abstract interface for generating a toolpath """ abstract interface for generating a toolpath
@type model: pycam.Geometry.Model.Model @type model: pycam.Geometry.Model.Model
...@@ -67,6 +67,8 @@ def generate_toolpath(model, tool_settings=None, ...@@ -67,6 +67,8 @@ def generate_toolpath(model, tool_settings=None,
@value support_grid_distance: grid size of remaining support material @value support_grid_distance: grid size of remaining support material
@type support_grid_thickness: float @type support_grid_thickness: float
@value support_grid_thickness: thickness of the support grid @value support_grid_thickness: thickness of the support grid
@type support_grid_height: float
@value support_grid_height: height of the support grid
@type calculation_backend: str | None @type calculation_backend: str | None
@value calculation_backend: any member of the CALCULATION_BACKENDS set @value calculation_backend: any member of the CALCULATION_BACKENDS set
The default is the triangular collision detection. The default is the triangular collision detection.
...@@ -95,13 +97,19 @@ def generate_toolpath(model, tool_settings=None, ...@@ -95,13 +97,19 @@ def generate_toolpath(model, tool_settings=None,
# create the grid model if requested # create the grid model if requested
if (not support_grid_distance is None) \ if (not support_grid_distance is None) \
and (not support_grid_thickness is None): and (not support_grid_thickness is None):
# grid height defaults to the thickness
if support_grid_height is None:
support_grid_height = support_grid_thickness
if support_grid_distance <= 0: if support_grid_distance <= 0:
return "The distance of the support grid must be a positive value" return "The distance of the support grid must be a positive value"
if support_grid_thickness <= 0: if support_grid_thickness <= 0:
return "The thickness of the support grid must be a positive value" return "The thickness of the support grid must be a positive value"
if support_grid_height <= 0:
return "The height of the support grid must be a positive value"
support_grid_model = pycam.Toolpath.SupportGrid.get_support_grid( support_grid_model = pycam.Toolpath.SupportGrid.get_support_grid(
minx, maxx, miny, maxy, minz, support_grid_distance, minx, maxx, miny, maxy, minz, support_grid_distance,
support_grid_distance, support_grid_thickness) support_grid_distance, support_grid_thickness,
support_grid_height)
trimesh_model += support_grid_model trimesh_model += support_grid_model
# Due to some weirdness the height of the drill must be bigger than the object's size. # Due to some weirdness the height of the drill must be bigger than the object's size.
# Otherwise some collisions are not detected. # Otherwise some collisions are not detected.
......
...@@ -21,6 +21,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -21,6 +21,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
from pycam.Geometry import Point, Line, Triangle, Model from pycam.Geometry import Point, Line, Triangle, Model
import math
def _add_cuboid_to_model(minx, maxx, miny, maxy, minz, maxz): def _add_cuboid_to_model(minx, maxx, miny, maxy, minz, maxz):
...@@ -58,24 +59,28 @@ def _add_cuboid_to_model(minx, maxx, miny, maxy, minz, maxz): ...@@ -58,24 +59,28 @@ def _add_cuboid_to_model(minx, maxx, miny, maxy, minz, maxz):
model.append(t) model.append(t)
return model return model
def get_support_grid(minx, maxx, miny, maxy, z_plane, dist_x, dist_y, thickness): def get_support_grid(minx, maxx, miny, maxy, z_plane, dist_x, dist_y, thickness, height):
lines_x = 1 + int((maxx - minx) / dist_x) lines_x = int(math.ceil((maxx - minx) / dist_x))
lines_y = 1 + int((maxy - miny) / dist_y) lines_y = int(math.ceil((maxy - miny) / dist_y))
# we center the grid # we center the grid
start_x = ((maxx - minx) - (lines_x - 1) * dist_x) / 2.0 + minx start_x = ((maxx - minx) - (lines_x - 1) * dist_x) / 2.0 + minx
start_y = ((maxy - miny) - (lines_y - 1) * dist_y) / 2.0 + miny start_y = ((maxy - miny) - (lines_y - 1) * dist_y) / 2.0 + miny
# create all x grid lines # create all x grid lines
grid_model = Model.Model() grid_model = Model.Model()
radius = thickness / 2.0 # helper variables
thick_half = thickness / 2.0
length_extension = max(thickness, height)
for i in range(lines_x): for i in range(lines_x):
x = start_x + i * dist_x x = start_x + i * dist_x
# we make the grid slightly longer (by thickness) than necessary # we make the grid slightly longer (by thickness) than necessary
grid_model += _add_cuboid_to_model(x - radius, x + radius, grid_model += _add_cuboid_to_model(x - thick_half, x + thick_half,
miny - thickness, maxy + thickness, z_plane, z_plane + thickness) miny - length_extension, maxy + length_extension, z_plane,
z_plane + height)
for i in range(lines_y): for i in range(lines_y):
y = start_y + i * dist_y y = start_y + i * dist_y
# we make the grid slightly longer (by thickness) than necessary # we make the grid slightly longer (by thickness) than necessary
grid_model += _add_cuboid_to_model(minx - thickness, maxx + thickness, grid_model += _add_cuboid_to_model(minx - length_extension,
y - radius, y + radius, z_plane, z_plane + thickness) maxx + length_extension, y - thick_half, y + thick_half,
z_plane, z_plane + height)
return grid_model return grid_model
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