move thin wall code into functions

This commit is contained in:
Stewart Allen 2025-02-23 09:55:20 -05:00
commit bf5f783c7a
4 changed files with 118 additions and 87 deletions

View file

@ -296,6 +296,7 @@ kiri.Top.prototype.encode = function(state) {
};
if (state.full) {
// obj.gaps = encode(this.gaps, state);
obj.last = encode(this.last, state);
obj.shells = encode(this.shells, state);
obj.fill_off = encode(this.fill_off, state);
@ -308,6 +309,7 @@ kiri.Top.prototype.encode = function(state) {
registerDecoder(TYPE.TOP, function(v, state) {
let top = kiri.newTop(decode(v.poly, state));
if (state.full) {
// top.gaps = decode(v.gaps, state);
top.last = decode(v.last, state);
top.shells = decode(v.shells, state);
top.fill_off = decode(v.fill_off, state);

View file

@ -139,22 +139,27 @@ class Slice {
return this;
}
addTop(poly) {
if (poly.length) {
/**
* @param {Object | Polygon} data
* @returns Slice.Top
*/
addTop(data) {
if (data.length) {
// standard legacy polygon
let top = new Top(poly);
this.tops.push(top);
top.simple = poly;
let top = new Top(data);
this.tops.push(data);
top.simple = data;
return top;
} else {
// frop top object passed back by slicePost()
let top = new Top(poly.poly);
top.thin_fill = poly.thin_fill ? poly.thin_fill.map(p => base.newPoint(p.x,p.y,p.z)) : undefined;
top.fill_lines = poly.fill_lines;
top.fill_off = poly.fill_off;
top.last = poly.last;
top.shells = poly.shells;
top.simple = poly.simple;
// create top object from object bundle passed back by slicePost()
let top = new Top(data.poly);
top.thin_fill = data.thin_fill ? data.thin_fill.map(p => base.newPoint(p.x,p.y,p.z)) : undefined;
top.fill_lines = data.fill_lines;
top.fill_off = data.fill_off;
top.last = data.last;
top.gaps = data.gaps;
top.shells = data.shells;
top.simple = data.simple;
this.tops.push(top);
return top;
}