Debian Codegraph @

examples/nodejs/adaptivewaterline.js

raw
1 const fs = require('fs')
2 const {
3 STLSurf,
4 STLReader,
5 CylCutter,
6 AdaptiveWaterline
7 } = require('@opencamlib/opencamlib')
8
9 const surface = new STLSurf()
10 const stlContents = fs.readFileSync(__dirname + '/../../stl/gnu_tux_mod.stl')
11 new STLReader(stlContents, surface)
12 const cutter = new CylCutter(4, 20)
13 const awl = new AdaptiveWaterline()
14 awl.setSTL(surface)
15 awl.setCutter(cutter)
16 awl.setSampling(0.1)
17 awl.setMinSampling(0.001)
18 awl.setZ(1)
19 awl.run()
20 awl.getLoops().forEach(function (loop) {
21 loop.forEach(function (point) {
22 console.log('G01 X' + point[0] + ' Y' + point[1] + ' Z' + point[2])
23 })
24 })