Commit c57db29f authored by lode_leroy's avatar lode_leroy

fix missing normals in STL from blender

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@231 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0fb398c9
...@@ -106,6 +106,10 @@ def ImportModel(filename, use_kdtree=True): ...@@ -106,6 +106,10 @@ def ImportModel(filename, use_kdtree=True):
attribs = unpack("<H",f.read(2)) attribs = unpack("<H",f.read(2))
dotcross = n.dot(p3.sub(p1).cross(p2.sub(p1))) dotcross = n.dot(p3.sub(p1).cross(p2.sub(p1)))
if a1==0 and a2==0 and a3==0:
dotcross = p3.sub(p1).cross(p2.sub(p1)).z
n = None
if dotcross > 0: if dotcross > 0:
t = Triangle(p1, p2, p3, UniqueEdge(p1,p2), UniqueEdge(p2,p3), UniqueEdge(p3,p1)) t = Triangle(p1, p2, p3, UniqueEdge(p1,p2), UniqueEdge(p2,p3), UniqueEdge(p3,p1))
elif dotcross < 0: elif dotcross < 0:
...@@ -116,7 +120,9 @@ def ImportModel(filename, use_kdtree=True): ...@@ -116,7 +120,9 @@ def ImportModel(filename, use_kdtree=True):
# check the tolerance value in pycam/Geometry/PointKdtree.py # check the tolerance value in pycam/Geometry/PointKdtree.py
print "ERROR: skipping invalid triangle: %s / %s / %s" % (p1, p2, p3) print "ERROR: skipping invalid triangle: %s / %s / %s" % (p1, p2, p3)
continue continue
t._normal = n if n:
t._normal = n
model.append(t) model.append(t)
else: else:
AOI = False AOI = False
......
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