@z3dev Yes I'm creating the slices for each axis from intersection of the model and a translated cuboid, then I create notches made from intersections of those slices, 1st axis slices have top half of those intersections subtracted and 2nd axis slices have bottom half, so they fit. Code is :
const main = (params) => {
const sc = 1, ep = params.ep *2
const vv = require('./' + params.v)
const vol = center({}, rotateX(degToRad(90), vv))
let r = [], rH = [], rV = []
let bV = measureBoundingBox(vol)
const pv = Object.values(params)
const lH = pv.slice(0,10).filter(Number).map(x => (x-50)/100)
const lV = pv.slice(10,20).filter(Number).map(x => (x-50)/100)
fH = bV[1][0] - bV[0][0]
mH = (bV[1][0] + bV[0][0]) / 2
var trH = cuboid( {
size: [ ep, 1+bV[1][1]- bV[0][1], 1+bV[1][2] - bV[0][2] ]} )
for (let i = 0; i < lH.length; i++){
var t = intersect(vol, translateX(fH * lH[i], trH))
if (t.polygons.length > 0)
rH.push(t)
}
fV = bV[1][1] - bV[0][1]
mV = (bV[1][1] + bV[0][1]) / 2
var trV = cuboid( {
size: [ 1+ bV[1][0] - bV[0][0], ep, 1+ bV[1][2] - bV[0][2] ]} )
for (let i = 0; i < lV.length; i++){
var t = intersect(vol, translateY(fV * lV[i], trV))
if (t.polygons.length > 0)
rV.push(t)
}
var ur = union(intersect(union(rH), union(rV)));
var tmp = scission(ur)
console.log(tmp.length)
var eS = [], eH = [], eV = [];
for(let i=0; i< tmp.length; i++){
let p = tmp[i];
let b = measureBoundingBox(p),
d = [b[1][0]-b[0][0], b[1][1]-b[0][1], b[1][2]-b[0][2]];
let c1 = translate([b[0][0], b[0][1] + ep/2, b[0][2]],
cuboid({size: [d[0], d[1]*2, d[2]]}));
let c2 = translate([b[0][0] + ep/2, b[0][1], b[1][2]],
cuboid({size: [d[0]*2, d[1], d[2]]}));
eH.push(intersect(tmp[i], c1));
eV.push(intersect(tmp[i], c2));
}
rH = rH.map(x=> subtract(x, eV));
rV = rV.map(x=> subtract(x, eH));
if(params.mode == '3'){
r.push(colorize([0,1,0,0.8], translateX(-70, subtract(vol, [rH,rV]))));
r.push(colorize([0.5,0.0,0], translateX(-70, rH.shift())));
if(rH.length > 0){
r.push(colorize([1,0,0], translateX(-70, rH)));
}
r.push(colorize([0,0,0.5], translateX(-70, rV.shift())));
if(rV.length > 0){
r.push(colorize([0,0,1], translateX(-70, rV)));
}
} else {
var dk = Math.max(fV, fH) *1.1
for(let ih = 0; ih < rH.length; ih++){
let b = measureBoundingBox(rH[ih]);
r.push(translateX(dk *ih, union(project({axis:[1,0,0]}, rH[ih]))))
}
for(let iv = 0; iv < rV.length; iv++){
let b = measureBoundingBox(rV[iv]);
r.push(translate([dk *iv, -dk - params.dky], union(project({axis:[0,1,0]}, rV[iv]))))
}
}
return r;
}
Stack trace is maybe (I'm using Firefox) :
fromPoints blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:555
m blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:1389
map self-hosted:224
projectGeom3 blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:1389
n blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:1389
map self-hosted:224
project blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:1389
main blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce line 38 > Function:137
instanciateDesign blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:5
rebuildSolids blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:8
onmessage blob:https://openjscad.xyz/333c3c92-e91a-42a7-8b4b-7dc2cdc255ce:11