Commit a8948307 authored by Lars Kruse's avatar Lars Kruse

rebased the libarea patch (was based on PyCAM v0.5.1)

parent 8a7d06f6
def _pocket_model(model): import copy
import area
import pycam.Geometry.Line
import pycam.Geometry.Polygon
def _pocket_model(polygons):
"""Create pocketing path.""" """Create pocketing path."""
# libarea.Vertex Linetypes # libarea.Vertex Linetypes
LINE = 0 LINE = 0
ARC_CCW = 1 ARC_CCW = 1
ARC_CW = -1 ARC_CW = -1
print "Model\n#lines:", model.get_num_of_lines() #print "Model\n#lines:", model.get_num_of_lines()
print "#line_groups:", len(model.get_polygons()) print "#line_groups:", len(polygons)
# copy pycam.Model to libarea.Area # copy pycam.Model to libarea.Area
my_area = area.Area() my_area = area.Area()
my_pocketParams = PocketParams() my_pocketParams = PocketParams()
for lg in model.get_polygons(): for lg in polygons:
#print "line_group:", lg #print "line_group:", lg
print "line_group() #Points:", len(lg.get_points()) print "line_group() #Points:", len(lg.get_points())
my_curve = area.Curve() my_curve = area.Curve()
...@@ -24,12 +32,12 @@ def _pocket_model(model): ...@@ -24,12 +32,12 @@ def _pocket_model(model):
for pt in lg.get_points(): for pt in lg.get_points():
#print "point(x,y): (%f,%f)" % (pt.x, pt.y) #print "point(x,y): (%f,%f)" % (pt.x, pt.y)
if p_first: if p_first:
my_curve.append(area.Vertex(area.Point(pt.x, pt.y))) my_curve.append(area.Vertex(area.Point(pt[0], pt[1])))
else: else:
if p_skip: # ugly hack to load same begin/end point only once if p_skip: # ugly hack to load same begin/end point only once
p_skip = False p_skip = False
else: else:
my_curve.append(area.Vertex(area.Point(pt.x, pt.y))) my_curve.append(area.Vertex(area.Point(pt[0], pt[1])))
p_skip = True p_skip = True
""" """
if p_previous is None: if p_previous is None:
...@@ -103,16 +111,16 @@ def _pocket_area(a, params, polygons): ...@@ -103,16 +111,16 @@ def _pocket_area(a, params, polygons):
#print "areaList()" #print "areaList()"
for c in a.getCurves(): for c in a.getCurves():
print "Curve() #vertices:", c.getNumVertices() print "Curve() #vertices:", c.getNumVertices()
my_poly = Polygon() my_poly = pycam.Geometry.Polygon.Polygon()
p_previous = None p_previous = None
p_next = None p_next = None
for vt in c.getVertices(): for vt in c.getVertices():
# from 2D to 3D with Z=0 # from 2D to 3D with Z=0
if p_previous is None: if p_previous is None:
p_previous = Point(vt.p.x, vt.p.y, 0.0) p_previous = (vt.p.x, vt.p.y, 0.0)
else: else:
p_next = Point(vt.p.x, vt.p.y, 0.0) p_next = (vt.p.x, vt.p.y, 0.0)
my_poly.append(Line(p_previous, p_next)) my_poly.append(pycam.Geometry.Line.Line(p_previous, p_next))
p_previous = p_next p_previous = p_next
#polygons.append(Line(p1, p2)) #polygons.append(Line(p1, p2))
#polygons.append(Point(vt.p.x, vt.p.y, 0.0)) #polygons.append(Point(vt.p.x, vt.p.y, 0.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