From 5939c3d1c154a18b650183cde5dd77420a089666 Mon Sep 17 00:00:00 2001 From: Stan Seibert Date: Thu, 28 Jul 2011 12:59:18 -0400 Subject: Support for reading bz2 compressed STL files. --- stl.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'stl.py') diff --git a/stl.py b/stl.py index f88c3fa..9a63306 100644 --- a/stl.py +++ b/stl.py @@ -2,9 +2,13 @@ import numpy as np import string import struct from geometry import Mesh +import bz2 def mesh_from_stl(filename): - f = open(filename) + if filename.endswith('.bz2'): + f = bz2.BZ2File(filename) + else: + f = open(filename) buf = f.read(200) f.close() @@ -15,7 +19,10 @@ def mesh_from_stl(filename): return mesh_from_ascii_stl(filename) def mesh_from_ascii_stl(filename): - f = open(filename) + if filename.endswith('.bz2'): + f = bz2.BZ2File(filename) + else: + f = open(filename) vertices = [] triangles = [] -- cgit