enable compound loop path code as parameter
This commit is contained in:
parent
ede341d0ab
commit
f4f89bc1ed
4 changed files with 37 additions and 39 deletions
|
|
@ -45,8 +45,8 @@ function init() {
|
|||
opacity: 0,
|
||||
color: 0xdddddd,
|
||||
zoom: { reverse: true, speed: 1 },
|
||||
size: { width: 2000, depth: 2000, height: 0.001, maxz: 200 },
|
||||
grid: { major: 25, minor: 5,
|
||||
size: { width: 2000, depth: 2000, height: 0.05, maxz: 200 },
|
||||
grid: { major: 25, minor: 5, zOffset: 0,
|
||||
colorMajor: 0xcccccc, colorMinor: 0xeeeeee,
|
||||
colorX: 0xff7777, colorY: 0x7777ff },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ let tool = {
|
|||
}
|
||||
},
|
||||
|
||||
analyze(models) {
|
||||
analyze(models, opt = { compound: false }) {
|
||||
models = fallback(models);
|
||||
api.log.emit('analyzing mesh(es)...').pin();
|
||||
let promises = [];
|
||||
|
|
@ -327,7 +327,7 @@ let tool = {
|
|||
let mcore = new Matrix4().makeRotationX(Math.PI / 2);
|
||||
for (let m of models) {
|
||||
// todo - translate vertices with source model's matrix
|
||||
let p = worker.model_analyze(m.id).then(data => {
|
||||
let p = worker.model_analyze({ id: m.id, opt }).then(data => {
|
||||
let { areas, edges } = data.mapped;
|
||||
let nm = areas.map(area => new mesh.model({
|
||||
file: (area.length/3).toString(),
|
||||
|
|
|
|||
|
|
@ -400,41 +400,38 @@ mesh.tool = class MeshTool {
|
|||
// new patch areas
|
||||
let areas = this.areas = [];
|
||||
|
||||
// start disabled code path for complex (nested) paths
|
||||
if (false) {
|
||||
if (opt.compound) {
|
||||
// group loops by normal (using swap as crude proxy for now)
|
||||
// then attempt to nest them (find holes)
|
||||
let polys = loops.map(loop => {
|
||||
return emitLoop(loop);
|
||||
});
|
||||
|
||||
// group loops by normal (using swap as crude proxy for now)
|
||||
// then attempt to nest them (find holes)
|
||||
let polys = loops.map(loop => {
|
||||
return emitLoop(loop);
|
||||
});
|
||||
|
||||
// return nested mapping
|
||||
let nested = geom.nest(polys.map(p => p.points));
|
||||
// recover and map loops from point arrays
|
||||
for (let rec of nested) {
|
||||
rec.loop = polys.filter(loop => loop.points === rec.points)[0];
|
||||
// keep parent/child winding reversed
|
||||
let CCW = rec.depth % 2 === 0;
|
||||
if ((CCW && rec.area > 0) || (!CCW && rec.area < 0)) {
|
||||
rec.points = rec.loop.points = rec.points.group(3).reverse().flat();
|
||||
rec.loop.index = rec.loop.index.reverse();
|
||||
// return nested mapping
|
||||
let nested = geom.nest(polys.map(p => p.points));
|
||||
// recover and map loops from point arrays
|
||||
for (let rec of nested) {
|
||||
rec.loop = polys.filter(loop => loop.points === rec.points)[0];
|
||||
// keep parent/child winding reversed
|
||||
let CCW = rec.depth % 2 === 0;
|
||||
if ((CCW && rec.area > 0) || (!CCW && rec.area < 0)) {
|
||||
rec.points = rec.loop.points = rec.points.group(3).reverse().flat();
|
||||
rec.loop.index = rec.loop.index.reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// extract tops which have nesting depth mod 2 === 0
|
||||
let tops = nested.filter(rec => rec.depth % 2 === 0);
|
||||
for (let top of tops) {
|
||||
areas.push(emitTop(top));
|
||||
}
|
||||
|
||||
} // end of disbled code
|
||||
|
||||
// create area faces covering loops
|
||||
for (let loop of loops) {
|
||||
let l2 = emitLoop(loop);
|
||||
let fs = emitFaces(l2);
|
||||
areas.push(fs);
|
||||
// extract tops which have nesting depth mod 2 === 0
|
||||
let tops = nested.filter(rec => rec.depth % 2 === 0);
|
||||
for (let top of tops) {
|
||||
areas.push(emitTop(top));
|
||||
}
|
||||
} else {
|
||||
// create area faces covering loops
|
||||
for (let loop of loops) {
|
||||
let l2 = emitLoop(loop);
|
||||
let fs = emitFaces(l2);
|
||||
areas.push(fs);
|
||||
}
|
||||
}
|
||||
|
||||
// auto-merge newly found enclosed areas
|
||||
|
|
|
|||
|
|
@ -179,8 +179,9 @@ let model = {
|
|||
return { o1, o2 };
|
||||
},
|
||||
|
||||
analyze(id) {
|
||||
let tool = analyze(id, { mapped: true });
|
||||
analyze(data) {
|
||||
let { id, opt } = data;
|
||||
let tool = analyze(id, { mapped: true, ...opt });
|
||||
let { stats, mapped } = tool;
|
||||
let { cull, dups, faces } = stats;
|
||||
log(`${id} | face count=${faces} bad=${cull} dup=${dups}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue