Skip to content

Commit 934bd30

Browse files
Copilotjgphilpott
andcommitted
Remove remaining three-bvh-csg usage from walls.test.coffee Travel Path Combing tests
Co-authored-by: jgphilpott <4128208+jgphilpott@users.noreply.github.com>
1 parent 20d1607 commit 934bd30

File tree

1 file changed

+38
-84
lines changed

1 file changed

+38
-84
lines changed

src/slicer/walls/walls.test.coffee

Lines changed: 38 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,34 @@ describe 'Wall Generation', ->
375375

376376
describe 'Travel Path Combing', ->
377377

378+
SHEET_W = 50
379+
DEPTH = 2
380+
HOLE_RADIUS = 3
381+
382+
buildSheetWithHolesMesh = (holePositions) ->
383+
384+
half = SHEET_W / 2
385+
sheetShape = new THREE.Shape()
386+
sheetShape.moveTo(-half, -half)
387+
sheetShape.lineTo(half, -half)
388+
sheetShape.lineTo(half, half)
389+
sheetShape.lineTo(-half, half)
390+
sheetShape.closePath()
391+
392+
for pos in holePositions
393+
394+
holePath = new THREE.Path()
395+
holePath.absarc(pos.x, pos.y, HOLE_RADIUS, 0, Math.PI * 2, false)
396+
sheetShape.holes.push(holePath)
397+
398+
sheetGeometry = new THREE.ExtrudeGeometry(sheetShape, { depth: DEPTH, bevelEnabled: false })
399+
400+
mesh = new THREE.Mesh(sheetGeometry, new THREE.MeshBasicMaterial())
401+
mesh.position.set(0, 0, 0)
402+
mesh.updateMatrixWorld()
403+
404+
return mesh
405+
378406
# Helper function to count combing paths in G-code.
379407
# A combing path is detected as 2+ consecutive G0 travel moves.
380408
countCombingPaths = (gcode) ->
@@ -402,45 +430,8 @@ describe 'Wall Generation', ->
402430

403431
test 'should use combing paths when traveling between hole walls', ->
404432

405-
# Create a simple mesh with a hole using CSG-like approach.
406-
# For testing, we'll create a thin box with a cylinder subtracted.
407-
Brush = null
408-
Evaluator = null
409-
SUBTRACTION = null
410-
411-
try
412-
{ Brush, Evaluator, SUBTRACTION } = require('three-bvh-csg')
413-
catch error
414-
console.warn('three-bvh-csg not available, skipping combing test')
415-
return
416-
417-
# Suppress MeshBVH deprecation warnings from three-bvh-csg.
418-
originalWarn = console.warn
419-
console.warn = jest.fn()
420-
421-
# Create a sheet (box).
422-
sheetGeometry = new THREE.BoxGeometry(50, 50, 2)
423-
sheetBrush = new Brush(sheetGeometry)
424-
sheetBrush.updateMatrixWorld()
425-
426-
# Create a hole (cylinder).
427-
holeGeometry = new THREE.CylinderGeometry(3, 3, 4, 32)
428-
holeBrush = new Brush(holeGeometry)
429-
holeBrush.rotation.x = Math.PI / 2
430-
holeBrush.position.set(0, 0, 0)
431-
holeBrush.updateMatrixWorld()
432-
433-
# Subtract hole from sheet.
434-
csgEvaluator = new Evaluator()
435-
resultBrush = csgEvaluator.evaluate(sheetBrush, holeBrush, SUBTRACTION)
436-
437-
# Restore console.warn.
438-
console.warn = originalWarn
439-
440-
# Create final mesh.
441-
mesh = new THREE.Mesh(resultBrush.geometry, new THREE.MeshBasicMaterial())
442-
mesh.position.set(0, 0, 1)
443-
mesh.updateMatrixWorld()
433+
# Create a sheet with a single centered hole using ExtrudeGeometry (no CSG required).
434+
mesh = buildSheetWithHolesMesh([{ x: 0, y: 0 }])
444435

445436
slicer.setNozzleDiameter(0.4)
446437
slicer.setShellWallThickness(0.8) # 2 walls
@@ -458,52 +449,15 @@ describe 'Wall Generation', ->
458449

459450
test 'should generate combing paths for multiple holes', ->
460451

461-
# Create a mesh with multiple holes.
462-
Brush = null
463-
Evaluator = null
464-
SUBTRACTION = null
465-
466-
try
467-
{ Brush, Evaluator, SUBTRACTION } = require('three-bvh-csg')
468-
catch error
469-
console.warn('three-bvh-csg not available, skipping combing test')
470-
return
452+
# Create a sheet with 4 holes in a 2x2 grid using ExtrudeGeometry (no CSG required).
453+
holePositions = [
454+
{ x: -12.5, y: -12.5 }
455+
{ x: 12.5, y: -12.5 }
456+
{ x: -12.5, y: 12.5 }
457+
{ x: 12.5, y: 12.5 }
458+
]
471459

472-
# Suppress MeshBVH deprecation warnings from three-bvh-csg.
473-
originalWarn = console.warn
474-
console.warn = jest.fn()
475-
476-
# Create a sheet (box).
477-
sheetGeometry = new THREE.BoxGeometry(50, 50, 2)
478-
sheetBrush = new Brush(sheetGeometry)
479-
sheetBrush.updateMatrixWorld()
480-
481-
csgEvaluator = new Evaluator()
482-
resultBrush = sheetBrush
483-
484-
# Create 4 holes in a 2x2 grid.
485-
for row in [0...2]
486-
487-
for col in [0...2]
488-
489-
x = -12.5 + col * 25
490-
y = -12.5 + row * 25
491-
492-
holeGeometry = new THREE.CylinderGeometry(3, 3, 4, 32)
493-
holeBrush = new Brush(holeGeometry)
494-
holeBrush.rotation.x = Math.PI / 2
495-
holeBrush.position.set(x, y, 0)
496-
holeBrush.updateMatrixWorld()
497-
498-
resultBrush = csgEvaluator.evaluate(resultBrush, holeBrush, SUBTRACTION)
499-
500-
# Restore console.warn.
501-
console.warn = originalWarn
502-
503-
# Create final mesh.
504-
mesh = new THREE.Mesh(resultBrush.geometry, new THREE.MeshBasicMaterial())
505-
mesh.position.set(0, 0, 1)
506-
mesh.updateMatrixWorld()
460+
mesh = buildSheetWithHolesMesh(holePositions)
507461

508462
slicer.setNozzleDiameter(0.4)
509463
slicer.setShellWallThickness(0.8) # 2 walls

0 commit comments

Comments
 (0)