Commit b116e3b5 authored by sumpfralle's avatar sumpfralle

fixed support grid calculation for cropped models

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1036 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent fd51996d
...@@ -572,6 +572,11 @@ class ContourModel(BaseModel): ...@@ -572,6 +572,11 @@ class ContourModel(BaseModel):
result.append(poly.get_reversed()) result.append(poly.get_reversed())
return result return result
def get_cropped_model_by_bounds(self, bounds):
low, high = bounds.get_absolute_limits()
return self.get_cropped_model(low[0], high[0], low[1], high[1],
low[2], high[2])
def get_cropped_model(self, minx, maxx, miny, maxy, minz, maxz): def get_cropped_model(self, minx, maxx, miny, maxy, minz, maxz):
new_line_groups = [] new_line_groups = []
for group in self._line_groups: for group in self._line_groups:
......
...@@ -878,7 +878,7 @@ class ProjectGui: ...@@ -878,7 +878,7 @@ class ProjectGui:
# update the speed factor label # update the speed factor label
speed_factor_widget.connect("value-changed", speed_factor_widget.connect("value-changed",
lambda widget: self.gui.get_object("SimulationSpeedFactorValueLabel").set_label( lambda widget: self.gui.get_object("SimulationSpeedFactorValueLabel").set_label(
"%g" % self.settings.get("simulation_speed_factor"))) "%.2f" % self.settings.get("simulation_speed_factor")))
self.simulation_window = self.gui.get_object("SimulationDialog") self.simulation_window = self.gui.get_object("SimulationDialog")
self.simulation_window.connect("delete-event", self.finish_toolpath_simulation) self.simulation_window.connect("delete-event", self.finish_toolpath_simulation)
# store the original content (for adding the number of current toolpaths in "update_toolpath_table") # store the original content (for adding the number of current toolpaths in "update_toolpath_table")
...@@ -1401,6 +1401,7 @@ class ProjectGui: ...@@ -1401,6 +1401,7 @@ class ProjectGui:
s.get("support_grid_thickness"), s.get("support_grid_thickness"),
s.get("support_grid_height"), s.get("support_grid_height"),
s.get("support_grid_length"), s.get("support_grid_length"),
bounds.get_referenced_bounds(s.get("model").get_bounds()),
start_at_corners=corner_start) start_at_corners=corner_start)
elif grid_type == GRID_TYPES["none"]: elif grid_type == GRID_TYPES["none"]:
pass pass
...@@ -3257,14 +3258,23 @@ class ProjectGui: ...@@ -3257,14 +3258,23 @@ class ProjectGui:
for index in range(3): for index in range(3):
# enabled, if dimension is non-zero # enabled, if dimension is non-zero
state = model_dims[index] != 0 state = model_dims[index] != 0
get_control(index, "low").set_sensitive(state)
get_control(index, "high").set_sensitive(state) get_control(index, "high").set_sensitive(state)
if (index == 2) and isinstance(self.model,
pycam.Geometry.Model.ContourModel):
# disable lower z for contour models
state = False
get_control(index, "low").set_sensitive(state)
else: else:
# non-relative margins: enable all controls # non-relative margins: enable all controls
for index in range(3): for index in range(3):
get_control(index, "low").set_sensitive(True)
get_control(index, "high").set_sensitive(True) get_control(index, "high").set_sensitive(True)
if (index == 2) and isinstance(self.model,
pycam.Geometry.Model.ContourModel):
# disable lower z for contour models
state = False
else:
state = True
get_control(index, "low").set_sensitive(state)
def update_bounds_table(self, new_index=None, skip_model_update=False): def update_bounds_table(self, new_index=None, skip_model_update=False):
# reset the model data and the selection # reset the model data and the selection
......
...@@ -29,6 +29,7 @@ from pycam.Cutters.CylindricalCutter import CylindricalCutter ...@@ -29,6 +29,7 @@ from pycam.Cutters.CylindricalCutter import CylindricalCutter
import pycam.Cutters import pycam.Cutters
import pycam.Toolpath.SupportGrid import pycam.Toolpath.SupportGrid
import pycam.Toolpath.MotionGrid import pycam.Toolpath.MotionGrid
import pycam.Toolpath
import pycam.Geometry.Model import pycam.Geometry.Model
from pycam.Utils import ProgressCounter from pycam.Utils import ProgressCounter
import pycam.Utils.log import pycam.Utils.log
...@@ -130,12 +131,12 @@ def generate_toolpath(model, tool_settings=None, ...@@ -130,12 +131,12 @@ def generate_toolpath(model, tool_settings=None,
engrave_offset = number(engrave_offset) engrave_offset = number(engrave_offset)
if bounds is None: if bounds is None:
# no bounds were given - we use the boundaries of the model # no bounds were given - we use the boundaries of the model
minx, miny, minz = (model.minx, model.miny, model.minz) bounds = pycam.Toolpath.Bounds(pycam.Toolpath.Bounds.TYPE_CUSTOM,
maxx, maxy, maxz = (model.maxx, model.maxy, model.maxz) (model.minx, model.miny, model.minz),
else: (model.maxx, model.maxy, model.maxz))
bounds_low, bounds_high = bounds.get_absolute_limits() bounds_low, bounds_high = bounds.get_absolute_limits()
minx, miny, minz = [number(value) for value in bounds_low] minx, miny, minz = [number(value) for value in bounds_low]
maxx, maxy, maxz = [number(value) for value in bounds_high] maxx, maxy, maxz = [number(value) for value in bounds_high]
# trimesh model or contour model? # trimesh model or contour model?
if isinstance(model, pycam.Geometry.Model.ContourModel): if isinstance(model, pycam.Geometry.Model.ContourModel):
# contour model # contour model
...@@ -210,7 +211,7 @@ def generate_toolpath(model, tool_settings=None, ...@@ -210,7 +211,7 @@ def generate_toolpath(model, tool_settings=None,
model, minz, support_grid_average_distance, model, minz, support_grid_average_distance,
support_grid_minimum_bridges, support_grid_thickness, support_grid_minimum_bridges, support_grid_thickness,
support_grid_height, support_grid_length, support_grid_height, support_grid_length,
start_at_corners=start_at_corners) bounds, start_at_corners=start_at_corners)
trimesh_models.append(support_grid_model) trimesh_models.append(support_grid_model)
elif (not support_grid_type) or (support_grid_type == "none"): elif (not support_grid_type) or (support_grid_type == "none"):
pass pass
......
...@@ -151,17 +151,19 @@ def get_support_grid(minx, maxx, miny, maxy, z_plane, dist_x, dist_y, thickness, ...@@ -151,17 +151,19 @@ def get_support_grid(minx, maxx, miny, maxy, z_plane, dist_x, dist_y, thickness,
return grid_model return grid_model
def get_support_distributed(model, z_plane, average_distance, def get_support_distributed(model, z_plane, average_distance,
min_bridges_per_polygon, thickness, height, length, min_bridges_per_polygon, thickness, height, length, bounds,
start_at_corners=False): start_at_corners=False):
if (average_distance == 0) or (length == 0) or (thickness == 0) \ if (average_distance == 0) or (length == 0) or (thickness == 0) \
or (height == 0): or (height == 0):
return return
result = Model() result = Model()
if hasattr(model, "get_polygons"): if hasattr(model, "get_polygons"):
polygons = model.get_polygons(z=z_plane, ignore_below=False) polygons = model.get_cropped_model_by_bounds(bounds).get_polygons(
z=z_plane, ignore_below=False)
else: else:
polygons = model.get_waterline_contour(Plane(Point(0, 0, z_plane), polygons = model.get_waterline_contour(Plane(Point(0, 0, z_plane),
Vector(0, 0, 1))).get_polygons() Vector(0, 0, 1))).get_cropped_model_by_bounds(bounds)\
.get_polygons()
# minimum required distance between two bridge start points # minimum required distance between two bridge start points
avoid_distance = 1.5 * (abs(length) + thickness) avoid_distance = 1.5 * (abs(length) + thickness)
if start_at_corners: if start_at_corners:
......
...@@ -355,6 +355,10 @@ class Bounds: ...@@ -355,6 +355,10 @@ class Bounds:
else: else:
self.bounds_type = bounds_type self.bounds_type = bounds_type
def get_referenced_bounds(self, reference):
return Bounds(bounds_type=self.bounds_type, bounds_low=self.bounds_low,
bounds_high=self.bounds_high, reference=reference)
def get_bounds(self): def get_bounds(self):
return self.bounds_low[:], self.bounds_high[:] return self.bounds_low[:], self.bounds_high[:]
...@@ -392,7 +396,7 @@ class Bounds: ...@@ -392,7 +396,7 @@ class Bounds:
in (Bounds.TYPE_RELATIVE_MARGIN, Bounds.TYPE_FIXED_MARGIN): in (Bounds.TYPE_RELATIVE_MARGIN, Bounds.TYPE_FIXED_MARGIN):
if reference is None: if reference is None:
raise ValueError, "any non-custom boundary definition " \ raise ValueError, "any non-custom boundary definition " \
+ "requires an a reference object for caluclating " \ + "requires a reference object for caluclating " \
+ "absolute limits" + "absolute limits"
else: else:
ref_low, ref_high = reference.get_absolute_limits() ref_low, ref_high = reference.get_absolute_limits()
......
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