Commit 2d77016c authored by sumpfralle's avatar sumpfralle

* join tangential moves (removes the inner points in a colinear set of adjacent path points)

* added a "compare" function to the "Point" class


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@304 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent e505a992
Version 0.2.4 - UNRELEASED
* join tangential moves (removes the inner points in a colinear set of adjacent path points)
Version 0.2.3 - 2010-04-05 Version 0.2.3 - 2010-04-05
* GUI change: tool and process settings can be combined into tasks * GUI change: tool and process settings can be combined into tasks
* store configured settings to a file in the user's home directory * store configured settings to a file in the user's home directory
......
...@@ -13,6 +13,28 @@ class Point: ...@@ -13,6 +13,28 @@ class Point:
def __repr__(self): def __repr__(self):
return "Point%d<%g,%g,%g>" % (self.id,self.x,self.y,self.z) return "Point%d<%g,%g,%g>" % (self.id,self.x,self.y,self.z)
def __cmp__(self, other):
""" Two points are equal if all dimensions are identical.
Otherwise the result is based on the individual x/y/z comparisons.
"""
if self.__class__ == other.__class__:
if (self.x == other.x) and (self.y == other.y) and (self.z == other.y):
return 0
elif self.x < other.y:
return -1
elif self.x > other.y:
return 1
elif self.y < other.y:
return -1
elif self.y > other.y:
return 1
elif self.z < other.z:
return -1
else:
return 1
else:
return cmp(str(self), str(other))
def mul(self, c): def mul(self, c):
return Point(self.x*c,self.y*c,self.z*c) return Point(self.x*c,self.y*c,self.z*c)
......
from pycam.Geometry import * from pycam.Geometry import *
def _check_colinearity(p1, p2, p3):
v1 = p2.sub(p1)
v2 = p3.sub(p2)
v1.normalize()
v2.normalize()
# compare if the normalized distances between p1-p2 and p2-p3 are equal
return v1 == v2
class PathAccumulator: class PathAccumulator:
def __init__(self, zigzag=False): def __init__(self, zigzag=False):
self.paths = [] self.paths = []
...@@ -9,6 +17,11 @@ class PathAccumulator: ...@@ -9,6 +17,11 @@ class PathAccumulator:
def append(self, p): def append(self, p):
if self.curr_path == None: if self.curr_path == None:
self.curr_path = Path() self.curr_path = Path()
if (len(self.curr_path.points) >= 2) and \
(_check_colinearity(self.curr_path.points[-2], self.curr_path.points[-1], p)):
# remove the previous point since it is in line with its
# predecessor and the new point
self.curr_path.points.pop()
self.curr_path.append(p) self.curr_path.append(p)
def new_direction(self, dir): def new_direction(self, dir):
......
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