Commit c312d850 authored by Guillaume Seguin's avatar Guillaume Seguin

Cleanup

parent b3e27469
......@@ -88,7 +88,7 @@ def emitstl(filename, facets = [], objname = "stltool_export", binary = 1):
class stl:
class stl(object):
def __init__(self, filename = None):
self.facet = [[0, 0, 0],[[0, 0, 0],[0, 0, 0],[0, 0, 0]]]
self.facets = []
......@@ -113,27 +113,26 @@ class stl:
print "Not an ascii stl solid - attempting to parse as binary"
f = open(filename, "rb")
buf = f.read(84)
while(len(buf)<84):
newdata = f.read(84-len(buf))
while len(buf) < 84:
newdata = f.read(84 - len(buf))
if not len(newdata):
break
buf+=newdata
buf += newdata
facetcount = struct.unpack_from("<I", buf, 80)
facetformat = struct.Struct("<ffffffffffffH")
for i in xrange(facetcount[0]):
buf = f.read(50)
while(len(buf)<50):
newdata = f.read(50-len(buf))
while len(buf) < 50:
newdata = f.read(50 - len(buf))
if not len(newdata):
break
buf+=newdata
buf += newdata
fd = list(facetformat.unpack(buf))
self.name = "binary soloid"
self.facet = [fd[:3],[fd[3:6], fd[6:9], fd[9:12]]]
self.facets+=[self.facet]
facet = self.facet
self.facetsminz+=[(min(map(lambda x:x[2], facet[1])), facet)]
self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])), facet)]
facet = [fd[:3],[fd[3:6], fd[6:9], fd[9:12]]]
self.facets.append(facet)
self.facetsminz.append((min(map(lambda x:x[2], facet[1])), facet))
self.facetsmaxz.append((max(map(lambda x:x[2], facet[1])), facet))
f.close()
return
......
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