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
* added basic support for importing DXF contour files
* added basic support for engravings
* allow non-square profiles for the support grid
Version 0.2.5 - 2010-06-10
* added support bridges for holding the object during cutting
......
......@@ -232,12 +232,23 @@ class ProjectGui:
grid_distance.connect("value-changed", self.update_support_grid_controls)
self.settings.add_item("support_grid_distance",
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.connect("value-changed", self.update_support_grid_controls)
self.settings.add_item("support_grid_thickness",
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_thickness", 0.5)
self.settings.set("support_grid_height", 0.5)
# visual and general settings
for name, objname in (("show_model", "ShowModelCheckBox"),
("show_support_grid", "ShowSupportGridCheckBox"),
......@@ -455,9 +466,19 @@ class ProjectGui:
@gui_activity_guard
def update_support_grid_controls(self, widget=None):
is_enabled = self.gui.get_object("SupportGridEnable").get_active()
grid_square = self.gui.get_object("SupportGridSquare")
details_box = self.gui.get_object("SupportGridDetailsBox")
grid_height_box = self.gui.get_object("SupportGridHeightBox")
if is_enabled:
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:
details_box.hide()
self.update_support_grid_model()
......@@ -468,13 +489,15 @@ class ProjectGui:
s = self.settings
if is_enabled \
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",
pycam.Toolpath.SupportGrid.get_support_grid(s.get("minx"),
s.get("maxx"), s.get("miny"), s.get("maxy"),
s.get("minz"), 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:
self.settings.set("support_grid", None)
......@@ -1690,9 +1713,11 @@ class ProjectGui:
if self.gui.get_object("SupportGridEnable").get_active():
support_grid_distance = self.settings.get("support_grid_distance")
support_grid_thickness = self.settings.get("support_grid_thickness")
support_grid_height = self.settings.get("support_grid_height")
else:
support_grid_distance = None
support_grid_thickness = None
support_grid_height = None
# run the toolpath generation
toolpath = pycam.Toolpath.Generator.generate_toolpath(self.model,
tool_settings=tool_dict, bounds=bounds,
......@@ -1705,6 +1730,7 @@ class ProjectGui:
step_down=process_settings["step_down"],
support_grid_distance=support_grid_distance,
support_grid_thickness=support_grid_thickness,
support_grid_height=support_grid_height,
calculation_backend=calculation_backend, callback=draw_callback)
print "Time elapsed: %f" % (time.time() - start_time)
......
......@@ -1119,82 +1119,148 @@
</packing>
</child>
<child>
<object class="GtkHBox" id="SupportGridDetailsBox">
<object class="GtkTable" id="SupportGridDetailsBox">
<property name="visible">True</property>
<property name="spacing">4</property>
<property name="n_rows">2</property>
<property name="n_columns">5</property>
<property name="row_spacing">3</property>
<child>
<object class="GtkArrow" id="arrow1">
<object class="GtkVSeparator" id="vseparator7">
<property name="visible">True</property>
<property name="xpad">2</property>
<property name="shadow_type">etched-in</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridDistanceControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridDistance</property>
<property name="digits">2</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="SupportGridDistanceLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Grid distance:</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">grid distance:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridDistanceControl">
<object class="GtkArrow" id="arrow1">
<property name="visible">True</property>
<property name="xpad">2</property>
<property name="shadow_type">etched-in</property>
</object>
</child>
<child>
<object class="GtkLabel" id="SupportGridThicknessLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">grid thickness:</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridThicknessControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridDistance</property>
<property name="adjustment">SupportGridThickness</property>
<property name="digits">2</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator7">
<object class="GtkVSeparator" id="vseparator10">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">5</property>
<property name="position">3</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="SupportGridThicknessLabel">
<object class="GtkCheckButton" id="SupportGridSquare">
<property name="label" translatable="yes">square grid profile</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Grid thickness:</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridThicknessControl">
<object class="GtkHBox" id="SupportGridHeightBox">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="SupportGridHeightLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">grid height:</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridHeightControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridThickness</property>
<property name="adjustment">SupportGridHeight</property>
<property name="digits">2</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">5</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
......@@ -4757,4 +4823,10 @@ Any selected group of dimensions will be scaled accordingly.</property>
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
</object>
<object class="GtkAdjustment" id="SupportGridHeight">
<property name="value">0.10000000000000001</property>
<property name="lower">0.01</property>
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
</object>
</interface>
......@@ -37,7 +37,7 @@ def generate_toolpath(model, tool_settings=None,
path_postprocessor="ZigZagCutter", material_allowance=0.0,
safety_height=None, overlap=0.0, step_down=0.0,
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
@type model: pycam.Geometry.Model.Model
......@@ -67,6 +67,8 @@ def generate_toolpath(model, tool_settings=None,
@value support_grid_distance: grid size of remaining support material
@type support_grid_thickness: float
@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
@value calculation_backend: any member of the CALCULATION_BACKENDS set
The default is the triangular collision detection.
......@@ -95,13 +97,19 @@ def generate_toolpath(model, tool_settings=None,
# create the grid model if requested
if (not support_grid_distance 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:
return "The distance of the support grid must be a positive value"
if support_grid_thickness <= 0:
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(
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
# Due to some weirdness the height of the drill must be bigger than the object's size.
# Otherwise some collisions are not detected.
......
......@@ -21,6 +21,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
from pycam.Geometry import Point, Line, Triangle, Model
import math
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)
return model
def get_support_grid(minx, maxx, miny, maxy, z_plane, dist_x, dist_y, thickness):
lines_x = 1 + int((maxx - minx) / dist_x)
lines_y = 1 + int((maxy - miny) / dist_y)
def get_support_grid(minx, maxx, miny, maxy, z_plane, dist_x, dist_y, thickness, height):
lines_x = int(math.ceil((maxx - minx) / dist_x))
lines_y = int(math.ceil((maxy - miny) / dist_y))
# we center the grid
start_x = ((maxx - minx) - (lines_x - 1) * dist_x) / 2.0 + minx
start_y = ((maxy - miny) - (lines_y - 1) * dist_y) / 2.0 + miny
# create all x grid lines
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):
x = start_x + i * dist_x
# we make the grid slightly longer (by thickness) than necessary
grid_model += _add_cuboid_to_model(x - radius, x + radius,
miny - thickness, maxy + thickness, z_plane, z_plane + thickness)
grid_model += _add_cuboid_to_model(x - thick_half, x + thick_half,
miny - length_extension, maxy + length_extension, z_plane,
z_plane + height)
for i in range(lines_y):
y = start_y + i * dist_y
# we make the grid slightly longer (by thickness) than necessary
grid_model += _add_cuboid_to_model(minx - thickness, maxx + thickness,
y - radius, y + radius, z_plane, z_plane + thickness)
grid_model += _add_cuboid_to_model(minx - length_extension,
maxx + length_extension, y - thick_half, y + thick_half,
z_plane, z_plane + height)
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