From e5d9712181d49d036419fb5126c8aa7a3c41dc70 Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Mon, 30 Jun 2025 20:46:58 -0600 Subject: [PATCH] set up cylinder route --- src/kiri-mode/cam/client.js | 25 ++++++++++++++++++++- src/kiri-mode/cam/driver.js | 42 +++++++++++++++++++++++++++++++++++ src/kiri-mode/cam/ops.js | 44 +++++++++++++++++++++++++++++++++++++ src/kiri-mode/cam/slice.js | 6 +++++ 4 files changed, 116 insertions(+), 1 deletion(-) diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index 1c7032cd..ff341819 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -1355,6 +1355,29 @@ CAM.init = function(kiri, api) { }); }; + func.selectHelical = () => { + + console.log("select helical") + + + CAM.cylinderFaces((progress,msg)=>{ + api.show.progress(progress,msg) + },(data)=>{ + + console.log(data) + + func.selectHelicalDone(data); + }) + + + + } + + func.selectHelicalDone = () =>{ + + console.log("select helical done") + } + // COMMON TAB/TRACE EVENT HANDLERS api.event.on("slice.begin", () => { if (isCamMode) { @@ -1864,7 +1887,7 @@ CAM.init = function(kiri, api) { sep: UC.newBlank({class:"pop-sep"}), thru: UC.newInput(LANG.cd_thru_s, {title:LANG.cd_thru_l, convert:UC.toFloat, units:true}), actions: UC.newRow([ - UC.newButton(LANG.select, ()=>func.selectHoles(true), {title:LANG.cd_seli_l}), + UC.newButton(LANG.select, func.selectHelical, {title:LANG.cd_seli_l}), ], {class:"ext-buttons f-col"}) }; diff --git a/src/kiri-mode/cam/driver.js b/src/kiri-mode/cam/driver.js index 9d92527e..6b164df2 100644 --- a/src/kiri-mode/cam/driver.js +++ b/src/kiri-mode/cam/driver.js @@ -99,6 +99,29 @@ kiri.load(api => { }); }) }; + + CAM.cylinderFaces = function(opProgress,onDone){ + + kiri.client.sync(); + const settings = api.conf.get(); + return new Promise((res,rej)=>{ + + console.log("messaging worker") + + kiri.client.send("cam_cylinder_faces", { settings }, output => { + let out = kiri.codec.decode(output) + if(out.progress != undefined){ + //if a progress message, + opProgress(out.progress,out.msg) + }else{ + api.hide.alert(alert); + onDone(out); + res(out); + } + }); + }) + + } } if (kiri.worker) { @@ -181,6 +204,25 @@ kiri.load(api => { shadowed:widget.shadowedDrills } } ))); } + + kiri.worker.cam_cylinder_faces = async function(data,send){ + const { settings, rec } = data; + const widgets = Object.values(kiri.worker.cache); + + console.log("hi from the worker") + + for (let [i,widget] of widgets.entries() ) { + if (await CAM.cylinders(settings, widget,)) { + + let {traces} = widget; + + console.log("traces",traces) + + traces.filter(t=>t) + } + + } + } } }); diff --git a/src/kiri-mode/cam/ops.js b/src/kiri-mode/cam/ops.js index 28f6a546..ac518af4 100644 --- a/src/kiri-mode/cam/ops.js +++ b/src/kiri-mode/cam/ops.js @@ -1726,6 +1726,49 @@ class OpRegister extends CamOp { } } +class OpHelical extends CamOp { + constructor(state, op) { + super(state, op); + } + + async slice(progress){ + let { op, state } = this; + let { settings, addSlices, widget, updateToolDiams } = state; + let { zBottom, zThru, thruHoles, color } = state; + let { drills, drillThrough} = op + + let drillTool = new CAM.Tool(settings, op.tool), + drillToolDiam = drillTool.fluteDiameter(), + sliceOut = this.sliceOut = []; + + updateToolDiams(drillToolDiam); + + + + + let slice = newSlice(0); + + let poly = newPolygon(); + + + + + slice.camTrace = { tool: op.tool, rate: op.feed, plunge: op.rate }; + slice.camLines = [poly]; + + slice.output() + .setLayer("Helical", {face: color, line: color}) + .addPolys(slice.camLines); + addSlices(slice); + sliceOut.push(slice); + } + + + async prepare(ops, progress){ + + } +} + class OpXRay extends CamOp { constructor(state, op) { super(state, op); @@ -1958,6 +2001,7 @@ CAM.OPS = CamOp.MAP = { "trace": OpTrace, "drill": OpDrill, "register": OpRegister, + "helical": OpHelical, "laser on": OpLaserOn, "laser off": OpLaserOff, "gcode": OpGCode, diff --git a/src/kiri-mode/cam/slice.js b/src/kiri-mode/cam/slice.js index 7e97fc32..aa24628c 100644 --- a/src/kiri-mode/cam/slice.js +++ b/src/kiri-mode/cam/slice.js @@ -515,6 +515,12 @@ CAM.traces = async function(settings, widget, single) { return true; }; + +CAM.cylinders = async (settings, widget) => { + + //this is where the migic is gonna happen +} + /** * Generate a list of holes in the model based on the given diameter. *