Fix loading of ascii stl files with MacOS line-ends.

This commit is contained in:
daid303 2012-10-04 12:24:43 +02:00
parent 76309c7f5b
commit 6edb5c29ca

View file

@ -21,16 +21,18 @@ class stlModel(mesh.mesh):
def _loadAscii(self, f): def _loadAscii(self, f):
cnt = 0 cnt = 0
for line in f: for lines in f:
if 'vertex' in line: for line in lines.split('\r'):
cnt += 1 if 'vertex' in line:
cnt += 1
self._prepareVertexCount(int(cnt)) self._prepareVertexCount(int(cnt))
f.seek(5, os.SEEK_SET) f.seek(5, os.SEEK_SET)
cnt = 0 cnt = 0
for line in f: for lines in f:
if 'vertex' in line: for line in lines.split('\r'):
data = line.split() if 'vertex' in line:
self.addVertex(float(data[1]), float(data[2]), float(data[3])) data = line.split()
self.addVertex(float(data[1]), float(data[2]), float(data[3]))
def _loadBinary(self, f): def _loadBinary(self, f):
#Skip the header #Skip the header