Skip to content

Commit 008baae

Browse files
author
Tristan
committed
fixed test, changed from scipy.imread to pylab.imread in some cases
due to odd PIL-related bugs on Linux
1 parent 229f9d8 commit 008baae

File tree

7 files changed

+27384
-10201
lines changed

7 files changed

+27384
-10201
lines changed

stl_tools/numpy2stl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ def numpy2stl(A, fn, scale=0.1, mask_val=-np.inf, ascii=False,
107107
n1, n2 = np.zeros(3), np.zeros(3)
108108

109109
if (this_pt[-1] > mask_val and top_right[-1] > mask_val and
110-
bottom_left[-1] > mask_val):
110+
bottom_left[-1] > mask_val):
111111

112112
facet = np.concatenate([n1, top_right, this_pt, bottom_left])
113113
facets.append(facet)
114114

115115
if (this_pt[-1] > mask_val and bottom_right[-1] > mask_val and
116-
bottom_left[-1] > mask_val):
116+
bottom_left[-1] > mask_val):
117117

118118
facet = np.concatenate([n2, bottom_right, this_pt, bottom_left])
119119
facets.append(facet)
@@ -136,4 +136,4 @@ def numpy2stl(A, fn, scale=0.1, mask_val=-np.inf, ascii=False,
136136
if __name__ == "__main__":
137137
from scipy.misc import lena
138138
A = lena()
139-
numpy2stl(A, "lena.stl")
139+
numpy2stl(A, "lena.stl")

stl_tools/test/TEST.csv

Lines changed: 99 additions & 99 deletions
Large diffs are not rendered by default.

stl_tools/test/TEST.png

-990 Bytes
Binary file not shown.

stl_tools/test/TEST_ascii.stl

Lines changed: 27276 additions & 10091 deletions
Large diffs are not rendered by default.

stl_tools/test/TEST_bin.stl

37.1 KB
Binary file not shown.

stl_tools/test/test_model.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import unittest
44

55
import numpy as np
6-
from scipy.misc import imread, imresize
6+
from scipy.misc import imresize
77
from stl_tools import text2array, numpy2stl
88

99

@@ -21,7 +21,7 @@ def test_text(self):
2121
Covers the text2png and text2array functions.
2222
"""
2323

24-
A = text2array("TEST", fontsize=1000)[:, :, 0]
24+
A = text2array("TEST", fontsize=1000)
2525
A = imresize(A, (100, 100))
2626
#np.savetxt("TEST.csv", A, delimiter=',')
2727
B = np.loadtxt("TEST.csv", delimiter=',')
@@ -32,10 +32,10 @@ def test_png(self):
3232
""" Tests creation of an STL from a PNG.
3333
Covers the text2array function.
3434
"""
35-
# test ascii output
36-
A = imread("TEST.png")
3735

38-
numpy2stl(A, "OUT_.stl", scale=0.05, mask_val=6., ascii=True)
36+
# test ascii output
37+
A = imresize([[0, 1], [1, 0]], (64, 64))
38+
numpy2stl(A, "OUT_.stl", scale=0.05, mask_val=3., ascii=True)
3939
reference = open("TEST_ascii.stl", 'rb')
4040
new = open("OUT_.stl", 'rb')
4141
newlines = new.readlines()

stl_tools/text2png.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os
2-
32
import pylab
4-
from scipy.misc import imread
53

64

75
def text2png(text, fn=None, fontsize=100):
@@ -44,7 +42,7 @@ def text2array(text, fontsize=100):
4442
"""
4543

4644
text2png(text, fn="_text", fontsize=fontsize)
47-
A = imread("_text.png")
45+
A = pylab.imread("_text.png")[:,:,:3].mean(axis=2)
4846
os.remove("_text.png")
4947
return A.max() - A
5048

0 commit comments

Comments
 (0)