@@ -28,65 +28,68 @@ def test_extrude_along_path(self):
28
28
path = [[0 , 0 , 0 ], [0 , 20 , 0 ]]
29
29
# basic test
30
30
actual = extrude_along_path (tri , path )
31
- expected = 'polyhedron(faces = [[0, 3, 1], [1, 3, 4], [1, 4, 2], [2, 4, 5], [2, 5, 0], [0, 5, 3], [6, 0, 1], [6, 1, 2], [6, 2, 0], [7, 3, 4], [7, 4, 5], [7, 5, 3]], points = [[0.0000000000, 0.0000000000, 0.0000000000], [10.0000000000, 0.0000000000, 0.0000000000], [0.0000000000, 0.0000000000, 10.0000000000], [0.0000000000, 20.0000000000, 0.0000000000], [10.0000000000, 20.0000000000, 0.0000000000], [0.0000000000, 20.0000000000, 10.0000000000], [3.3333333333, 0.0000000000, 3.3333333333], [3.3333333333, 20.0000000000, 3.3333333333]] );'
31
+ expected = 'polyhedron(faces= [[0,1,3], [1,4,3],[1,2,4], [2,5,4],[2,0,5],[0,3,5],[2,1, 0],[3,4,5]], points= [[0.0000000000,0.0000000000,0.0000000000],[10.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[10.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,10.0000000000]] );'
32
32
self .assertEqualOpenScadObject (expected , actual )
33
33
34
34
def test_extrude_along_path_vertical (self ):
35
35
# make sure we still look good extruding along z axis; gimbal lock can mess us up
36
36
vert_path = [[0 , 0 , 0 ], [0 , 0 , 20 ]]
37
37
actual = extrude_along_path (tri , vert_path )
38
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4 ],[1,4,2 ],[2,4,5 ],[2,5,0 ],[0,5,3 ],[6,0,1],[6,1,2 ],[6,2, 0],[7, 3,4],[7,4,5],[7,5,3]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[-10.0000000000,0.0000000000,0.0000000000],[0.0000000000,10.0000000000,0.0000000000],[0.0000000000,0.0000000000,20.0000000000],[-10.0000000000,0.0000000000,20.0000000000],[0.0000000000,10.0000000000,20.0000000000],[-3.3333333333,3.3333333333,0.0000000000],[-3.3333333333,3.3333333333,20.0000000000]]); '
38
+ expected = 'polyhedron(faces=[[0,1,3 ],[1,4,3 ],[1, 2,4],[2,5,4 ],[2, 0,5],[0,3,5 ],[2,1, 0],[3,4,5]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[-10.0000000000,0.0000000000,0.0000000000],[0.0000000000,10.0000000000,0.0000000000],[0.0000000000,0.0000000000,20.0000000000],[-10.0000000000,0.0000000000,20.0000000000],[0.0000000000,10.0000000000,20.0000000000]]); '
39
39
self .assertEqualOpenScadObject (expected , actual )
40
40
41
41
def test_extrude_along_path_1d_scale (self ):
42
42
# verify that we can apply scalar scaling
43
43
path = [[0 , 0 , 0 ], [0 , 20 , 0 ]]
44
44
scales_1d = [1.5 , 0.5 ]
45
45
actual = extrude_along_path (tri , path , scales = scales_1d )
46
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4],[1,4,2],[2,4,5],[2,5,0],[0,5,3],[6,0,1],[6,1,2],[6,2,0],[7,3,4],[7,4,5],[7,5,3]],points=[[0.0000000000,0.0000000000,0.0000000000],[15.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,15.0000000000],[0.0000000000,20.0000000000,0.0000000000],[5.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,5.0000000000],[5.0000000000,0.0000000000,5.0000000000],[1.6666666667,20.0000000000,1.6666666667]]);'
46
+ expected = 'polyhedron(faces=[[0,1,3],[1,4,3],[1,2,4],[2,5,4],[2,0,5],[0,3,5],[2,1,0],[3,4,5]],points=[[0.0000000000,0.0000000000,0.0000000000],[15.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,15.0000000000],[0.0000000000,20.0000000000,0.0000000000],[5.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,5.0000000000]]);'
47
+ print ('test_extrude_along_path_1d_scale' )
48
+
47
49
self .assertEqualOpenScadObject (expected , actual )
48
50
49
51
def test_extrude_along_path_2d_scale (self ):
50
52
# verify that we can apply differential x & y scaling
51
53
path = [[0 , 0 , 0 ], [0 , 20 , 0 ], [0 , 40 , 0 ]]
52
54
scales_2d = [Point2 (1 ,1 ), Point2 (0.5 , 1.5 ), Point2 (1.5 , 0.5 ), ]
53
55
actual = extrude_along_path (tri , path , scales = scales_2d )
54
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4 ],[1,4,2 ],[2,4,5 ],[2,5,0 ],[0,5,3 ],[3,6,4 ],[4,6,7 ],[4,7,5 ],[5,7,8 ],[5,8,3 ],[3,8,6 ],[9,0,1 ],[9 ,1,2],[9,2, 0],[10, 6,7],[10,7,8],[10,8,6]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[10.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[5.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,15.0000000000],[0.0000000000,40.0000000000,0.0000000000],[15.0000000000,40.0000000000,0.0000000000],[0.0000000000,40.0000000000,5.0000000000],[3.3333333333,0.0000000000,3.3333333333],[5.0000000000,40.0000000000,1.6666666667 ]]);'
56
+ expected = 'polyhedron(faces=[[0,1,3 ],[1,4,3 ],[1, 2,4],[2,5,4 ],[2, 0,5],[0,3,5 ],[3, 4,6],[4,7,6 ],[4, 5,7],[5,8,7 ],[5, 3,8],[3,6,8 ],[2 ,1,0],[6,7,8]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[10.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[5.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,15.0000000000],[0.0000000000,40.0000000000,0.0000000000],[15.0000000000,40.0000000000,0.0000000000],[0.0000000000,40.0000000000,5.0000000000]]);'
55
57
self .assertEqualOpenScadObject (expected , actual )
56
58
57
59
def test_extrude_along_path_2d_scale_list_input (self ):
58
60
# verify that we can apply differential x & y scaling
59
61
path = [[0 , 0 , 0 ], [0 , 20 , 0 ], [0 , 40 , 0 ]]
60
62
scales_2d = [(1 ,1 ), (0.5 , 1.5 ), (1.5 , 0.5 ), ]
61
63
actual = extrude_along_path (tri , path , scales = scales_2d )
62
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4 ],[1,4,2 ],[2,4,5 ],[2,5,0 ],[0,5,3 ],[3,6,4 ],[4,6,7 ],[4,7,5 ],[5,7,8 ],[5,8,3 ],[3,8,6 ],[9,0,1 ],[9 ,1,2],[9,2, 0],[10, 6,7],[10,7,8],[10,8,6]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[10.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[5.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,15.0000000000],[0.0000000000,40.0000000000,0.0000000000],[15.0000000000,40.0000000000,0.0000000000],[0.0000000000,40.0000000000,5.0000000000],[3.3333333333,0.0000000000,3.3333333333],[5.0000000000,40.0000000000,1.6666666667 ]]);'
64
+ expected = 'polyhedron(faces=[[0,1,3 ],[1,4,3 ],[1, 2,4],[2,5,4 ],[2, 0,5],[0,3,5 ],[3, 4,6],[4,7,6 ],[4, 5,7],[5,8,7 ],[5, 3,8],[3,6,8 ],[2 ,1,0],[6,7,8]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[10.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[5.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,15.0000000000],[0.0000000000,40.0000000000,0.0000000000],[15.0000000000,40.0000000000,0.0000000000],[0.0000000000,40.0000000000,5.0000000000]]);'
63
65
self .assertEqualOpenScadObject (expected , actual )
64
66
65
67
def test_extrude_along_path_end_caps (self ):
66
68
path = [[0 , 0 , 0 ], [0 , 20 , 0 ]]
67
69
actual = scad_render (extrude_along_path (tri , path , connect_ends = False ))
68
- expected = 'polyhedron(faces = [[0, 3, 1], [1, 3, 4], [1, 4, 2], [2, 4, 5], [2, 5, 0], [0, 5, 3], [6, 0, 1], [6, 1, 2], [6, 2, 0], [7, 3, 4], [7, 4, 5], [7, 5, 3]], points = [[0.0000000000, 0.0000000000, 0.0000000000], [10.0000000000, 0.0000000000, 0.0000000000], [0.0000000000, 0.0000000000, 10.0000000000], [0.0000000000, 20.0000000000, 0.0000000000], [10.0000000000, 20.0000000000, 0.0000000000], [0.0000000000, 20.0000000000, 10.0000000000], [3.3333333333, 0.0000000000, 3.3333333333], [3.3333333333, 20.0000000000, 3.3333333333]]); '
70
+ expected = 'polyhedron(faces= [[0,1,3], [1,4,3],[1,2,4], [2,5,4],[2,0,5],[0,3,5],[2,1, 0],[3,4,5]], points= [[0.0000000000,0.0000000000,0.0000000000],[10.0000000000,0.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[10.0000000000,20.0000000000,0.0000000000],[0.0000000000,20.0000000000,10.0000000000]]); '
69
71
self .assertEqualNoWhitespace (expected , actual )
70
72
71
73
def test_extrude_along_path_connect_ends (self ):
72
74
path = [[0 , 0 , 0 ], [20 , 0 , 0 ], [20 ,20 ,0 ], [0 ,20 , 0 ]]
73
75
actual = extrude_along_path (tri , path , connect_ends = True )
74
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4 ],[1,4,2 ],[2,4,5 ],[2,5,0 ],[0,5,3 ],[3,6,4 ],[4,6,7 ],[4,7,5 ],[5,7,8 ],[5,8,3 ],[3,8,6 ],[6,9,7 ],[7,9,10 ],[7,10,8 ],[8,10,11 ],[8,11,6 ],[6,11,9 ],[0 ,9,1 ],[1, 9,10],[1, 10,2 ],[2, 10,11],[2, 11,0 ],[0,11,9 ]],points=[[0.0000000000,0.0000000000,0.0000000000],[-7.0710678119,-7.0710678119,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[20.0000000000,0.0000000000,0.0000000000],[27.0710678119,-7.0710678119,0.0000000000],[20.0000000000,0.0000000000,10.0000000000],[20.0000000000,20.0000000000,0.0000000000],[27.0710678119,27.0710678119,0.0000000000],[20.0000000000,20.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[-7.0710678119,27.0710678119,0.0000000000],[0.0000000000,20.0000000000,10.0000000000]]);'
76
+ expected = 'polyhedron(faces=[[0,1,3 ],[1,4,3 ],[1, 2,4],[2,5,4 ],[2, 0,5],[0,3,5 ],[3, 4,6],[4,7,6 ],[4, 5,7],[5,8,7 ],[5, 3,8],[3,6,8 ],[6, 7,9],[7,10,9 ],[7, 8,10],[8,11,10 ],[8, 6,11],[6 ,9,11 ],[9,10,0 ],[10,1,0 ],[10,11,1 ],[11,2,1],[ 11,9,2 ],[9,0,2 ]],points=[[0.0000000000,0.0000000000,0.0000000000],[-7.0710678119,-7.0710678119,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[20.0000000000,0.0000000000,0.0000000000],[27.0710678119,-7.0710678119,0.0000000000],[20.0000000000,0.0000000000,10.0000000000],[20.0000000000,20.0000000000,0.0000000000],[27.0710678119,27.0710678119,0.0000000000],[20.0000000000,20.0000000000,10.0000000000],[0.0000000000,20.0000000000,0.0000000000],[-7.0710678119,27.0710678119,0.0000000000],[0.0000000000,20.0000000000,10.0000000000]]); '
75
77
self .assertEqualOpenScadObject (expected , actual )
76
78
77
79
def test_extrude_along_path_rotations (self ):
80
+
78
81
# confirm we can rotate for each point in path
79
82
path = [[0 ,0 ,0 ], [20 , 0 ,0 ]]
80
83
rotations = [- 45 , 45 ]
81
84
actual = extrude_along_path (tri , path , rotations = rotations )
82
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4 ],[1,4,2 ],[2,4,5 ],[2,5,0 ],[0,5,3 ],[6,0,1],[6,1,2 ],[6,2, 0],[7, 3,4],[7,4,5],[7,5,3]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[0.0000000000,-7.0710678119,-7.0710678119],[0.0000000000,-7.0710678119,7.0710678119],[20.0000000000,0.0000000000,0.0000000000],[20.0000000000,-7.0710678119,7.0710678119],[20.0000000000,7.0710678119,7.0710678119],[0.0000000000,-4.7140452079,0.0000000000],[20.0000000000,-0.0000000000,4.7140452079]]); '
85
+ expected = 'polyhedron(faces=[[0,1,3 ],[1,4,3 ],[1, 2,4],[2,5,4 ],[2, 0,5],[0,3,5 ],[2,1, 0],[3,4,5]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[0.0000000000,-7.0710678119,-7.0710678119],[0.0000000000,-7.0710678119,7.0710678119],[20.0000000000,0.0000000000,0.0000000000],[20.0000000000,-7.0710678119,7.0710678119],[20.0000000000,7.0710678119,7.0710678119]]); '
83
86
self .assertEqualOpenScadObject (expected , actual )
84
87
85
88
# confirm we can rotate with a single supplied value
86
89
path = [[0 ,0 ,0 ], [20 , 0 ,0 ]]
87
90
rotations = [45 ]
88
91
actual = extrude_along_path (tri , path , rotations = rotations )
89
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4 ],[1,4,2 ],[2,4,5 ],[2,5,0 ],[0,5,3 ],[6,0,1],[6,1,2 ],[6,2, 0],[7, 3,4],[7,4,5],[7,5,3]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[0.0000000000,-10.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[20.0000000000,0.0000000000,0.0000000000],[20.0000000000,-7.0710678119,7.0710678119],[20.0000000000,7.0710678119,7.0710678119],[0.0000000000,-3.3333333333,3.3333333333],[20.0000000000,-0.0000000000,4.7140452079]]); '
92
+ expected = 'polyhedron(faces=[[0,1,3 ],[1,4,3 ],[1, 2,4],[2,5,4 ],[2, 0,5],[0,3,5 ],[2,1, 0],[3,4,5]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[0.0000000000,-10.0000000000,0.0000000000],[0.0000000000,0.0000000000,10.0000000000],[20.0000000000,0.0000000000,0.0000000000],[20.0000000000,-7.0710678119,7.0710678119],[20.0000000000,7.0710678119,7.0710678119]]); '
90
93
self .assertEqualOpenScadObject (expected , actual )
91
94
92
95
def test_extrude_along_path_transforms (self ):
@@ -95,13 +98,13 @@ def test_extrude_along_path_transforms(self):
95
98
# Make sure we can take a transform function for each point in path
96
99
transforms = [lambda p , path , loop : 2 * p , lambda p , path , loop : 0.5 * p ]
97
100
actual = extrude_along_path (tri , path , transforms = transforms )
98
- expected = 'polyhedron(faces=[[0,3,1],[1,3,4 ],[1,4,2 ],[2,4,5 ],[2,5,0 ],[0,5,3 ],[6,0,1],[6,1,2 ],[6,2, 0],[7, 3,4],[7,4,5],[7,5,3]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[0.0000000000,-20.0000000000,0.0000000000],[0.0000000000,0.0000000000,20.0000000000],[20.0000000000,0.0000000000,0.0000000000],[20.0000000000,-5.0000000000,0.0000000000],[20.0000000000,0.0000000000,5.0000000000],[0.0000000000,-6.6666666667,6.6666666667],[20.0000000000,-1.6666666667,1.6666666667]]); '
101
+ expected = 'polyhedron(faces=[[0,1,3 ],[1,4,3 ],[1, 2,4],[2,5,4 ],[2, 0,5],[0,3,5 ],[2,1, 0],[3,4,5]] ,points=[[0.0000000000,0.0000000000,0.0000000000],[0.0000000000,-20.0000000000,0.0000000000],[0.0000000000,0.0000000000,20.0000000000],[20.0000000000,0.0000000000,0.0000000000],[20.0000000000,-5.0000000000,0.0000000000],[20.0000000000,0.0000000000,5.0000000000]]); '
99
102
self .assertEqualOpenScadObject (expected , actual )
100
103
101
104
# Make sure we can take a single transform function for all points
102
105
transforms = [lambda p , path , loop : 2 * p ]
103
106
actual = extrude_along_path (tri , path , transforms = transforms )
104
- expected = 'polyhedron(faces = [[0, 3, 1], [1, 3, 4], [1, 4, 2], [2, 4, 5], [2, 5, 0], [0, 5, 3], [6, 0, 1], [6, 1, 2], [6, 2, 0], [7, 3, 4], [7, 4, 5], [7, 5, 3]], points = [[0.0000000000, 0.0000000000, 0.0000000000], [0.0000000000, -20.0000000000, 0.0000000000], [0.0000000000, 0.0000000000, 20.0000000000], [20.0000000000, 0.0000000000, 0.0000000000], [20.0000000000, -20.0000000000, 0.0000000000], [20.0000000000, 0.0000000000, 20.0000000000], [0.0000000000, -6.6666666667, 6.6666666667], [20.0000000000, -6.6666666667, 6.6666666667 ]]);'
107
+ expected = 'polyhedron(faces= [[0,1,3], [1,4,3],[1,2,4], [2,5,4],[2,0,5],[0,3,5],[2,1, 0],[3,4,5]], points= [[0.0000000000,0.0000000000,0.0000000000],[0.0000000000,-20.0000000000,0.0000000000],[0.0000000000,0.0000000000,20.0000000000],[20.0000000000,0.0000000000,0.0000000000],[20.0000000000,-20.0000000000,0.0000000000],[20.0000000000,0.0000000000,20.0000000000]]);'
105
108
self .assertEqualOpenScadObject (expected , actual )
106
109
107
110
def test_extrude_along_path_numpy (self ):
0 commit comments