Commit 5f1a3d10 authored by sumpfralle's avatar sumpfralle

fixed handling of empty "filename_templates" in "get_filename_via_dialog"

fix floating inaccuracy problem in ContourFollow
added string representation for Bounds instances


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@722 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0a221447
...@@ -2894,8 +2894,10 @@ class ProjectGui: ...@@ -2894,8 +2894,10 @@ class ProjectGui:
for file_filter in get_filters_from_list(type_filter): for file_filter in get_filters_from_list(type_filter):
dialog.add_filter(file_filter) dialog.add_filter(file_filter)
# guess the export filename based on the model's filename # guess the export filename based on the model's filename
valid_templates = [one_template for one_template in filename_templates if filename_templates is None:
if one_template] valid_templates = []
else:
valid_templates = [t for t in filename_templates if one_template]
if valid_templates: if valid_templates:
filename_template = valid_templates[0] filename_template = valid_templates[0]
# remove the extension # remove the extension
......
...@@ -348,11 +348,16 @@ class ContourFollow: ...@@ -348,11 +348,16 @@ class ContourFollow:
if len(points_above) == 0: if len(points_above) == 0:
# the highest point of the triangle is at z # the highest point of the triangle is at z
outer_edges = [] outer_edges = []
else:
if abs(triangle.minz - z) < epsilon:
# This is just an accuracy issue (see the
# "triangle.minz >= z" statement above).
outer_edges = []
else: else:
# this should not happen # this should not happen
raise ValueError(("Could not find a waterline, but " \ raise ValueError(("Could not find a waterline, but " \
+ "there are points above z level (%f): %s / %s") \ + "there are points above z level (%f): " \
% (z, triangle, points_above)) + "%s / %s") % (z, triangle, points_above))
else: else:
# remove points that are not part of the waterline # remove points that are not part of the waterline
points_above = [p for p in points_above points_above = [p for p in points_above
...@@ -451,6 +456,7 @@ class ContourFollow: ...@@ -451,6 +456,7 @@ class ContourFollow:
proj_cp = plane.get_point_projection(cp) proj_cp = plane.get_point_projection(cp)
# e.g. the Spherical Cutter often does not collide exactly above # e.g. the Spherical Cutter often does not collide exactly above
# the potential collision line. # the potential collision line.
# TODO: maybe an "is cp inside of the triangle" check would be good?
if (triangle is hit_t) or (edge.is_point_inside(proj_cp)): if (triangle is hit_t) or (edge.is_point_inside(proj_cp)):
result.append((cl, edge)) result.append((cl, edge))
# continue with the next outer_edge # continue with the next outer_edge
......
...@@ -177,6 +177,11 @@ class Bounds: ...@@ -177,6 +177,11 @@ class Bounds:
self.set_bounds(bounds_low, bounds_high) self.set_bounds(bounds_low, bounds_high)
self.reference = reference self.reference = reference
def __repr__(self):
bounds_type_labels = ("relative", "fixed", "custom")
return "Bounds(%s, %s, %s)" % (bounds_type_labels[self.bounds_type],
self.bounds_low, self.bounds_high)
def is_valid(self): def is_valid(self):
for index in range(3): for index in range(3):
if self.bounds_low[index] > self.bounds_high[index]: if self.bounds_low[index] > self.bounds_high[index]:
......
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