-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
test_Tweaker.py
122 lines (87 loc) · 4.82 KB
/
test_Tweaker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import pytest
import numpy as np
# import Tweaker modules
import FileHandler
from MeshTweaker import Tweak
file_handler = FileHandler.FileHandler()
@pytest.mark.skip("Test routine")
def test_routine(file_name, target_alignment, kwargs):
objs = file_handler.load_mesh(file_name)
info = dict()
for part, content in objs.items():
mesh = content["mesh"]
info[part] = dict()
x = Tweak(mesh, **kwargs)
info[part]["alignment"] = x.alignment
info[part]["rotation_axis"] = x.rotation_axis
info[part]["rotation_angle"] = x.rotation_angle
info[part]["euler_parameter"] = x.euler_parameter
info[part]["bottom_area"] = x.bottom_area
info[part]["overhang_area"] = x.overhang_area
info[part]["contour"] = x.contour
info[part]["unprintability"] = x.unprintability
info[part]["best_5"] = x.best_5
info[part]["time"] = x.time
info[part]["tweaker_stats"] = x
print("Object: {}, result: new alignment: \t{}".format(file_name, x.alignment))
assert np.allclose(info[part]["alignment"], target_alignment, atol=1e-4)
# Testing four main configs on demo_object
def test_11():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": True, "min_volume": True, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
def test_12():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": True, "min_volume": False, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
def test_13():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": False, "min_volume": True, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
def test_14():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": False, "min_volume": False, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
# Testing with extended mode only on death_star
def test_21():
file_name = "death_star.stl"
kwargs = dict({"extended_mode": True, "min_volume": True, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0.422389, 0.069502, -0.903746], kwargs=kwargs)
def test_22():
file_name = "death_star.stl"
kwargs = dict({"extended_mode": True, "min_volume": False, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0.422389, 0.069502, -0.903746], kwargs=kwargs)
# Testing fav-side option for each configuration
def test_31():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": True, "min_volume": True, "favside": "[[1,1,2.3],2.5]", "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
def test_32():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": True, "min_volume": False, "favside": "[[1,1,2.3],2.5]", "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
def test_33():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": False, "min_volume": True, "favside": "[[1,1,2.3],2.5]", "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
def test_34():
file_name = "demo_object.stl"
kwargs = dict({"extended_mode": False, "min_volume": False, "favside": "[[1,1,2.3],2.5]", "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0., -0.64278733, -0.76604468], kwargs=kwargs)
# Testing four main configs on 3mf object
def test_41():
file_name = "pyramid.3mf"
kwargs = dict({"extended_mode": True, "min_volume": True, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0.57735027, 0.57735027, 0.57735027], kwargs=kwargs)
def test_42():
file_name = "pyramid.3mf"
kwargs = dict({"extended_mode": True, "min_volume": False, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0.57735027, 0.57735027, 0.57735027], kwargs=kwargs)
def test_43():
file_name = "pyramid.3mf"
kwargs = dict({"extended_mode": False, "min_volume": True, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0.57735027, 0.57735027, 0.57735027], kwargs=kwargs)
def test_44():
file_name = "pyramid.3mf"
kwargs = dict({"extended_mode": False, "min_volume": False, "favside": None, "verbose": False})
test_routine(file_name=file_name, target_alignment=[-0.57735027, 0.57735027, 0.57735027], kwargs=kwargs)