@@ -40,6 +40,7 @@ class OpArea extends CamOp {
4040 // selected area polygons: surfaces and edges
4141 let { devel, edgeangle } = settings . controller ;
4242 let stack = [ ] ;
43+ let surfaces = this . surfaces = [ ] ;
4344 let areas = this . areas = [ stack ] ;
4445 let polys = [ ] ;
4546
@@ -199,6 +200,7 @@ class OpArea extends CamOp {
199200
200201 let resolution = tolerance || 0.05 ;
201202 let raster = await self . get_raster_gpu ( { mode : "tracing" , resolution } ) ;
203+ let surface = [ ] ;
202204 let paths = [ ] ;
203205
204206 // prepare paths
@@ -260,27 +262,50 @@ class OpArea extends CamOp {
260262 // convert terrain raster output back to open polylines
261263 for ( let path of output . paths ) {
262264 path = newPolygon ( ) . fromArray ( [ 1 , ...path ] ) ;
265+ surface . push ( path ) ;
263266 newLayer ( ) . output ( )
264267 . setLayer ( "linear" , { line : 0x00ff00 } , false )
265268 . addPolys ( [ path ] ) ;
266269 }
270+
271+ // output this surface
272+ surfaces . push ( surface ) ;
267273 }
268274 }
269275
270276 addSlices ( areas . flat ( ) ) ;
271277 }
272278
273279 prepare ( ops , progress ) {
274- let { op, state, areas } = this ;
275- let { getPrintPoint , pocket, setTool, setSpindle } = ops ;
280+ let { op, state, areas, surfaces } = this ;
281+ let { getPrintPoint, newLayer , pocket, polyEmit , setTool, setSpindle, tip2tipEmit } = ops ;
276282 let { process } = state . settings ;
277283
278284 setTool ( op . tool , op . rate ) ;
279285 setSpindle ( op . spindle ) ;
280286
287+ let printPoint = getPrintPoint ( ) ;
288+
289+ // process surface paths
290+ for ( let surface of surfaces ) {
291+ let array = surface . map ( poly => { return {
292+ el : poly ,
293+ first : poly . first ( ) ,
294+ last : poly . last ( )
295+ } } ) ;
296+ tip2tipEmit ( array , printPoint , ( next , first , count ) => {
297+ printPoint = polyEmit ( next . el , 0 , 1 , printPoint , { } ) ;
298+ newLayer ( ) ;
299+ } ) ;
300+ }
301+
302+ // skip areas when processing surfaces
303+ if ( surfaces . length ) {
304+ return ;
305+ }
306+
281307 // process areas as pockets
282308 while ( areas ?. length ) {
283- let printPoint = getPrintPoint ( ) ;
284309 let min = {
285310 dist : Infinity ,
286311 area : undefined
@@ -302,7 +327,6 @@ class OpArea extends CamOp {
302327 // if we have a next-closest top poly, pocket that
303328 if ( min . area ) {
304329 min . area . used = true ;
305- console . log ( { area : min . area } ) ;
306330 pocket ( {
307331 cutdir : op . ov_conv ,
308332 depthFirst : process . camDepthFirst ,
@@ -314,7 +338,6 @@ class OpArea extends CamOp {
314338 break ;
315339 }
316340 }
317-
318341 }
319342}
320343
0 commit comments