checkpoint auto support work
This commit is contained in:
parent
c191e8bc04
commit
4bd21e4e10
5 changed files with 74 additions and 10 deletions
|
|
@ -1619,11 +1619,11 @@
|
||||||
fdmSep: UC.newBlank({class:"pop-sep", modes:FDM}),
|
fdmSep: UC.newBlank({class:"pop-sep", modes:FDM}),
|
||||||
sliceSupportSpan: UC.newInput(LANG.sp_span_s, {title:LANG.sp_span_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM, show: () => UI.sliceSupportEnable.checked}),
|
sliceSupportSpan: UC.newInput(LANG.sp_span_s, {title:LANG.sp_span_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM, show: () => UI.sliceSupportEnable.checked}),
|
||||||
sliceSupportEnable: UC.newBoolean(LANG.sp_auto_s, onBooleanClick, {title: LANG.sp_auto_l, modes:FDM, trigger:true}),
|
sliceSupportEnable: UC.newBoolean(LANG.sp_auto_s, onBooleanClick, {title: LANG.sp_auto_l, modes:FDM, trigger:true}),
|
||||||
// sliceSupportGen: UC.newRow([
|
|
||||||
// UI.ssaGen = UC.newButton('detect', onButtonClick)
|
|
||||||
// ], { modes: FDM }),
|
|
||||||
|
|
||||||
fdmSep: UC.newBlank({class:"pop-sep", modes:FDM}),
|
fdmSep: UC.newBlank({class:"pop-sep", modes:FDM}),
|
||||||
|
sliceSupportGen: LOCAL ? UC.newRow([
|
||||||
|
UI.ssaGen = UC.newButton('detect', onButtonClick, {class: "f-col grow a-center"})
|
||||||
|
], { modes: FDM, class: "ext-buttons f-row grow" }) : null,
|
||||||
sliceSupportManual: UC.newRow([
|
sliceSupportManual: UC.newRow([
|
||||||
(UI.ssmAdd = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
|
(UI.ssmAdd = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
|
||||||
(UI.ssmDun = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-check"></i>'})),
|
(UI.ssmDun = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-check"></i>'})),
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@
|
||||||
KIRI.codec.decode(output).forEach(rec => {
|
KIRI.codec.decode(output).forEach(rec => {
|
||||||
ids.push(rec.id);
|
ids.push(rec.id);
|
||||||
widgets[rec.id].traces = rec.traces;
|
widgets[rec.id].traces = rec.traces;
|
||||||
// widgets[rec.id].sindex = rec.sindex;
|
|
||||||
});
|
});
|
||||||
ondone(ids);
|
ondone(ids);
|
||||||
});
|
});
|
||||||
|
|
@ -45,11 +44,10 @@
|
||||||
const { settings } = data;
|
const { settings } = data;
|
||||||
const widgets = Object.values(cache);
|
const widgets = Object.values(cache);
|
||||||
const fresh = widgets.filter(widget => CAM.traces(settings, widget));
|
const fresh = widgets.filter(widget => CAM.traces(settings, widget));
|
||||||
send.done(KIRI.codec.encode(fresh.map(widget => {return {
|
send.done(KIRI.codec.encode(fresh.map(widget => { return {
|
||||||
id: widget.id,
|
id: widget.id,
|
||||||
traces: widget.traces,
|
traces: widget.traces,
|
||||||
// sindex: widget.sindex
|
} } )));
|
||||||
}})));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,30 @@
|
||||||
});
|
});
|
||||||
api.event.on("fdm.supports.gen", func.sgen = () => {
|
api.event.on("fdm.supports.gen", func.sgen = () => {
|
||||||
alert = api.show.alert("analyzing part...", 1000);
|
alert = api.show.alert("analyzing part...", 1000);
|
||||||
FDM.support_generate(done => {
|
FDM.support_generate(array => {
|
||||||
|
console.log({generated_supports: array});
|
||||||
api.hide.alert(alert);
|
api.hide.alert(alert);
|
||||||
|
for (let rec of array) {
|
||||||
|
let { widget, supports } = rec;
|
||||||
|
let wa = API.widgets.annotate(widget.id);
|
||||||
|
let ws = wa.support || [];
|
||||||
|
for (let support of supports) {
|
||||||
|
let { from, to, mid } = support;
|
||||||
|
let dw = api.conf.get().process.sliceSupportSize / 2;
|
||||||
|
let dh = from.z - to.z;
|
||||||
|
let rec = {
|
||||||
|
x: mid.x,
|
||||||
|
y: mid.y,
|
||||||
|
z: mid.z,
|
||||||
|
dw,
|
||||||
|
dh,
|
||||||
|
id: Math.random() * 0xffffffffff
|
||||||
|
};
|
||||||
|
addWidgetSupport(widget, rec);
|
||||||
|
ws.push(Object.clone(rec));
|
||||||
|
}
|
||||||
|
wa.support = ws;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
api.event.on("fdm.supports.add", func.sadd = () => {
|
api.event.on("fdm.supports.add", func.sadd = () => {
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,24 @@
|
||||||
if (KIRI.client)
|
if (KIRI.client)
|
||||||
// FDM.support_generate = KIRI.client.fdm_support_generate = function(ondone) {
|
// FDM.support_generate = KIRI.client.fdm_support_generate = function(ondone) {
|
||||||
FDM.support_generate = function(ondone) {
|
FDM.support_generate = function(ondone) {
|
||||||
send('fdm_support_generate', {}, ondone);
|
KIRI.client.sync();
|
||||||
|
let settings = API.conf.get();
|
||||||
|
let widgets = API.widgets.map();
|
||||||
|
send('fdm_support_generate', {}, (gen) => {
|
||||||
|
for (let g of gen) g.widget = widgets[g.id];
|
||||||
|
ondone(gen);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (KIRI.worker)
|
if (KIRI.worker)
|
||||||
KIRI.worker.fdm_support_generate = function(data, send) {
|
KIRI.worker.fdm_support_generate = function(data, send) {
|
||||||
send.done();
|
const { settings } = data;
|
||||||
|
const widgets = Object.values(cache);
|
||||||
|
const fresh = widgets.filter(widget => FDM.supports(settings, widget));
|
||||||
|
send.done(KIRI.codec.encode(fresh.map(widget => { return {
|
||||||
|
id: widget.id,
|
||||||
|
supports: widget.supports,
|
||||||
|
} } )));
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1074,4 +1074,36 @@
|
||||||
return good.length > 2 ? good : [];
|
return good.length > 2 ? good : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FDM.supports = function(settings, widget) {
|
||||||
|
let buf = new THREE.BufferGeometry();
|
||||||
|
buf.setAttribute('position', new THREE.BufferAttribute(widget.vertices, 3));
|
||||||
|
let geo = new THREE.Geometry().fromBufferGeometry(buf);
|
||||||
|
// console.log('geo',
|
||||||
|
// geo,
|
||||||
|
// {
|
||||||
|
// "<": geo.faces.filter(f => f.normal.z < 0),
|
||||||
|
// ">": geo.faces.filter(f => f.normal.z > 0),
|
||||||
|
// "=": geo.faces.filter(f => f.normal.z == 0)
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
let mesh = new THREE.Mesh(geo, new THREE.MeshBasicMaterial());
|
||||||
|
let dir = new THREE.Vector3(0,0,-1)
|
||||||
|
let add = [];
|
||||||
|
geo.faces.filter(f => f.normal.z < 0).forEach(face => {
|
||||||
|
let a = geo.vertices[face.a];
|
||||||
|
let b = geo.vertices[face.b];
|
||||||
|
let c = geo.vertices[face.c];
|
||||||
|
let point = a.add(b).add(c).divideScalar(3);
|
||||||
|
let ray = new THREE.Raycaster(point, dir);
|
||||||
|
let int = ray.intersectObjects([ mesh ], false);
|
||||||
|
if (int && int.length) {
|
||||||
|
console.log(int);
|
||||||
|
let mid = new THREE.Vector3().add(point).add(int[0].point).divideScalar(2);
|
||||||
|
add.push({from: point, to: int[0].point, mid});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
widget.supports = add;
|
||||||
|
return add.length > 0;
|
||||||
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue