add drills to rec, and fix slicing
This commit is contained in:
parent
68f10c875f
commit
1a00278bce
2 changed files with 45 additions and 24 deletions
|
|
@ -400,7 +400,9 @@ CAM.init = function(kiri, api) {
|
||||||
};
|
};
|
||||||
|
|
||||||
func.opAddDrill = () => {
|
func.opAddDrill = () => {
|
||||||
func.opAdd(popOp.drill.new());
|
let rec = popOp.drill.new();
|
||||||
|
rec.drills = { /* widget.id: [ drills... ] */ };
|
||||||
|
func.opAdd(rec);
|
||||||
};
|
};
|
||||||
|
|
||||||
func.opAddRegister = (axis, points) => {
|
func.opAddRegister = (axis, points) => {
|
||||||
|
|
@ -1191,6 +1193,13 @@ CAM.init = function(kiri, api) {
|
||||||
alert = api.show.alert("[esc] cancels trace editing");
|
alert = api.show.alert("[esc] cancels trace editing");
|
||||||
kiri.api.widgets.opacity(0.8);
|
kiri.api.widgets.opacity(0.8);
|
||||||
|
|
||||||
|
holes.toRecord = () => {
|
||||||
|
return holes.map(hole => {
|
||||||
|
let {x,y,z,depth,selected} = hole
|
||||||
|
return {x,y,z,depth,selected}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (!holes.length) {
|
if (!holes.length) {
|
||||||
unselectHoles(holes);
|
unselectHoles(holes);
|
||||||
}
|
}
|
||||||
|
|
@ -1214,6 +1223,10 @@ CAM.init = function(kiri, api) {
|
||||||
hole.updateColor()
|
hole.updateColor()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
//add hole data to record
|
||||||
|
|
||||||
|
poppedRec.drills[widget.id] = holes.toRecord();
|
||||||
|
|
||||||
widget.holes.forEach(hole => {
|
widget.holes.forEach(hole => {
|
||||||
widget.mesh.add(hole.mesh);
|
widget.mesh.add(hole.mesh);
|
||||||
widget.adds.push(hole.mesh);
|
widget.adds.push(hole.mesh);
|
||||||
|
|
@ -1265,6 +1278,9 @@ CAM.init = function(kiri, api) {
|
||||||
let { object } = int;
|
let { object } = int;
|
||||||
func.selectHoleToggle(object.hole);
|
func.selectHoleToggle(object.hole);
|
||||||
|
|
||||||
|
let widget = object.parent.widget; //only update the parent widget
|
||||||
|
poppedRec.drills[widget.id] = widget.holes.toRecord();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func.selectHoleToggle = function(hole) {
|
func.selectHoleToggle = function(hole) {
|
||||||
|
|
|
||||||
|
|
@ -1463,47 +1463,52 @@ class OpDrill extends CamOp {
|
||||||
let { op, state } = this;
|
let { op, state } = this;
|
||||||
let { settings, addSlices, widget, updateToolDiams } = state;
|
let { settings, addSlices, widget, updateToolDiams } = state;
|
||||||
let { zBottom, zThru, thruHoles, color } = state;
|
let { zBottom, zThru, thruHoles, color } = state;
|
||||||
|
let { drills, drillThrough} = op
|
||||||
|
|
||||||
let drills = [],
|
let drillTool = new CAM.Tool(settings, op.tool),
|
||||||
drillTool = new CAM.Tool(settings, op.tool),
|
|
||||||
drillToolDiam = drillTool.fluteDiameter(),
|
drillToolDiam = drillTool.fluteDiameter(),
|
||||||
sliceOut = this.sliceOut = [];
|
sliceOut = this.sliceOut = [];
|
||||||
|
|
||||||
updateToolDiams(drillToolDiam);
|
updateToolDiams(drillToolDiam);
|
||||||
|
|
||||||
console.log(widget)
|
|
||||||
|
const allDrills = Object.values(drills).flat();
|
||||||
|
|
||||||
|
console.log("drills",allDrills)
|
||||||
|
console.log("op",op)
|
||||||
|
|
||||||
// for each slice, look for polygons with 98.5% circularity whose
|
// for each slice, look for polygons with 98.5% circularity whose
|
||||||
// area is within the tolerance of a circle matching the tool diameter
|
// area is within the tolerance of a circle matching the tool diameter
|
||||||
|
|
||||||
|
|
||||||
// drill points to use center (average of all points) of the polygon
|
// drill points to use center (average of all points) of the polygon
|
||||||
drills.forEach(function(drill) {
|
allDrills.forEach((drill)=> {
|
||||||
let center = drill.center(true),
|
let slice = newSlice(0);
|
||||||
slice = newSlice(0,null);
|
|
||||||
if (op.mark) {
|
if (op.mark) {
|
||||||
// replace points with single mark
|
// replace depth with single down peck
|
||||||
let points = drill.points;
|
drill.depth = op.down
|
||||||
points = [
|
|
||||||
points[0],
|
|
||||||
points[0].clone().sub({x:0, y:0, z:op.down})
|
|
||||||
];
|
|
||||||
drill.points = points;
|
|
||||||
}
|
}
|
||||||
drill.points.forEach(function(point) {
|
drill.zBottom = drill.z - drill.depth;
|
||||||
point.x = center.x;
|
|
||||||
point.y = center.y;
|
|
||||||
});
|
|
||||||
// for thru holes, follow z thru when set
|
// for thru holes, follow z thru when set
|
||||||
if ((op.thru>0) && center.isInPolygon(thruHoles)) {
|
if ((op.thru>0) ) {
|
||||||
drill.points.push(drill.points.last().sub({x:0,y:0,z:op.thru}));
|
drill.zBottom -= op.thru;
|
||||||
}else if(zThru && center.isInPolygon(thruHoles)){
|
|
||||||
drill.points.push(drill.points.last().sub({x:0,y:0,z:zThru}));
|
|
||||||
}
|
}
|
||||||
slice.camLines = [ drill ];
|
console.log(slice)
|
||||||
|
|
||||||
|
const poly = newPolygon()
|
||||||
|
poly.points.push({x:drill.x, y:drill.y, z:drill.z})
|
||||||
|
poly.points.push({x:drill.x, y:drill.y, z:drill.zBottom})
|
||||||
|
|
||||||
|
// poly.points.pop();
|
||||||
|
slice.camTrace = { tool: op.tool, rate: op.feed, plunge: op.rate };
|
||||||
|
slice.camLines = [poly];
|
||||||
|
|
||||||
|
console.log("cam line",slice.camLines)
|
||||||
slice.output()
|
slice.output()
|
||||||
.setLayer("drill", {face: color, line: color})
|
.setLayer("drill", {face: color, line: color})
|
||||||
.addPolys(drill);
|
.addPolys(slice.camLines);
|
||||||
addSlices(slice);
|
addSlices(slice);
|
||||||
sliceOut.push(slice);
|
sliceOut.push(slice);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue