Doodle3D-Slicer/src/Slice.js

32 lines
593 B
JavaScript
Raw Normal View History

2016-04-21 22:14:22 +02:00
import Shape from 'Doodle3D/clipper-js';
2015-07-26 15:32:10 +02:00
export default class {
2017-05-13 14:48:48 +02:00
constructor() {
this.parts = [];
}
getOutline() {
const outLines = new Shape([], true);
2015-06-12 15:58:26 +02:00
2017-05-13 14:48:48 +02:00
for (let i = 0; i < this.parts.length; i ++) {
const part = this.parts[i];
2015-06-11 14:34:30 +02:00
2017-05-13 14:48:48 +02:00
if (part.shape.closed) {
outLines.join(this.parts[i].outerLine);
}
}
2015-06-11 14:34:30 +02:00
2017-05-13 14:48:48 +02:00
return outLines;
}
add(shape) {
const part = { shape };
2015-07-10 18:04:10 +02:00
2017-05-13 14:48:48 +02:00
if (shape.closed) {
part.innerLines = [];
part.outerLine = new Shape([], true);
part.fill = new Shape([], false);
}
2015-06-11 14:34:30 +02:00
2017-05-13 14:48:48 +02:00
this.parts.push(part);
}
2016-04-21 22:14:22 +02:00
}