Commit 4e0ca13e authored by sumpfralle's avatar sumpfralle

removed "edges" as initialization parameters for Triangles

 * otherwise they are currently not transformed
 * this increases memory usage slightly, but avoids out-dated edge information


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@638 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0138faeb
......@@ -40,25 +40,12 @@ class Triangle(TransformableContainer):
id = 0
# points are expected to be in ClockWise order
def __init__(self, p1=None, p2=None, p3=None, e1=None, e2=None, e3=None,
n=None):
def __init__(self, p1=None, p2=None, p3=None, n=None):
self.id = Triangle.id
Triangle.id += 1
self.p1 = p1
self.p2 = p2
self.p3 = p3
if (not e1) and p1 and p2:
self.e1 = Line(p1, p2)
else:
self.e1 = e1
if (not e2) and p2 and p3:
self.e2 = Line(p2, p3)
else:
self.e2 = e2
if (not e3) and p3 and p1:
self.e3 = Line(p3, p1)
else:
self.e3 = e3
self.normal = n
self.reset_cache()
......@@ -70,6 +57,9 @@ class Triangle(TransformableContainer):
self.maxx = max(self.p1.x, self.p2.x, self.p3.x)
self.maxy = max(self.p1.y, self.p2.y, self.p3.y)
self.maxz = max(self.p1.z, self.p2.z, self.p3.z)
self.e1 = Line(self.p1, self.p2)
self.e2 = Line(self.p2, self.p3)
self.e3 = Line(self.p3, self.p1)
# calculate normal, if p1-p2-pe are in clockwise order
if self.normal is None:
self.normal = self.p3.sub(self.p1).cross(self.p2.sub( \
......
......@@ -53,27 +53,6 @@ def UniqueVertex(x, y, z):
vertices += 1
return Point(x, y, z)
def UniqueEdge(p1, p2):
global edges
if hasattr(p1, "edges"):
for e in p1.edges:
if e.p1 == p1 and e.p2 == p2:
return e
if e.p2 == p1 and e.p1 == p2:
return e
edges += 1
e = Line(p1, p2)
if not hasattr(p1, "edges"):
p1.edges = [e]
else:
p1.edges.append(e)
if not hasattr(p2, "edges"):
p2.edges = [e]
else:
p2.edges.append(e)
return e
def ImportModel(filename, use_kdtree=True, program_locations=None, unit=None):
global vertices, edges, kdtree
vertices = 0
......@@ -158,11 +137,9 @@ def ImportModel(filename, use_kdtree=True, program_locations=None, unit=None):
n = None
if dotcross > 0:
t = Triangle(p1, p2, p3, UniqueEdge(p1, p2), UniqueEdge(p2, p3),
UniqueEdge(p3, p1))
t = Triangle(p1, p2, p3)
elif dotcross < 0:
t = Triangle(p1, p3, p2, UniqueEdge(p1, p3), UniqueEdge(p3, p2),
UniqueEdge(p2, p1))
t = Triangle(p1, p3, p2)
else:
# the three points are in a line - or two points are identical
# usually this is caused by points, that are too close together
......@@ -241,11 +218,9 @@ def ImportModel(filename, use_kdtree=True, program_locations=None, unit=None):
# make sure the points are in ClockWise order
dotcross = n.dot(p3.sub(p1).cross(p2.sub(p1)))
if dotcross > 0:
t = Triangle(p1, p2, p3, UniqueEdge(p1, p2),
UniqueEdge(p2, p3), UniqueEdge(p3, p1), n)
t = Triangle(p1, p2, p3, n)
elif dotcross < 0:
t = Triangle(p1, p3, p2, UniqueEdge(p1, p3),
UniqueEdge(p3, p2), UniqueEdge(p2, p1), n)
t = Triangle(p1, p3, p2, n)
else:
# The three points are in a line - or two points are
# identical. Usually this is caused by points, that are too
......
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