@@ -362,6 +362,67 @@ describe 'Slicing', ->
362362 expect (Math .abs (printCenterX - expectedCenterX)).toBeLessThan (2 )
363363 expect (Math .abs (printCenterY - expectedCenterY)).toBeLessThan (2 )
364364
365+ test ' should use smart wipe when slicing a real mesh with smartWipeNozzle enabled' , ->
366+
367+ # Create a small box mesh.
368+ geometry = new THREE.BoxGeometry (10 , 10 , 10 )
369+ material = new THREE.MeshBasicMaterial ()
370+ mesh = new THREE.Mesh (geometry, material)
371+
372+ mesh .position .set (0 , 0 , 5 )
373+ mesh .updateMatrixWorld ()
374+
375+ # Enable smart wipe (both flags must be true).
376+ slicer .setWipeNozzle (true )
377+ slicer .setSmartWipeNozzle (true )
378+ slicer .setLayerHeight (0.2 )
379+ slicer .setInfillDensity (0 ) # No infill for faster test.
380+ slicer .setVerbose (false )
381+
382+ result = slicer .slice (mesh)
383+
384+ # Smart wipe emits a G1 with both X or Y and E- inside a G91 block.
385+ # Find the relative-mode section and confirm it contains such a line.
386+ lines = result .split (' \n ' )
387+ isRelative = false
388+ foundSmartWipe = false
389+
390+ for line in lines
391+
392+ if line .indexOf (' G91' ) is 0
393+ isRelative = true
394+ else if line .indexOf (' G90' ) is 0
395+ isRelative = false
396+
397+ # Smart wipe move: relative G1 with X or Y displacement and negative E.
398+ if isRelative and line .indexOf (' G1 ' ) is 0 and line .indexOf (' E-' ) > - 1 and (line .indexOf (' X' ) > - 1 or line .indexOf (' Y' ) > - 1 )
399+ foundSmartWipe = true
400+
401+ # Smart wipe should have fired (not the fallback G0 X5 Y5).
402+ expect (foundSmartWipe).toBe (true )
403+ expect (result).not .toContain (' G0 X5 Y5' ) # No simple fallback wipe.
404+
405+ test ' should fall back to simple wipe when smartWipeNozzle is disabled' , ->
406+
407+ # Create a small box mesh.
408+ geometry = new THREE.BoxGeometry (10 , 10 , 10 )
409+ material = new THREE.MeshBasicMaterial ()
410+ mesh = new THREE.Mesh (geometry, material)
411+
412+ mesh .position .set (0 , 0 , 5 )
413+ mesh .updateMatrixWorld ()
414+
415+ # Disable smart wipe — expect the simple X+5 Y+5 fallback.
416+ slicer .setWipeNozzle (true )
417+ slicer .setSmartWipeNozzle (false )
418+ slicer .setLayerHeight (0.2 )
419+ slicer .setInfillDensity (0 ) # No infill for faster test.
420+ slicer .setVerbose (false )
421+
422+ result = slicer .slice (mesh)
423+
424+ expect (result).toContain (' G0 X5 Y5' ) # Simple fallback wipe should be present.
425+
365426 describe ' Torus Slicing with Holes' , ->
366427
367428 test ' should generate infill clipped by hole walls' , ->
0 commit comments