mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 19:43:48 +01:00
cleanup slices to geode
This commit is contained in:
parent
ebbe75ef2e
commit
9e4109a3f8
@ -1,39 +1,37 @@
|
|||||||
import GCode from '../gcode.js';
|
import GCode from '../gcode.js';
|
||||||
|
|
||||||
export default function slicesToGCode(slices, settings) {
|
function pathToGCode(gcode, shape, retract, unRetract, layer, type) {
|
||||||
var gcode = new GCode().setSettings(settings);
|
for (let i = 0; i < shape.paths.length; i ++) {
|
||||||
|
const line = shape.paths[i];
|
||||||
|
|
||||||
function pathToGCode (shape, retract, unRetract, type) {
|
const length = shape.closed ? (line.length + 1) : line.length;
|
||||||
for (var i = 0; i < shape.paths.length; i ++) {
|
for (let i = 0; i < length; i ++) {
|
||||||
var line = shape.paths[i];
|
const point = line[i % line.length];
|
||||||
|
|
||||||
var length = shape.closed ? (line.length + 1) : line.length;
|
if (i === 0) {
|
||||||
|
// TODO
|
||||||
|
// moveTo should impliment combing
|
||||||
|
gcode.moveTo(point.X, point.Y, layer);
|
||||||
|
|
||||||
for (var j = 0; j < length; j ++) {
|
if (unRetract) {
|
||||||
var point = line[j % line.length];
|
gcode.unRetract();
|
||||||
|
|
||||||
if (j === 0) {
|
|
||||||
// TODO
|
|
||||||
// moveTo should impliment combing
|
|
||||||
gcode.moveTo(point.X, point.Y, layer);
|
|
||||||
|
|
||||||
if (unRetract) {
|
|
||||||
gcode.unRetract();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gcode.lineTo(point.X, point.Y, layer, type);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
gcode.lineTo(point.X, point.Y, layer, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retract) {
|
|
||||||
gcode.retract();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var layer = 0; layer < slices.length; layer ++) {
|
if (retract) {
|
||||||
var slice = slices[layer];
|
gcode.retract();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function slicesToGCode(slices, settings) {
|
||||||
|
const gcode = new GCode().setSettings(settings);
|
||||||
|
|
||||||
|
for (let layer = 0; layer < slices.length; layer ++) {
|
||||||
|
const slice = slices[layer];
|
||||||
|
|
||||||
if (layer === 1) {
|
if (layer === 1) {
|
||||||
gcode.turnFanOn();
|
gcode.turnFanOn();
|
||||||
@ -41,30 +39,29 @@ export default function slicesToGCode(slices, settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (slice.brim !== undefined) {
|
if (slice.brim !== undefined) {
|
||||||
pathToGCode(slice.brim, true, true, "brim");
|
pathToGCode(gcode, slice.brim, true, true, layer, 'brim');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < slice.parts.length; i ++) {
|
for (let i = 0; i < slice.parts.length; i ++) {
|
||||||
var part = slice.parts[i];
|
const part = slice.parts[i];
|
||||||
|
|
||||||
if (part.shape.closed) {
|
if (part.shape.closed) {
|
||||||
pathToGCode(part.outerLine, false, true, "outerLine");
|
pathToGCode(gcode, part.outerLine, false, true, layer, 'outerLine');
|
||||||
|
|
||||||
for (var j = 0; j < part.innerLines.length; j ++) {
|
for (let i = 0; i < part.innerLines.length; i ++) {
|
||||||
var innerLine = part.innerLines[j];
|
const innerLine = part.innerLines[i];
|
||||||
pathToGCode(innerLine, false, false, "innerLine");
|
pathToGCode(gcode, innerLine, false, false, layer, 'innerLine');
|
||||||
}
|
}
|
||||||
|
|
||||||
pathToGCode(part.fill, true, false, "fill");
|
pathToGCode(gcode, part.fill, true, false, layer, 'fill');
|
||||||
}
|
} else {
|
||||||
else {
|
const retract = !(slice.parts.length === 1 && slice.support === undefined);
|
||||||
var retract = !(slice.parts.length === 1 && slice.support === undefined);
|
pathToGCode(gcode, part.shape, retract, retract, layer, 'outerLine');
|
||||||
pathToGCode(part.shape, retract, retract, "outerLine");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slice.support !== undefined) {
|
if (slice.support !== undefined) {
|
||||||
pathToGCode(slice.support, true, true, "support");
|
pathToGCode(gcode, slice.support, true, true, layer, 'support');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user