filter slice shells with miniscule areas
This commit is contained in:
parent
3e56c3e965
commit
c7bd107567
2 changed files with 16 additions and 5 deletions
|
|
@ -123,9 +123,9 @@ class Slice {
|
|||
return slice ? POLY.fingerprintCompare(this.fingerprint(), slice.fingerprint()) : false;
|
||||
};
|
||||
|
||||
addTops(polys) {
|
||||
addTops(polys, opt) {
|
||||
polys.forEach(p => {
|
||||
this.addTop(p);
|
||||
this.addTop(p, opt);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
|
@ -134,16 +134,23 @@ class Slice {
|
|||
* @param {Object | Polygon} data
|
||||
* @returns Slice.Top
|
||||
*/
|
||||
addTop(data) {
|
||||
addTop(data, opt) {
|
||||
let minArea = opt.minArea ?? 0;
|
||||
if (data.length) {
|
||||
// standard legacy polygon
|
||||
let top = new Top(data);
|
||||
if (top.area() < minArea) {
|
||||
return null;
|
||||
}
|
||||
this.tops.push(top);
|
||||
top.simple = data;
|
||||
return top;
|
||||
} else {
|
||||
// create top object from object bundle passed back by slicePost()
|
||||
let top = new Top(data.poly);
|
||||
if (top.area() < minArea) {
|
||||
return null;
|
||||
}
|
||||
top.thin_fill = data.thin_fill?.map(p => newPoint(p.x,p.y,p.z));
|
||||
top.thin_wall = data.thin_wall;
|
||||
top.thin_sort = data.thin_sort;
|
||||
|
|
@ -152,7 +159,7 @@ class Slice {
|
|||
top.fill_off = data.fill_off;
|
||||
top.last = data.last;
|
||||
top.gaps = data.gaps;
|
||||
top.shells = data.shells;
|
||||
top.shells = data.shells.filter(p => p.area() > minArea);
|
||||
top.simple = data.simple;
|
||||
this.tops.push(top);
|
||||
return top;
|
||||
|
|
@ -208,6 +215,10 @@ class Top {
|
|||
this.poly = polygon; // outline poly
|
||||
}
|
||||
|
||||
area() {
|
||||
return this.poly.area();
|
||||
}
|
||||
|
||||
clone(deep) {
|
||||
let top = new Top(this.poly.clone(deep));
|
||||
return top;
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ export function fdm_slice(settings, widget, onupdate, ondone) {
|
|||
return output.slices.map(data => {
|
||||
let { z, clip, lines, groups, changes } = data;
|
||||
if (!data.tops) return null;
|
||||
let slice = newSlice(z).addTops(data.tops);
|
||||
let slice = newSlice(z).addTops(data.tops, { minArea: 0.1 });
|
||||
slice.index = indices.indexOf(z);
|
||||
slice.height = heights[slice.index];
|
||||
slice.clips = clip;
|
||||
|
|
|
|||
Loading…
Reference in a new issue