Skip to content

Commit 12eca80

Browse files
committed
Added test for STL output quality control
1 parent 76d7c95 commit 12eca80

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

tests/test_stl_codec.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import tests.test_helpers as helpers
23

34
def test_stl_codec():
@@ -9,4 +10,25 @@ def test_stl_codec():
910
command = ["python", "cq-cli.py", "--codec", "stl", "--infile", test_file]
1011
out, err, exitcode = helpers.cli_call(command)
1112

12-
assert out.decode().split('\n')[0].replace('\r', '') == "solid "
13+
assert out.decode().split('\n')[0].replace('\r', '') == "solid "
14+
15+
def test_stl_codec_quality():
16+
"""
17+
Test of the STL codec plugin's ability to adjust the quality of the resulting STL.
18+
"""
19+
test_file = helpers.get_test_file_location("sphere.py")
20+
21+
command = ["python", "cq-cli.py", "--codec", "stl", "--infile", test_file, "--outfile", "/tmp/high.stl"]
22+
out, err, exitcode = helpers.cli_call(command)
23+
24+
# Keep track of the number of lines for each STL as an approximate measure of quality
25+
high_detail = os.path.getsize("/tmp/high.stl")
26+
27+
# Attempt to adjust the quality of the resulting STL
28+
command2 = ["python", "cq-cli.py", "--codec", "stl", "--infile", test_file, "--outfile", "/tmp/low.stl", "--outputopts", "linearDeflection:0.3;angularDeflection:0.3"]
29+
out2, err2, exitcode2 = helpers.cli_call(command2)
30+
31+
# Keep track of the number of lines in the STL as an approximate measure of quality
32+
low_detail = os.path.getsize("/tmp/low.stl")
33+
34+
assert low_detail < high_detail

tests/testdata/sphere.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import cadquery as cq
2+
3+
sphere = cq.Workplane().sphere(1)
4+
5+
show_object(sphere)

0 commit comments

Comments
 (0)