add contour output density control through new parameter 'reduction' which can produce similar results with radically smaller file sizes

This commit is contained in:
Stewart Allen 2023-01-19 18:25:40 -05:00
commit b0f05dc285
5 changed files with 31 additions and 21 deletions

View file

@ -26,8 +26,9 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
* CAM add threading support for all slicing ops
* CAM add omit pocket option to outline op
* CAM add trace support for taper tip diameter
* CAM add trace offset override
* CAM add leave stock to contour
* CAM add trace offset override parameter
* CAM add leave stock parameter to contour
* CAM add contour output density control (reduction)
# Release 3.7 (2022-11-12)

View file

@ -1299,6 +1299,7 @@ CAM.init = function(kiri, api) {
leave: 'camContourLeave',
tolerance: 'camTolerance',
flatness: 'camFlatness',
reduction: 'camContourReduce',
bridging: 'camContourBridge',
bottom: 'camContourBottom',
curves: 'camContourCurves',
@ -1315,8 +1316,9 @@ CAM.init = function(kiri, api) {
leave: UC.newInput(LANG.cf_leav_s, {title:LANG.cf_leav_l, convert:UC.toFloat, bound:UC.bound(0,100)}),
sep: UC.newBlank({class:"pop-sep"}),
angle: UC.newInput(LANG.cf_angl_s, {title:LANG.cf_angl_l, convert:UC.toFloat, bound:UC.bound(45,90), show:(op) => op.inputs.curves.checked}),
flatness: UC.newInput(LANG.ou_flat_s, {title:LANG.ou_flat_l, convert:UC.toFloat, bound:UC.bound(0,1.0), units:true, round:4}),
flatness: UC.newInput(LANG.ou_flat_s, {title:LANG.ou_flat_l, convert:UC.toFloat, bound:UC.bound(0,1.0), units:false, round:4}),
tolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0,10.0), units:true, round:4}),
reduction: UC.newInput(LANG.ou_redu_s, {title:LANG.ou_redu_l, convert:UC.toInt, bound:UC.bound(0,10), units:false}),
// bridging: UC.newInput(LANG.ou_brdg_s, {title:LANG.ou_brdg_l, convert:UC.toFloat, bound:UC.bound(0,1000.0), units:true, round:4, show:(op) => op.inputs.curves.checked}),
sep: UC.newBlank({class:"pop-sep"}),
curves: UC.newBoolean(LANG.cf_curv_s, undefined, {title:LANG.cf_curv_l}),

View file

