add thin type 3 test
This commit is contained in:
parent
382e0cd5d7
commit
91ad27f540
5 changed files with 69 additions and 3 deletions
|
|
@ -253,6 +253,40 @@ class Polygon {
|
|||
return ret;
|
||||
}
|
||||
|
||||
setInner(inner) {
|
||||
this.inner = inner;
|
||||
return this;
|
||||
}
|
||||
|
||||
// generate a trace path around the inside of a polygon
|
||||
// including inner polys. return the noodle and the remainder
|
||||
// of the polygon with the noodle removed (for the next pass)
|
||||
noodle(width) {
|
||||
// inset outer polygon
|
||||
let inner = this.inner;
|
||||
let inset = this.clone().offset(width);
|
||||
let noodle = [ this.clone().setInner(inset) ];
|
||||
let noodin = [];
|
||||
// subtract inners from the inset
|
||||
if (inner) {
|
||||
noodle = POLY.subtract(noodle, inner, []);
|
||||
// for each inner, offset and subtract noodle + itself
|
||||
let nood = [];
|
||||
for (let innie of inner) {
|
||||
let inexp = innie.clone().offset(-width);
|
||||
let intrm = POLY.trimTo(inexp, [ this ]);
|
||||
let inood = POLY.subtract(intrm, [ ...noodle, innie ], []);
|
||||
nood.push(...inood);
|
||||
}
|
||||
noodin = POLY.union(nood, 0, true);
|
||||
}
|
||||
// unify inner noodles and outer noodle
|
||||
noodle = POLY.union([ ...noodle, ...noodin ], 0, true);
|
||||
// subtract noodle from poly for next noodle calc
|
||||
let remain = POLY.subtract([ this ], noodle, []);
|
||||
return { noodle, remain };
|
||||
}
|
||||
|
||||
// generate center crossing point cloud
|
||||
centers(step, z, min, max, opt = {}) {
|
||||
let cloud = [],
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ function diff(setA, setB, z) {
|
|||
/**
|
||||
* Slice.doProjectedFills()
|
||||
*
|
||||
* @param {Polygon[]} setA source set
|
||||
* @param {Polygon[]} setA target set
|
||||
* @param {Polygon[]} setB mask set
|
||||
* @returns {Polygon[]}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -167,6 +167,28 @@ function thin_type_2(params) {
|
|||
return { last, gaps };
|
||||
}
|
||||
|
||||
function thin_type_3(params) {
|
||||
let { z, top, count, offsetN, last, gaps } = params;
|
||||
top.thin_fill = [];
|
||||
top.fill_sparse = [];
|
||||
|
||||
let { noodle, remain } = top.poly.noodle(offsetN);
|
||||
top.shells = noodle;
|
||||
top.gaps = remain;
|
||||
// top.fill_off = noodle;
|
||||
|
||||
// if (remain.length) {
|
||||
// top.gaps = [];
|
||||
// for (let poly of remain) {
|
||||
// let { noodle } = poly.noodle(offsetN);
|
||||
// console.log({ next_noodle: noodle });
|
||||
// top.gaps.push(...noodle);
|
||||
// }
|
||||
// }
|
||||
|
||||
return { last, gaps };
|
||||
}
|
||||
|
||||
/**
|
||||
* may run in minion or worker context. performs shell offsetting
|
||||
* including thin wall detection when enabled
|
||||
|
|
@ -214,6 +236,10 @@ FDM.doTopShells = function(z, top, count, offset1, offsetN, fillOffset, opt = {}
|
|||
case "type 2":
|
||||
ret = thin_type_2({ z, top, count, top_poly, offset1, offsetN, fillOffset, gaps, wasm });
|
||||
break;
|
||||
case "type 3":
|
||||
ret = thin_type_3({ z, top, count, top_poly, offsetN });
|
||||
fillOffset = 0;
|
||||
break;
|
||||
default:
|
||||
ret = offset_default({ z, top, count, top_poly, offset1, offsetN, wasm });
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ const LISTS = {
|
|||
thin: [
|
||||
{ name: "off" },
|
||||
{ name: "type 1" },
|
||||
{ name: "type 2" }
|
||||
{ name: "type 2" },
|
||||
{ name: "type 3" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1863,6 +1863,11 @@ gapp.register("kiri.init", (root, exports) => {
|
|||
const current = settings();
|
||||
const control = current.controller;
|
||||
|
||||
if (!control.devel) {
|
||||
// TODO: hide thin type 3 during development
|
||||
kiri.consts.LISTS.thin.length = 3;
|
||||
}
|
||||
|
||||
platform.deselect();
|
||||
catalog.addFileListener(updateCatalog);
|
||||
space.view.setZoom(control.reverseZoom, control.zoomSpeed);
|
||||
|
|
|
|||
Loading…
Reference in a new issue