compute inner ball and taper trace paths

This commit is contained in:
Stewart Allen 2020-03-11 20:28:28 -04:00
commit 685db22d2c
4 changed files with 77 additions and 26 deletions

View file

@ -740,7 +740,7 @@ let gs_kiri_cam = exports;
const output = POLY.flatten(offset, [], true);
slice.tops[0].inner = output;
// slice.tops[0].inner = output;
slice.tops[0].traces = output;
};
@ -985,6 +985,60 @@ let gs_kiri_cam = exports;
onupdate(0.50 + update * 0.50, msg || "create topo");
});
// check for ball and taper mills paths and add to top[0].inner
if (procFinish) {
let tool = getToolById(conf, proc.finishingTool);
if (tool.type !== 'endmill') {
let profile = createToolProfile(conf, proc.finishingTool, widget.topo);
sliceAll.forEach(function(slice, index) {
let polys = [];
let nups = [];
slice.gatherTopPolys([]).forEach(poly => poly.flattenTo(polys));
polys.forEach(poly => {
let pz = poly.first().z;
let mz = -Infinity;
let np = newPolygon().setOpen();
let mp = 0;
// find top poly segments that are not significantly offset
// my tool profile and add to new polygons which accumulate
// to the top inner array
// TODO offset polygons should be calculated after this pass
// so that they can not be offset when segments match
// TODO for now remove trace polygons enclosed by newly
// created inner polygons
poly.forEachSegment((p1,p2) => {
let nz = getTopoZPathMax(widget, profile, p1.x, p1.y, p2.x, p2.y);
if (nz > mz) {
mz = nz;
}
if (nz - pz < 0.01) {
mp++
if (np.length) {
if (!np.first().isEqual(p2)) {
np.append(p2);
} else {
np.setClosed();
}
} else {
np.append(p1).append(p2);
}
} else if (np.length) {
nups.append(np);
np = newPolygon().setOpen();
}
});
if (np.length) {
nups.append(np);
}
// if (mp) console.log(slice.z,'match',mp,poly.length,np.length);
});
if (nups.length) {
slice.tops[0].inner = nups;
}
});
}
}
ondone();
};

View file

@ -15,11 +15,14 @@ var gs_kiri_fdm = exports;
DBUG = BASE.debug,
UTIL = BASE.util,
CONF = BASE.config,
FDM = KIRI.driver.FDM = { },
POLY = BASE.polygons,
FDM = KIRI.driver.FDM = {
slice,
printSetup,
printExport
},
SLICER = KIRI.slicer,
newPoint = BASE.newPoint,
time = UTIL.time;
newPoint = BASE.newPoint;
// customer gcode post function for XYZ daVinci Mini W
self.kiri_fdm_xyz_mini_w = function(gcode, options) {
@ -39,10 +42,10 @@ var gs_kiri_fdm = exports;
* @param {Function} onupdate (called with % complete and optional message)
* @param {Function} ondone (called when complete with an array of Slice objects)
*/
FDM.slice = function(settings, widget, onupdate, ondone) {
function slice(settings, widget, onupdate, ondone) {
var spro = settings.process,
sdev = settings.device,
update_start = time(),
update_start = Date.now(),
minSolid = spro.sliceSolidMinArea,
solidLayers = spro.sliceSolidLayers,
vaseMode = spro.sliceFillType === 'vase',
@ -334,7 +337,7 @@ var gs_kiri_fdm = exports;
* @param {Object} print state object
* @param {Function} update incremental callback
*/
FDM.printSetup = function(print, update) {
function printSetup(print, update) {
var widgets = print.widgets,
settings = print.settings,
device = settings.device,
@ -551,7 +554,7 @@ var gs_kiri_fdm = exports;
/**
* @returns {Array} gcode lines
*/
FDM.printExport = function(print, online) {
function printExport(print, online) {
var layers = print.output,
settings = print.settings,
device = settings.device,

View file

@ -14,7 +14,13 @@ var gs_kiri_laser = exports;
BASE = self.base,
UTIL = BASE.util,
DBUG = BASE.debug,
LASER = KIRI.driver.LASER = { },
LASER = KIRI.driver.LASER = {
slice,
printSetup,
exportGCode,
exportSVG,
exportDXF
},
SLICER = KIRI.slicer,
newPoint = BASE.newPoint;
@ -26,7 +32,7 @@ var gs_kiri_laser = exports;
* @param {Function} onupdate (called with % complete and optional message)
* @param {Function} ondone (called when complete with an array of Slice objects)
*/
LASER.slice = function(settings, widget, onupdate, ondone) {
function slice(settings, widget, onupdate, ondone) {
var proc = settings.process;
if (proc.laserSliceHeight < 0) {
@ -82,7 +88,7 @@ var gs_kiri_laser = exports;
* @param {Object} print state object
* @param {Function} update incremental callback
*/
LASER.printSetup = function(print, update) {
function printSetup(print, update) {
var widgets = print.widgets,
settings = print.settings,
device = settings.device,
@ -242,7 +248,7 @@ var gs_kiri_laser = exports;
/**
*
*/
LASER.exportGCode = function(print) {
function exportGCode(print) {
var lines = [], dx = 0, dy = 0, feedrate, laser_on;
exportElements(
@ -283,7 +289,7 @@ var gs_kiri_laser = exports;
/**
*
*/
LASER.exportSVG = function(print, cut_color) {
function exportSVG(print, cut_color) {
var lines = [], dx = 0, dy = 0, my;
var color = cut_color || "blue";
@ -316,7 +322,7 @@ var gs_kiri_laser = exports;
/**
*
*/
LASER.exportDXF = function(print) {
function exportDXF(print) {
var lines = [];
exportElements(

View file

@ -245,18 +245,6 @@ var gs_kiri_widget = exports;
});
};
// PRO.encodeSlices = function() {
// var encoded = [];
// if (this.slices) this.slices.forEach(function(slice) {
// encoded.push(slice.encode());
// });
// return encoded;
// };
// PRO.decodeSlices = function(encoded) {
// this.slices = KIRI.codec.decode(encoded, { mesh:this.mesh });
// };
/**
*
* @param {Float32Array} vertices