@@ -12,27 +12,49 @@ describe('.isPlanar', () => {
1212 test ( 'returns true if all extrusions are on the same plane' , ( ) => {
1313 const job = new Job ( ) ;
1414
15- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
16- append_path ( job , PathType . Extrusion , [ 1 , 2 , 0 , 5 , 6 , 0 ] ) ;
15+ append_path ( job , PathType . Extrusion , [
16+ [ 0 , 0 , 0 ] ,
17+ [ 1 , 2 , 0 ]
18+ ] ) ;
19+ append_path ( job , PathType . Extrusion , [
20+ [ 1 , 2 , 0 ] ,
21+ [ 5 , 6 , 0 ]
22+ ] ) ;
1723
1824 expect ( job . isPlanar ( ) ) . toEqual ( true ) ;
1925 } ) ;
2026
2127 test ( 'returns false if any extrusions are on a different plane' , ( ) => {
2228 const job = new Job ( ) ;
2329
24- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
25- append_path ( job , PathType . Extrusion , [ 1 , 2 , 0 , 5 , 6 , 1 ] ) ;
30+ append_path ( job , PathType . Extrusion , [
31+ [ 0 , 0 , 0 ] ,
32+ [ 1 , 2 , 0 ]
33+ ] ) ;
34+ append_path ( job , PathType . Extrusion , [
35+ [ 1 , 2 , 0 ] ,
36+ [ 5 , 6 , 1 ]
37+ ] ) ;
2638
2739 expect ( job . isPlanar ( ) ) . toEqual ( false ) ;
2840 } ) ;
2941
3042 test ( 'ignores travel paths' , ( ) => {
3143 const job = new Job ( ) ;
3244
33- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
34- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 1 , 1 , 2 , 0 ] ) ;
35- append_path ( job , PathType . Extrusion , [ 1 , 2 , 0 , 5 , 6 , 0 ] ) ;
45+ append_path ( job , PathType . Extrusion , [
46+ [ 0 , 0 , 0 ] ,
47+ [ 1 , 2 , 0 ]
48+ ] ) ;
49+ append_path ( job , PathType . Travel , [
50+ [ 5 , 6 , 0 ] ,
51+ [ 5 , 6 , 1 ] ,
52+ [ 1 , 2 , 0 ]
53+ ] ) ;
54+ append_path ( job , PathType . Extrusion , [
55+ [ 1 , 2 , 0 ] ,
56+ [ 5 , 6 , 0 ]
57+ ] ) ;
3658
3759 expect ( job . isPlanar ( ) ) . toEqual ( true ) ;
3860 } ) ;
@@ -42,17 +64,29 @@ describe('.layers', () => {
4264 test ( 'returns null if the job is not planar' , ( ) => {
4365 const job = new Job ( ) ;
4466
45- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
46- append_path ( job , PathType . Extrusion , [ 5 , 6 , 0 , 5 , 6 , 1 ] ) ;
67+ append_path ( job , PathType . Extrusion , [
68+ [ 0 , 0 , 0 ] ,
69+ [ 1 , 2 , 0 ]
70+ ] ) ;
71+ append_path ( job , PathType . Extrusion , [
72+ [ 5 , 6 , 0 ] ,
73+ [ 5 , 6 , 1 ]
74+ ] ) ;
4775
4876 expect ( job . layers ) . toEqual ( null ) ;
4977 } ) ;
5078
5179 test ( 'paths without z changes are on the same layer' , ( ) => {
5280 const job = new Job ( ) ;
5381
54- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
55- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 0 ] ) ;
82+ append_path ( job , PathType . Extrusion , [
83+ [ 0 , 0 , 0 ] ,
84+ [ 1 , 2 , 0 ]
85+ ] ) ;
86+ append_path ( job , PathType . Travel , [
87+ [ 5 , 6 , 0 ] ,
88+ [ 5 , 6 , 0 ]
89+ ] ) ;
5690
5791 const layers = job . layers ;
5892
@@ -65,8 +99,14 @@ describe('.layers', () => {
6599 test ( 'travel paths moving z create a new layer' , ( ) => {
66100 const job = new Job ( ) ;
67101
68- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
69- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 1 ] ) ;
102+ append_path ( job , PathType . Extrusion , [
103+ [ 0 , 0 , 0 ] ,
104+ [ 1 , 2 , 0 ]
105+ ] ) ;
106+ append_path ( job , PathType . Travel , [
107+ [ 5 , 6 , 0 ] ,
108+ [ 5 , 6 , 1 ]
109+ ] ) ;
70110
71111 const layers = job . layers ;
72112
@@ -80,10 +120,22 @@ describe('.layers', () => {
80120 test ( 'multiple travels in a row are on the same layer' , ( ) => {
81121 const job = new Job ( ) ;
82122
83- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
84- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 2 ] ) ;
85- append_path ( job , PathType . Travel , [ 5 , 6 , 2 , 5 , 6 , 0 ] ) ;
86- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 2 ] ) ;
123+ append_path ( job , PathType . Extrusion , [
124+ [ 0 , 0 , 0 ] ,
125+ [ 1 , 2 , 0 ]
126+ ] ) ;
127+ append_path ( job , PathType . Travel , [
128+ [ 5 , 6 , 0 ] ,
129+ [ 5 , 6 , 2 ]
130+ ] ) ;
131+ append_path ( job , PathType . Travel , [
132+ [ 5 , 6 , 2 ] ,
133+ [ 5 , 6 , 0 ]
134+ ] ) ;
135+ append_path ( job , PathType . Travel , [
136+ [ 5 , 6 , 0 ] ,
137+ [ 5 , 6 , 2 ]
138+ ] ) ;
87139
88140 const layers = job . layers ;
89141
@@ -97,11 +149,26 @@ describe('.layers', () => {
97149 test ( 'extrusions after travels are on the same layer' , ( ) => {
98150 const job = new Job ( ) ;
99151
100- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
101- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 2 ] ) ;
102- append_path ( job , PathType . Travel , [ 5 , 6 , 2 , 5 , 6 , 0 ] ) ;
103- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 2 ] ) ;
104- append_path ( job , PathType . Extrusion , [ 5 , 6 , 2 , 5 , 6 , 2 ] ) ;
152+ append_path ( job , PathType . Extrusion , [
153+ [ 0 , 0 , 0 ] ,
154+ [ 1 , 2 , 0 ]
155+ ] ) ;
156+ append_path ( job , PathType . Travel , [
157+ [ 5 , 6 , 0 ] ,
158+ [ 5 , 6 , 2 ]
159+ ] ) ;
160+ append_path ( job , PathType . Travel , [
161+ [ 5 , 6 , 2 ] ,
162+ [ 5 , 6 , 0 ]
163+ ] ) ;
164+ append_path ( job , PathType . Travel , [
165+ [ 5 , 6 , 0 ] ,
166+ [ 5 , 6 , 2 ]
167+ ] ) ;
168+ append_path ( job , PathType . Extrusion , [
169+ [ 5 , 6 , 2 ] ,
170+ [ 5 , 6 , 2 ]
171+ ] ) ;
105172
106173 const layers = job . layers ;
107174
@@ -117,9 +184,18 @@ describe('.extrusions', () => {
117184 test ( 'returns all extrusion paths' , ( ) => {
118185 const job = new Job ( ) ;
119186
120- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
121- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 0 ] ) ;
122- append_path ( job , PathType . Extrusion , [ 1 , 2 , 0 , 5 , 6 , 0 ] ) ;
187+ append_path ( job , PathType . Extrusion , [
188+ [ 0 , 0 , 0 ] ,
189+ [ 1 , 2 , 0 ]
190+ ] ) ;
191+ append_path ( job , PathType . Travel , [
192+ [ 5 , 6 , 0 ] ,
193+ [ 5 , 6 , 0 ]
194+ ] ) ;
195+ append_path ( job , PathType . Extrusion , [
196+ [ 1 , 2 , 0 ] ,
197+ [ 5 , 6 , 0 ]
198+ ] ) ;
123199
124200 const extrusions = job . extrusions ;
125201
@@ -136,10 +212,22 @@ describe('.travels', () => {
136212 test ( 'returns all travel paths' , ( ) => {
137213 const job = new Job ( ) ;
138214
139- append_path ( job , PathType . Extrusion , [ 0 , 0 , 0 , 1 , 2 , 0 ] ) ;
140- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 0 ] ) ;
141- append_path ( job , PathType . Extrusion , [ 1 , 2 , 0 , 5 , 6 , 0 ] ) ;
142- append_path ( job , PathType . Travel , [ 5 , 6 , 0 , 5 , 6 , 0 ] ) ;
215+ append_path ( job , PathType . Extrusion , [
216+ [ 0 , 0 , 0 ] ,
217+ [ 1 , 2 , 0 ]
218+ ] ) ;
219+ append_path ( job , PathType . Travel , [
220+ [ 5 , 6 , 0 ] ,
221+ [ 5 , 6 , 0 ]
222+ ] ) ;
223+ append_path ( job , PathType . Extrusion , [
224+ [ 1 , 2 , 0 ] ,
225+ [ 5 , 6 , 0 ]
226+ ] ) ;
227+ append_path ( job , PathType . Travel , [
228+ [ 5 , 6 , 0 ] ,
229+ [ 5 , 6 , 0 ]
230+ ] ) ;
143231
144232 const travels = job . travels ;
145233
@@ -152,8 +240,8 @@ describe('.travels', () => {
152240 } ) ;
153241} ) ;
154242
155- function append_path ( job , travelType , vertices ) {
243+ function append_path ( job , travelType , points ) {
156244 const path = new Path ( travelType , 0.6 , 0.2 , job . state . tool ) ;
157- path . vertices = vertices ;
245+ points . forEach ( ( point : [ number , number , number ] ) => path . addPoint ( ... point ) ) ;
158246 job . addPath ( path ) ;
159247}
0 commit comments