Commit 957bced6 authored by sumpfralle's avatar sumpfralle

fixed minor typos

stabilized the barycenter function


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@972 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 3af29696
......@@ -180,24 +180,31 @@ class Polygon(TransformableContainer):
cyz += (p1.y + p2.y) * (p1.y * p2.z - p1.z * p2.y)
czx += (p1.z + p2.z) * (p1.z * p2.x - p1.x * p2.z)
czy += (p1.z + p2.z) * (p1.y * p2.z - p1.z * p2.y)
if self.minz == self.maxz:
if abs(self.maxz - self.minz) < epsilon:
return Point(cxy / (6 * area), cyx / (6 * area), self.minz)
elif self.miny == self.maxy:
elif abs(self.maxy - self.miny) < epsilon:
return Point(cxz / (6 * area), self.miny, czx / (6 * area))
elif self.minz == self.maxz:
elif abs(self.maxx - self.minx) < epsilon:
return Point(self.minx, cyz / (6 * area), czy / (6 * area))
else:
# calculate area of xy projection
area_xy = self.get_plane_projection(Plane(Point(0, 0, 0),
Point(0, 0, 1))).get_area()
area_xz = self.get_plane_projection(Plane(Point(0, 0, 0),
Point(0, 1, 0))).get_area()
area_yz = self.get_plane_projection(Plane(Point(0, 0, 0),
Point(1, 0, 0))).get_area()
poly_xy = self.get_plane_projection(Plane(Point(0, 0, 0),
Point(0, 0, 1)))
poly_xz = self.get_plane_projection(Plane(Point(0, 0, 0),
Point(0, 1, 0)))
poly_yz = self.get_plane_projection(Plane(Point(0, 0, 0),
Point(1, 0, 0)))
if (poly_xy is None) or (poly_xz is None) or (poly_yz is None):
log.warn("Invalid polygon projection for barycenter: %s" \
% str(self))
return None
area_xy = poly_xy.get_area()
area_xz = poly_xz.get_area()
area_yz = poly_yz.get_area()
if 0 in (area_xy, area_xz, area_yz):
log.info("Failed assumtion: zero-sized projected area - " + \
"%s / %s / %s" % (area_xy, area_xz, area_yz))
return Point(0, 0, 0)
return None
if abs(cxy / area_xy - cxz / area_xz) > epsilon:
log.info("Failed assumption: barycenter xy/xz - %s / %s" % \
(cxy / area_xy, cxz / area_xz))
......
......@@ -3639,7 +3639,7 @@ class ProjectGui:
self.settings.get("support_grid_thickness"),
self.settings.get("support_grid_height"),
self.settings.get("support_grid_length"),
start_at_corner=corner_start)
start_at_corners=corner_start)
elif grid_type == GRID_TYPES["none"]:
pass
else:
......
......@@ -660,8 +660,8 @@ class ToolpathSettings:
self.support_grid["adjustments_y"] = adjustments_y
def set_support_distributed(self, average_distance, minimum_bridges,
thickness, height, length, start_at_corner=False):
if start_at_corner:
thickness, height, length, start_at_corners=False):
if start_at_corners:
self.support_grid["type"] = "distributed_corners"
else:
self.support_grid["type"] = "distributed_edges"
......
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