Commit 0e0466b3 authored by sumpfralle's avatar sumpfralle

more separation for the support grid plugins

some minor refactoring regarding support models
fixed minor issue with "register_ui" being called after "register_ui_section"


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1066 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 8a7037e6
This diff is collapsed.
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window1">
<child>
<object class="GtkExpander" id="DistributedSupportExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">30</property>
<child>
<object class="GtkTable" id="table12">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">3</property>
<property name="row_spacing">2</property>
<child>
<object class="GtkSpinButton" id="GridMinBridgesPerPolygon">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridMinBridgesPerPolygon</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>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GridMinBridgesPerPolygonLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Minimum bridges per polygon:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="GridAverageDistance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridAverageDistance</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GridAverageDistanceLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Average distance between bridges:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GridLengthLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Length of each bridge:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="GridLengthControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridLength</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridAverageDistanceExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Distribution</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkAdjustment" id="SupportGridAverageDistance">
<property name="lower">0.01</property>
<property name="upper">500</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridMinBridgesPerPolygon">
<property name="lower">1</property>
<property name="upper">20</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridLength">
<property name="lower">-100</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
</interface>
This diff is collapsed.
...@@ -926,9 +926,9 @@ def draw_complete_model_view(settings): ...@@ -926,9 +926,9 @@ def draw_complete_model_view(settings):
""" """
model.to_OpenGL(show_directions=settings.get("show_directions")) model.to_OpenGL(show_directions=settings.get("show_directions"))
# draw the support grid # draw the support grid
if settings.get("show_support_grid") and settings.get("support_grid"): if settings.get("show_support_grid") and settings.get("current_support_model"):
GL.glColor4f(*settings.get("color_support_grid")) GL.glColor4f(*settings.get("color_support_grid"))
settings.get("support_grid").to_OpenGL() settings.get("current_support_model").to_OpenGL()
# draw the toolpath simulation # draw the toolpath simulation
if settings.get("show_simulation"): if settings.get("show_simulation"):
moves = settings.get("simulation_toolpath_moves") moves = settings.get("simulation_toolpath_moves")
......
...@@ -232,6 +232,7 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -232,6 +232,7 @@ class EventCore(pycam.Gui.Settings.Settings):
log.debug("Trying to unregister an unknown event: %s" % event) log.debug("Trying to unregister an unknown event: %s" % event)
def emit_event(self, event): def emit_event(self, event):
log.debug("Event emitted: %s" % str(event))
if event in self.event_handlers: if event in self.event_handlers:
if self.event_handlers[event][EVENT_BLOCKER_INDEX] != 0: if self.event_handlers[event][EVENT_BLOCKER_INDEX] != 0:
return return
...@@ -256,13 +257,14 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -256,13 +257,14 @@ class EventCore(pycam.Gui.Settings.Settings):
if self.event_handlers[event][EVENT_BLOCKER_INDEX] > 0: if self.event_handlers[event][EVENT_BLOCKER_INDEX] > 0:
self.event_handlers[event][EVENT_BLOCKER_INDEX] -= 1 self.event_handlers[event][EVENT_BLOCKER_INDEX] -= 1
else: else:
log.debug("Trying to unblock non-blocked event '%s'" % str(event)) log.debug("Trying to unblock non-blocked event '%s'" % \
str(event))
else: else:
log.debug("Trying to unblock an unknown event: %s" % str(event)) log.debug("Trying to unblock an unknown event: %s" % str(event))
def register_ui_section(self, section, add_action, clear_action): def register_ui_section(self, section, add_action, clear_action):
if not section in self.ui_sections: if not section in self.ui_sections:
self.ui_sections[section] = [None, None, None] self.ui_sections[section] = [None, None]
self.ui_sections[section][UI_WIDGET_INDEX] = [] self.ui_sections[section][UI_WIDGET_INDEX] = []
self.ui_sections[section][UI_FUNC_INDEX] = (add_action, clear_action) self.ui_sections[section][UI_FUNC_INDEX] = (add_action, clear_action)
self._rebuild_ui_section(section) self._rebuild_ui_section(section)
...@@ -272,7 +274,8 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -272,7 +274,8 @@ class EventCore(pycam.Gui.Settings.Settings):
ui_section = self.ui_sections[section] ui_section = self.ui_sections[section]
if ui_section[UI_FUNC_INDEX]: if ui_section[UI_FUNC_INDEX]:
add_func, clear_func = ui_section[UI_FUNC_INDEX] add_func, clear_func = ui_section[UI_FUNC_INDEX]
ui_section[UI_WIDGET_INDEX].sort(key=lambda x: x[WIDGET_WEIGHT_INDEX]) ui_section[UI_WIDGET_INDEX].sort(
key=lambda x: x[WIDGET_WEIGHT_INDEX])
clear_func() clear_func()
for item in ui_section[UI_WIDGET_INDEX]: for item in ui_section[UI_WIDGET_INDEX]:
add_func(item[WIDGET_OBJ_INDEX], item[WIDGET_NAME_INDEX]) add_func(item[WIDGET_OBJ_INDEX], item[WIDGET_NAME_INDEX])
...@@ -281,12 +284,14 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -281,12 +284,14 @@ class EventCore(pycam.Gui.Settings.Settings):
def register_ui(self, section, name, widget, weight=0): def register_ui(self, section, name, widget, weight=0):
if not section in self.ui_sections: if not section in self.ui_sections:
self.ui_sections[section] = [None, []] self.ui_sections[section] = [None, None]
ui_section = self.ui_sections[section] self.ui_sections[section][UI_WIDGET_INDEX] = []
assert WIDGET_NAME_INDEX == 0 assert WIDGET_NAME_INDEX == 0
assert WIDGET_OBJ_INDEX == 1 assert WIDGET_OBJ_INDEX == 1
assert WIDGET_WEIGHT_INDEX == 2 assert WIDGET_WEIGHT_INDEX == 2
ui_section[UI_WIDGET_INDEX].append((name, widget, weight)) self.ui_sections[section][UI_WIDGET_INDEX].append((name, widget,
weight))
self._rebuild_ui_section(section)
def unregister_ui(self, section, widget): def unregister_ui(self, section, widget):
if (section in self.ui_sections) or (None in self.ui_sections): if (section in self.ui_sections) or (None in self.ui_sections):
...@@ -301,7 +306,8 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -301,7 +306,8 @@ class EventCore(pycam.Gui.Settings.Settings):
for index in removal_list: for index in removal_list:
ui_section[UI_WIDGET_INDEX].pop(index) ui_section[UI_WIDGET_INDEX].pop(index)
else: else:
log.debug("Trying to unregister unknown ui section: %s" % str(section)) log.debug("Trying to unregister unknown ui section: %s" % \
str(section))
class ProjectGui(object): class ProjectGui(object):
...@@ -425,6 +431,7 @@ class ProjectGui(object): ...@@ -425,6 +431,7 @@ class ProjectGui(object):
self.settings.register_event("model-change-after", self.update_save_actions) self.settings.register_event("model-change-after", self.update_save_actions)
self.settings.register_event("model-change-after", self.update_model_type_related_controls) self.settings.register_event("model-change-after", self.update_model_type_related_controls)
self.settings.register_event("model-change-after", self.update_view) self.settings.register_event("model-change-after", self.update_view)
self.settings.register_event("visual-item-updated", self.update_view)
self.settings.set("update_progress", self.update_progress_bar) self.settings.set("update_progress", self.update_progress_bar)
self.settings.set("disable_progress_cancel_button", self.disable_progress_cancel_button) self.settings.set("disable_progress_cancel_button", self.disable_progress_cancel_button)
self.settings.set("load_model", self.load_model) self.settings.set("load_model", self.load_model)
...@@ -2717,7 +2724,7 @@ class ProjectGui(object): ...@@ -2717,7 +2724,7 @@ class ProjectGui(object):
def load_model(self, model): def load_model(self, model):
# load the new model only if the import worked # load the new model only if the import worked
if not model is None: if model:
self.settings.emit_event("model-change-before") self.settings.emit_event("model-change-before")
self.model = model self.model = model
self.last_model_uri = None self.last_model_uri = None
...@@ -3131,6 +3138,15 @@ class ProjectGui(object): ...@@ -3131,6 +3138,15 @@ class ProjectGui(object):
self.update_toolpath_table() self.update_toolpath_table()
dialog.hide() dialog.hide()
def _get_projection_plane(self):
# determine projection plane
if (self.model.maxz < 0) or (self.model.minz > 0):
# completely above or below zero
plane_z = self.model.minz
else:
plane_z = 0
return Plane(Point(0, 0, plane_z), Vector(0, 0, 1))
@progress_activity_guard @progress_activity_guard
def crop_toolpath(self, toolpath): def crop_toolpath(self, toolpath):
if hasattr(self.model, "get_polygons"): if hasattr(self.model, "get_polygons"):
...@@ -3571,10 +3587,9 @@ class ProjectGui(object): ...@@ -3571,10 +3587,9 @@ class ProjectGui(object):
tool_settings["tool_radius"], tool_settings["torus_radius"], tool_settings["tool_radius"], tool_settings["torus_radius"],
tool_settings["speed"], tool_settings["feedrate"]) tool_settings["speed"], tool_settings["feedrate"])
support_factory = self.settings.get("get_support_model") support_model = self.settings.get("current_support_model")
if support_factory: if support_model:
# TODO: this is not a good approach - "toolpath_settings" should just have a "set_support" method toolpath_settings.set_support_model(support_model)
support_factory(toolpath_settings)
# calculation backend: ODE / None # calculation backend: ODE / None
if self.settings.get("enable_ode"): if self.settings.get("enable_ode"):
......
...@@ -574,20 +574,6 @@ class ToolpathSettings(object): ...@@ -574,20 +574,6 @@ class ToolpathSettings(object):
"speed": float, "speed": float,
"feedrate": float, "feedrate": float,
}, },
"SupportGrid": {
"type": str,
"distance_x": float,
"distance_y": float,
"thickness": float,
"height": float,
"offset_x": float,
"offset_y": float,
"adjustments_x": "list_of_float",
"adjustments_y": "list_of_float",
"average_distance": float,
"minimum_bridges": int,
"length": float,
},
"Program": { "Program": {
"unit": str, "unit": str,
"enable_ode": bool, "enable_ode": bool,
...@@ -612,7 +598,6 @@ class ToolpathSettings(object): ...@@ -612,7 +598,6 @@ class ToolpathSettings(object):
self.program = {} self.program = {}
self.bounds = {} self.bounds = {}
self.tool_settings = {} self.tool_settings = {}
self.support_grid = {}
self.process_settings = {} self.process_settings = {}
def set_bounds(self, bounds): def set_bounds(self, bounds):
...@@ -647,48 +632,11 @@ class ToolpathSettings(object): ...@@ -647,48 +632,11 @@ class ToolpathSettings(object):
def get_tool_settings(self): def get_tool_settings(self):
return self.tool_settings return self.tool_settings
def set_support_grid(self, distance_x, distance_y, thickness, height, def set_support_model(self, model):
offset_x=0.0, offset_y=0.0, adjustments_x=None, self.support_model = model
adjustments_y=None):
if adjustments_x is None: def get_support_model(self):
adjustments_x = [] return self.support_model
if adjustments_y is None:
adjustments_y = []
self.support_grid["type"] = "grid"
self.support_grid["distance_x"] = distance_x
self.support_grid["distance_y"] = distance_y
self.support_grid["offset_x"] = offset_x
self.support_grid["offset_y"] = offset_y
self.support_grid["thickness"] = thickness
self.support_grid["height"] = height
self.support_grid["adjustments_x"] = adjustments_x
self.support_grid["adjustments_y"] = adjustments_y
def set_support_distributed(self, average_distance, minimum_bridges,
thickness, height, length, start_at_corners=False):
if start_at_corners:
self.support_grid["type"] = "distributed_corners"
else:
self.support_grid["type"] = "distributed_edges"
self.support_grid["average_distance"] = average_distance
self.support_grid["minimum_bridges"] = minimum_bridges
self.support_grid["thickness"] = thickness
self.support_grid["height"] = height
self.support_grid["length"] = length
def get_support_grid(self):
result = {}
if self.support_grid:
options = self.support_grid
else:
options = {}
# add all keys from the default list
for key in self.SECTIONS["SupportGrid"].keys():
if options.has_key(key):
result[key] = options[key]
else:
result[key] = None
return result
def set_calculation_backend(self, backend=None): def set_calculation_backend(self, backend=None):
self.program["enable_ode"] = (backend.upper() == "ODE") self.program["enable_ode"] = (backend.upper() == "ODE")
...@@ -738,7 +686,6 @@ class ToolpathSettings(object): ...@@ -738,7 +686,6 @@ class ToolpathSettings(object):
config.readfp(text_stream) config.readfp(text_stream)
for config_dict, section in ((self.bounds, "Bounds"), for config_dict, section in ((self.bounds, "Bounds"),
(self.tool_settings, "Tool"), (self.tool_settings, "Tool"),
(self.support_grid, "SupportGrid"),
(self.process_settings, "Process")): (self.process_settings, "Process")):
for key, value_type in self.SECTIONS[section].items(): for key, value_type in self.SECTIONS[section].items():
value_raw = config.get(section, key, None) value_raw = config.get(section, key, None)
...@@ -775,7 +722,6 @@ class ToolpathSettings(object): ...@@ -775,7 +722,6 @@ class ToolpathSettings(object):
result = [] result = []
for config_dict, section in ((self.bounds, "Bounds"), for config_dict, section in ((self.bounds, "Bounds"),
(self.tool_settings, "Tool"), (self.tool_settings, "Tool"),
(self.support_grid, "SupportGrid"),
(self.process_settings, "Process")): (self.process_settings, "Process")):
# skip empty sections # skip empty sections
if not config_dict: if not config_dict:
......
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
$Id$
Copyright 2011 Lars Kruse <devel@sumpfralle.de>
This file is part of PyCAM.
PyCAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyCAM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
import pycam.Plugins
class ModelSupportDistributed(pycam.Plugins.PluginBase):
UI_FILE = "model_support_distributed.ui"
def setup(self):
if self.gui:
support_expander = self.gui.get_object("DistributedSupportExpander")
support_expander.unparent()
self.core.register_ui("support_model_type_selector",
"Distributed (edges)", "distributed_edges", weight=0)
self.core.register_ui("support_model_type_selector",
"Distributed (corners)", "distributed_corners", weight=10)
self.core.register_ui("support_model_settings", "Grid settings",
support_expander)
self.core.register_event("support-model-changed",
self.update_support_controls)
self.core.register_event("support-model-changed",
self.update_support_model)
grid_length = self.gui.get_object("SupportGridLength")
grid_length.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_length",
grid_length.get_value, grid_length.set_value)
average_distance = self.gui.get_object("GridAverageDistance")
average_distance.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_average_distance",
average_distance.get_value, average_distance.set_value)
minimum_bridges = self.gui.get_object("GridMinBridgesPerPolygon")
minimum_bridges.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_minimum_bridges",
minimum_bridges.get_value, minimum_bridges.set_value)
self.core.set("support_grid_average_distance", 30)
self.core.set("support_grid_minimum_bridges", 2)
self.core.set("support_grid_length", 5)
return True
def update_support_controls(self):
grid_type = self.core.get("support_model_type")
if grid_type in ("distributed_edges", "distributed_corners"):
self.gui.get_object("DistributedSupportExpander").show()
else:
self.gui.get_object("DistributedSupportExpander").hide()
def update_support_model(self, widget=None):
model = self.core.get("model")
if not model:
return
grid_type = self.core.get("support_model_type")
support_model = None
if grid_type in ("distributed_edges", "distributed_corners"):
s = self.core
if (s.get("support_grid_thickness") > 0) \
and (s.get("support_grid_height") > 0) \
and (s.get("support_grid_average_distance") > 0) \
and (s.get("support_grid_minimum_bridges") > 0):
# get the minimum z value of the bounding box
bounds = s.get("current_bounds")
if bounds:
minz = bounds.get_absolute_limits(
reference=model.get_bounds())[0][2]
corner_start = (grid_type == "distributed_corners")
support_model = pycam.Toolpath.SupportGrid.get_support_distributed(
s.get("model"), minz,
s.get("support_grid_average_distance"),
s.get("support_grid_minimum_bridges"),
s.get("support_grid_thickness"),
s.get("support_grid_height"),
s.get("support_grid_length"),
bounds.get_referenced_bounds(s.get("model").get_bounds()),
start_at_corners=corner_start)
if support_model != self.core.get("current_support_model"):
self.core.set("current_support_model", support_model)
self.core.emit_event("visual-item-updated")
This diff is collapsed.
...@@ -47,7 +47,7 @@ CALCULATION_BACKENDS = frozenset((None, "ODE")) ...@@ -47,7 +47,7 @@ CALCULATION_BACKENDS = frozenset((None, "ODE"))
def generate_toolpath_from_settings(model, tp_settings, callback=None): def generate_toolpath_from_settings(model, tp_settings, callback=None):
process = tp_settings.get_process_settings() process = tp_settings.get_process_settings()
grid = tp_settings.get_support_grid() support_model = tp_settings.get_support_model()
backend = tp_settings.get_calculation_backend() backend = tp_settings.get_calculation_backend()
return generate_toolpath(model, tp_settings.get_tool_settings(), return generate_toolpath(model, tp_settings.get_tool_settings(),
tp_settings.get_bounds(), process["path_direction"], tp_settings.get_bounds(), process["path_direction"],
...@@ -55,24 +55,14 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None): ...@@ -55,24 +55,14 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None):
process["material_allowance"], process["overlap_percent"], process["material_allowance"], process["overlap_percent"],
process["step_down"], process["engrave_offset"], process["step_down"], process["engrave_offset"],
process["milling_style"], process["pocketing_type"], process["milling_style"], process["pocketing_type"],
grid["type"], grid["distance_x"], grid["distance_y"], support_model, backend, callback)
grid["thickness"], grid["height"], grid["offset_x"],
grid["offset_y"], grid["adjustments_x"], grid["adjustments_y"],
grid["average_distance"], grid["minimum_bridges"], grid["length"],
backend, callback)
def generate_toolpath(model, tool_settings=None, def generate_toolpath(model, tool_settings=None,
bounds=None, direction="x", bounds=None, direction="x",
path_generator="DropCutter", path_postprocessor="ZigZagCutter", path_generator="DropCutter", path_postprocessor="ZigZagCutter",
material_allowance=0, overlap_percent=0, step_down=0, engrave_offset=0, material_allowance=0, overlap_percent=0, step_down=0, engrave_offset=0,
milling_style="ignore", pocketing_type="none", milling_style="ignore", pocketing_type="none",
support_grid_type=None, support_grid_distance_x=None, support_model=None, calculation_backend=None, callback=None):
support_grid_distance_y=None, support_grid_thickness=None,
support_grid_height=None, support_grid_offset_x=None,
support_grid_offset_y=None, support_grid_adjustments_x=None,
support_grid_adjustments_y=None, support_grid_average_distance=None,
support_grid_minimum_bridges=None, support_grid_length=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
...@@ -103,22 +93,6 @@ def generate_toolpath(model, tool_settings=None, ...@@ -103,22 +93,6 @@ def generate_toolpath(model, tool_settings=None,
@value step_down: maximum height of each layer (for PushCutter) @value step_down: maximum height of each layer (for PushCutter)
@type engrave_offset: float @type engrave_offset: float
@value engrave_offset: toolpath distance to the contour model @value engrave_offset: toolpath distance to the contour model
@type support_grid_distance_x: float
@value support_grid_distance_x: distance between support grid lines along x
@type support_grid_distance_y: float
@value support_grid_distance_y: distance between support grid lines along y
@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 support_grid_offset_x: float
@value support_grid_offset_x: shift the support grid by this value along x
@type support_grid_offset_y: float
@value support_grid_offset_y: shift the support grid by this value along y
@type support_grid_adjustments_x: list(float)
@value support_grid_adjustments_x: manual adjustment of each x-grid bar
@type support_grid_adjustments_y: list(float)
@value support_grid_adjustments_y: manual adjustment of each y-grid bar
@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.
...@@ -156,67 +130,8 @@ def generate_toolpath(model, tool_settings=None, ...@@ -156,67 +130,8 @@ def generate_toolpath(model, tool_settings=None,
# material allowance is not available for these two strategies # material allowance is not available for these two strategies
cutter.set_required_distance(material_allowance) cutter.set_required_distance(material_allowance)
# create the grid model if requested # create the grid model if requested
if (support_grid_type == "grid") \ if support_model:
and (((not support_grid_distance_x is None) \ trimesh_models.append(support_model)
or (not support_grid_distance_y 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_x < 0) or (support_grid_distance_y < 0):
return "The distance of the support grid must be a positive value"
if not ((support_grid_distance_x > 0) or (support_grid_distance_y > 0)):
return "Both distance values for the support grid may not be " \
+ "zero at the same time"
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"
if not callback is None:
callback(text="Preparing support grid model ...")
support_grid_model = pycam.Toolpath.SupportGrid.get_support_grid(
minx, maxx, miny, maxy, minz, support_grid_distance_x,
support_grid_distance_y, support_grid_thickness,
support_grid_height, offset_x=support_grid_offset_x,
offset_y=support_grid_offset_y,
adjustments_x=support_grid_adjustments_x,
adjustments_y=support_grid_adjustments_y)
trimesh_models.append(support_grid_model)
elif (support_grid_type in ("distributed_edges", "distributed_corners")) \
and (not support_grid_average_distance is None) \
and (not support_grid_thickness is None) \
and (not support_grid_length is None):
if support_grid_height is None:
support_grid_height = support_grid_thickness
if support_grid_minimum_bridges is None:
support_grid_minimum_bridges = 2
if support_grid_average_distance <= 0:
return "The average support grid distance must be a positive value"
if support_grid_minimum_bridges <= 0:
return "The minimum number of bridged per polygon 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"
if not callback is None:
callback(text="Preparing support grid model ...")
# check which model to choose
if not contour_model is None:
model = contour_model
else:
model = trimesh_models[0]
start_at_corners = (support_grid_type == "distributed_corners")
support_grid_model = pycam.Toolpath.SupportGrid.get_support_distributed(
model, minz, support_grid_average_distance,
support_grid_minimum_bridges, support_grid_thickness,
support_grid_height, support_grid_length,
bounds, start_at_corners=start_at_corners)
trimesh_models.append(support_grid_model)
elif (not support_grid_type) or (support_grid_type == "none"):
pass
else:
return "Invalid support grid type selected: %s" % support_grid_type
# Adapt the contour_model to the engraving offset. This offset is # Adapt the contour_model to the engraving offset. This offset is
# considered to be part of the material_allowance. # considered to be part of the material_allowance.
if (not contour_model is None) and (engrave_offset != 0): if (not contour_model is None) and (engrave_offset != 0):
......
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