much better tab cutout control with count and angle now controllable

This commit is contained in:
Stewart Allen 2020-03-05 11:53:54 -05:00
commit 230a1e5f66
3 changed files with 41 additions and 33 deletions

View file

@ -747,39 +747,41 @@ var gs_kiri_cam = exports;
// for tracing out intersections
trace.setClockwise();
const outside = 10000,
width = (tabWidth + toolDiam) / 2,
// horizontal top cut
htl = { x: -outside, y: width },
htr = { x: -htl.x, y: htl.y },
// horizontal bottom cut
hbl = { x: htl.x, y: -htl.y },
hbr = { x: -htl.x, y: -htl.y },
// vertical left cut
vtl = { x: -width, y: outside },
vbl = { x: vtl.x, y: -vtl.y },
// vertical right cut
vtr = { x: -vtl.x, y: vtl.y },
vbr = { x: -vtl.x, y: -vtl.y },
nutraces = [];
var lrtop = trace.intersections(htl, htr),
lrbot = trace.intersections(hbl, hbr),
tblt = trace.intersections(vtl, vbl),
tbrt = trace.intersections(vtr, vbr);
if (!(lrtop.length && lrbot.length && tblt.length && tbrt.length)) {
console.log("unable to compute cutouts");
return;
let count = proc.camTabsCount;
let angle = proc.camTabsAngle;
let angle_inc = 360 / count;
let center = BASE.newPoint(0,0,slice.z);
let offset = (tabWidth + toolDiam) / 2;
let ints = [];
let segs = [];
while (count-- > 0) {
let slope = BASE.newSlopeFromAngle(angle);
let normal = BASE.newSlopeFromAngle(angle + 90);
let c1 = center.projectOnSlope(normal, offset);
let c2 = center.projectOnSlope(normal, -offset);
let o1 = c1.projectOnSlope(slope, 10000);
let o2 = c2.projectOnSlope(slope, 10000);
let int1 = trace.intersections(c1, o1).pop();
let int2 = trace.intersections(c2, o2).pop();
if (int1 && int2) {
ints.push(int1);
ints.push(int2);
}
// segs.push(BASE.newPolygon([c1, o1]).setOpen());
// segs.push(BASE.newPolygon([c2, o2]).setOpen());
angle -= angle_inc;
}
if (ints.length) {
let z = slice.z;
ints.push(ints.shift());
for (let i=0; i<ints.length; i+=2) {
segs.push(trace.emitSegment(ints[i], ints[i+1]));
}
// replace intersected trace with segments
slice.tops[0].traces.splice(index, 1, ...segs);
} else {
console.log(`unable to compute tabs for slice @ ${slice.z}`);
}
var tr1 = trace.emitSegment(lrtop[0], tblt[0]),
tr2 = trace.emitSegment(tbrt[0], lrtop[lrtop.length-1]),
tr3 = trace.emitSegment(lrbot[lrbot.length-1], tbrt[tbrt.length-1]),
tr4 = trace.emitSegment(tblt[tblt.length-1], lrbot[0]);
// remove cut trace and replace with open polys
slice.tops[0].traces.splice(index, 1, tr1, tr2, tr3, tr4);
}
// called when horizontal slicing complete

View file

@ -162,6 +162,8 @@ self.kiri.license = exports.LICENSE;
drillDwell: 1,
drillLift: 1,
drillingOn: 1,
camTabsAngle: 1,
camTabsCount: 1,
camTabsWidth: 1,
camTabsHeight: 1,
camTabsOn: 1,
@ -389,6 +391,8 @@ self.kiri.license = exports.LICENSE;
drillLift: 2,
drillingOn: false,
camTabsAngle: 0,
camTabsCount: 4,
camTabsWidth: 5,
camTabsHeight: 5,
camTabsOn: false,
@ -2838,6 +2842,8 @@ self.kiri.license = exports.LICENSE;
drillingOn: UC.newBoolean("enable", onBooleanClick, {modes:CAM}),
camTabs: UC.newGroup("cutout tabs", null, {modes:CAM}),
camTabsAngle: UC.newInput("angle", {title:"starting angle for tab spacing\nin degrees", convert:UC.toInt, bound:UC.bound(0,360), modes:CAM}),
camTabsCount: UC.newInput("count", {title:"number of tabs to use\nwill be spaced evenly\naround the part", convert:UC.toInt, bound:UC.bound(1,20), modes:CAM}),
camTabsWidth: UC.newInput("width", {title:"width in millimeters\nperpendicular to part", convert:UC.toFloat, bound:UC.bound(1,100), modes:CAM}),
camTabsHeight: UC.newInput("height", {title:"height in millimeters\nfrom part bottom", convert:UC.toFloat, bound:UC.bound(1,100), modes:CAM}),
camTabsOn: UC.newBoolean("enable", onBooleanClick, {title:"enable or disable tabs\ntab generation skipped when\npocket only mode enabled", modes:CAM}),

View file

@ -1,7 +1,7 @@
var exports = {
COPYRIGHT:"Copyright (C) 2014-2019 Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE:"See the license.md file included with the source distribution",
VERSION:"1.6.7"
VERSION:"1.6.8"
};
if (!module) var module = {};
module.exports = exports;