@ -31,7 +31,7 @@ class Topo {
let { widget, settings, tshadow, center, tabs, color } = opt.state;
let { controller, process } = settings,
density = parseInt(controller.animesh || 100) * 2500,
animesh = parseInt(controller.animesh || 100) * 2500,
axis = contour.axis.toLowerCase(),
contourX = axis === "x",
contourY = axis === "y",
@ -48,7 +48,8 @@ class Topo {
boundsX = maxX - minX,
boundsY = maxY - minY,
inside = contour.inside,
resolution = tolerance ? tolerance : 1/Math.sqrt(density/(boundsX * boundsY)),
density = 1 + (contour.reduction || 0),
resolution = tolerance ? tolerance : 1/Math.sqrt(animesh/(boundsX * boundsY)),
tool = new CAM.Tool(settings, contour.tool),
toolOffset = tool.generateProfile(resolution).profile,
toolDiameter = tool.fluteDiameter(),
@ -98,7 +99,7 @@ class Topo {
}
// console.log({ resolution, flatness });
this.tolerance = resolution;
// this.tolerance = resolution;
if (tabs) {
clipTab.appendAll(tabs.map(tab => {
@ -181,6 +182,7 @@ class Topo {
toolStep,
contourX,
contourY,
density,
clipTo,
clipTab,
clipTabZ: clipTab ? clipTab.map(t => t.z) : undefined,
@ -308,7 +310,7 @@ class Topo {
const concurrent = kiri.minions.running;
const { minX, maxX, minY, maxY, boundsX, boundsY, stepsX, stepsY } = params;
const { gridDelta, resolution, partOff, toolStep, contourX, contourY } = params;
const { gridDelta, resolution, density, partOff, toolStep, contourX, contourY } = params;
const { clipTo, clipTab, clipTabZ, tabHeight, newslices, color, leave } = params;
let stepsTaken = 0,
@ -338,7 +340,8 @@ class Topo {
clipTabZ,
tabHeight,
resolution,
concurrent
concurrent,
density
});
let resolver;
@ -500,8 +503,6 @@ class Trace {
lastPP,
lastSlope;
const curvature = flatness / 10;
const newslice = this.newslice = () => {
this.slice = slice = [];
}
@ -654,16 +655,18 @@ class Trace {
crossY_sync(params, then) {
const { push_point, end_poly, newtrace, newslice, inClip } = this.object;
const { clipTab, tabHeight, clipTo, box, resolution, leave } = this.cross;
const { clipTab, tabHeight, clipTo, box, resolution, density, leave } = this.cross;
const { toolAtZ } = this.probe;
let { from, to, x, gridx, gridy } = params;
const step = resolution * density;
const checkr = newPoint(0,0);
newslice();
newtrace();
for (let y = from; y < to; y += resolution) {
for (let y = from; y < to; y += step) {
if (y < box.min.y || y > box.max.y) {
gridy++;
gridy += density;
continue;
}
// find tool z at grid point
@ -679,11 +682,11 @@ class Trace {
// poly (usually shadow), end the segment
if (clipTo && !inClip(clipTo, undefined, checkr)) {
end_poly();
gridy++;
gridy += density;
continue;
}
push_point(x, y, tv + leave);
gridy++;
gridy += density;
}
end_poly();
then(this.slice);
@ -691,16 +694,17 @@ class Trace {
crossX_sync(params, then) {
const { push_point, end_poly, newtrace, newslice, inClip } = this.object;
const { clipTab, tabHeight, clipTo, box, resolution, leave } = this.cross;
const { clipTab, tabHeight, clipTo, box, resolution, density, leave } = this.cross;
const { toolAtZ } = this.probe;
let { from, to, y, gridx, gridy } = params;
const step = resolution * density;
const checkr = newPoint(0,0);
newslice();
newtrace();
for (let x = from; x < to; x += resolution) {
for (let x = from; x < to; x += step) {
if (x < box.min.x || x > box.max.x) {
gridx++;
gridx += density;
continue;
}
// find tool z at grid point
@ -716,11 +720,11 @@ class Trace {
// poly (usually shadow), end the segment
if (clipTo && !inClip(clipTo, undefined, checkr)) {
end_poly();
gridx++;
gridx += density;
continue;
}
push_point(x, y, tv + leave);
gridx++;
gridx += density;
}
end_poly();
then(this.slice);

View file

@ -494,6 +494,7 @@ const conf = exports({
camContourSpeed: 1000,
camContourAngle: 85,
camContourLeave: 0,
camContourReduce: 2,
camContourBottom: false,
camContourCurves: false,
camContourIn: false,

View file

@ -664,10 +664,12 @@ self.kiri.lang['en-us'] = {
ou_fans_l: "0 - 255",
// OUTPUT CAM
ou_toll_s: "tolerance",
ou_toll_s: "precision",
ou_toll_l: ["surface precision","in workspace units","lower is slower and","uses more memory","0 = automatic based","on animate preference"],
ou_flat_s: "flatness",
ou_flat_l: ["delta z below which two adjacent points are considered co-linear. 0 = compute using tolerance"],
ou_redu_s: "reduction",
ou_redu_l: ["number of axis steps to skip for each unit of precision. higher precision may require reduction to produce reasonable file sizes. start at 0 and test in increments of 1."],
ou_brdg_s: "bridging",
ou_brdg_l: ["flat distance between curved","areas to bridge with a cut"],
ou_zanc_s: "z anchor",