Commit bf4ec246 authored by lode_leroy's avatar lode_leroy

fix coordinate system for Art of Illusion exported STL files

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@6 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 15fec660
...@@ -5,7 +5,8 @@ from pycam.Geometry import * ...@@ -5,7 +5,8 @@ from pycam.Geometry import *
def ImportModel(filename): def ImportModel(filename):
model = Model() model = Model()
f = file(filename,"r") f = file(filename,"r")
solid = re.compile("\s*solid\s+(\w+)\s+") solid = re.compile("\s*solid\s+(\w+)\s+.*")
solid_AOI = re.compile("\s*solid\s+\"(\w+)\"; Produced by Art of Illusion.*")
endsolid = re.compile("\s*endsolid\s+") endsolid = re.compile("\s*endsolid\s+")
facet = re.compile("\s*facet\s+") facet = re.compile("\s*facet\s+")
normal = re.compile("\s*facet\s+normal\s+(?P<x>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<y>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<z>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+") normal = re.compile("\s*facet\s+normal\s+(?P<x>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<y>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<z>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+")
...@@ -19,7 +20,14 @@ def ImportModel(filename): ...@@ -19,7 +20,14 @@ def ImportModel(filename):
p1 = None p1 = None
p2 = None p2 = None
p3 = None p3 = None
AOI = False
for line in f: for line in f:
m = solid_AOI.match(line)
if m:
print "AOI"
model.name = m.group(1)
AOI = True
continue
m = solid.match(line) m = solid.match(line)
if m: if m:
model.name = m.group(1) model.name = m.group(1)
...@@ -28,6 +36,9 @@ def ImportModel(filename): ...@@ -28,6 +36,9 @@ def ImportModel(filename):
if m: if m:
m = normal.match(line) m = normal.match(line)
if m: if m:
if AOI:
n = Point(float(m.group('x')),-float(m.group('z')),float(m.group('y')))
else:
n = Point(float(m.group('x')),float(m.group('y')),float(m.group('z'))) n = Point(float(m.group('x')),float(m.group('y')),float(m.group('z')))
continue continue
m = loop.match(line) m = loop.match(line)
...@@ -35,6 +46,9 @@ def ImportModel(filename): ...@@ -35,6 +46,9 @@ def ImportModel(filename):
continue continue
m = vertex.match(line) m = vertex.match(line)
if m: if m:
if AOI:
p = Point(float(m.group('x')),-float(m.group('z')),float(m.group('y')))
else:
p = Point(float(m.group('x')),float(m.group('y')),float(m.group('z'))) p = Point(float(m.group('x')),float(m.group('y')),float(m.group('z')))
# TODO: check for duplicate points (using kdtree?) # TODO: check for duplicate points (using kdtree?)
if p1 == None: if p1 == None:
......
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