replace tabs with spaces

This commit is contained in:
casperlamboo 2017-05-13 14:48:48 +02:00 committed by Simon Voordouw
parent 9210504ea4
commit d8e95e3e76
13 changed files with 478 additions and 478 deletions

View File

@ -7,8 +7,8 @@ import THREE from 'three.js';
import * as SLICER from 'doodle3d-slicer';
const settings = new SLICER.Settings({
...SLICER.printerSettings['ultimaker2go'],
...SLICER.userSettings
...SLICER.printerSettings['ultimaker2go'],
...SLICER.userSettings
});
const geometry = new THREE.TorusGeometry(20, 10, 30, 30);
@ -17,6 +17,6 @@ const slicer = new SLICER.Slicer();
slicer.setGeometry(geometry);
slicer.slice(settings, false).then(gcode => {
document.getElementById('gcode').innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
document.getElementById('gcode').innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
});
```

View File

@ -1,45 +1,45 @@
import React from 'react';
export default class SlicerViewer extends React.Component {
state = {
slice: 0
};
state = {
slice: 0
};
changeSlider = (event) => {
this.setState({
...this.state,
slice: parseInt(event.target.value)
});
};
changeSlider = (event) => {
this.setState({
...this.state,
slice: parseInt(event.target.value)
});
};
render() {
const { slice } = this.state;
const { layerIntersectionPoints, settings, layerShapes } = this.props;
render() {
const { slice } = this.state;
const { layerIntersectionPoints, settings, layerShapes } = this.props;
const numLayers = settings.dimensionsZ / settings.layerHeight;
const numLayers = settings.dimensionsZ / settings.layerHeight;
const intersectionPoints = layerIntersectionPoints[slice + 1];
const shape = layerShapes[slice];
const intersectionPoints = layerIntersectionPoints[slice + 1];
const shape = layerShapes[slice];
return (
<div>
<svg viewBox={`-20 -20 ${settings.dimensionsX + 40} ${settings.dimensionsX + 40}`}>
<rect
width={settings.dimensionsX}
height={settings.dimensionsY}
fill="lightGrey"
/>
{intersectionPoints.map(({ x, y }, i) => <circle key={i} cx={x} cy={y} r="0.3"/>)}
{shape && shape.closedShapes.map((closedShape, i) => (
<polygon
key={i}
points={closedShape.map(({ x, y }) => `${x} ${y}`).join(' ')}
fill="rgba(255, 0, 0, 0.5)"
/>
))}
</svg>
<input onChange={this.changeSlider} value={slice} type="range" min="0" max={numLayers} />
</div>
);
}
return (
<div>
<svg viewBox={`-20 -20 ${settings.dimensionsX + 40} ${settings.dimensionsX + 40}`}>
<rect
width={settings.dimensionsX}
height={settings.dimensionsY}
fill="lightGrey"
/>
{intersectionPoints.map(({ x, y }, i) => <circle key={i} cx={x} cy={y} r="0.3"/>)}
{shape && shape.closedShapes.map((closedShape, i) => (
<polygon
key={i}
points={closedShape.map(({ x, y }) => `${x} ${y}`).join(' ')}
fill="rgba(255, 0, 0, 0.5)"
/>
))}
</svg>
<input onChange={this.changeSlider} value={slice} type="range" min="0" max={numLayers} />
</div>
);
}
}

View File

@ -7,27 +7,27 @@ import generateRawData from './generateRawData.js';
import SlicerViewer from './SlicerViewer.js';
const settings = new SLICER.Settings({
...SLICER.printerSettings['ultimaker2go'],
...SLICER.userSettings
...SLICER.printerSettings['ultimaker2go'],
...SLICER.userSettings
});
const stlLoader = new THREE.STLLoader();
stlLoader.load('stl/Airplane.stl', (geometry) => {
geometry.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI / -2));
geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(50, -0.1, 50)));
// geometry.applyMatrix(new THREE.Matrix4().scale(0.8));
geometry.mergeVertices();
geometry.computeFaceNormals();
geometry.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI / -2));
geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(50, -0.1, 50)));
// geometry.applyMatrix(new THREE.Matrix4().scale(0.8));
geometry.mergeVertices();
geometry.computeFaceNormals();
const rawData = generateRawData(geometry, settings);
const rawData = generateRawData(geometry, settings);
render(<SlicerViewer
layerIntersectionPoints={rawData.layerIntersectionPoints}
layerShapes={rawData.layerShapes}
slices={rawData.slices}
settings={settings.config}
/>, document.getElementById('container'));
render(<SlicerViewer
layerIntersectionPoints={rawData.layerIntersectionPoints}
layerShapes={rawData.layerShapes}
slices={rawData.slices}
settings={settings.config}
/>, document.getElementById('container'));
});
// const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
@ -38,8 +38,8 @@ stlLoader.load('stl/Airplane.stl', (geometry) => {
// const rawData = generateRawData(geometry, settings);
//
// render(<SlicerViewer
// layerIntersectionPoints={rawData.layerIntersectionPoints}
// layerShapes={rawData.layerShapes}
// slices={rawData.slices}
// settings={settings.config}
// layerIntersectionPoints={rawData.layerIntersectionPoints}
// layerShapes={rawData.layerShapes}
// slices={rawData.slices}
// settings={settings.config}
// />, document.getElementById('container'));

View File

@ -12,43 +12,43 @@ import applyPrecision from 'src/sliceActions/applyPrecision.js';
import removePrecision from 'src/sliceActions/removePrecision.js';
export default function generateRawData(geometry, settings) {
const rawData = {};
const rawData = {};
const lines = createLines(geometry, settings);
const lines = createLines(geometry, settings);
const {
layerIntersectionIndexes,
layerIntersectionPoints
} = calculateLayersIntersections(lines, settings);
const {
layerIntersectionIndexes,
layerIntersectionPoints
} = calculateLayersIntersections(lines, settings);
rawData.layerIntersectionPoints = layerIntersectionPoints
.map(intersectionPoints => intersectionPoints.map(intersectionPoint => intersectionPoint.clone()));
rawData.layerIntersectionPoints = layerIntersectionPoints
.map(intersectionPoints => intersectionPoints.map(intersectionPoint => intersectionPoint.clone()));
const layerShapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
const layerShapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
rawData.layerShapes = layerShapes
.map(({ closedShapes, openShapes }) => ({
closedShapes: closedShapes.map(closedShape => closedShape.map(vector => vector.clone())),
openShapes: openShapes.map(openShape => openShape.map(vector => vector.clone()))
}));
rawData.layerShapes = layerShapes
.map(({ closedShapes, openShapes }) => ({
closedShapes: closedShapes.map(closedShape => closedShape.map(vector => vector.clone())),
openShapes: openShapes.map(openShape => openShape.map(vector => vector.clone()))
}));
applyPrecision(layerShapes);
applyPrecision(layerShapes);
const slices = shapesToSlices(layerShapes, settings);
const slices = shapesToSlices(layerShapes, settings);
generateInnerLines(slices, settings);
generateInfills(slices, settings);
generateSupport(slices, settings);
addBrim(slices, settings);
optimizePaths(slices, settings);
removePrecision(slices);
generateInnerLines(slices, settings);
generateInfills(slices, settings);
generateSupport(slices, settings);
addBrim(slices, settings);
optimizePaths(slices, settings);
removePrecision(slices);
rawData.slices = slices;
rawData.slices = slices;
const gcode = slicesToGCode(slices, settings);
const gcode = slicesToGCode(slices, settings);
rawData.gcode = gcode;
rawData.gcode = gcode;
return rawData;
return rawData;
}

View File

@ -1,29 +1,29 @@
<!DOCTYPE>
<html>
<head>
<head>
<title>Doodle3D Slicer</title>
<title>Doodle3D Slicer</title>
<style>
#gcode {
font-family: monospace;
}
</style>
<style>
#gcode {
font-family: monospace;
}
</style>
<script type="text/javascript" src="../jspm_packages/system.js"></script>
<script type="text/javascript" src="../jspm.config.js"></script>
<script type="text/javascript" src="../jspm_packages/system.js"></script>
<script type="text/javascript" src="../jspm.config.js"></script>
<link href="main.css" rel="stylesheet"/>
<link href="main.css" rel="stylesheet"/>
<script type="text/javascript">
System.import('example/app.js');
</script>
<script type="text/javascript">
System.import('example/app.js');
</script>
</head>
</head>
<body>
<body>
<div id="container"></div>
<div id="container"></div>
</body>
</body>
</html>

View File

@ -1,21 +1,21 @@
* {
margin: 0;
padding: 0;
margin: 0;
padding: 0;
}
#container {
position: relative;
position: relative;
}
#container, svg {
width: 100%;
height: 100%;
width: 100%;
height: 100%;
}
svg, input {
position: absolute;
position: absolute;
}
input {
width: 100%;
width: 100%;
}

View File

@ -10,178 +10,178 @@ const POSITION_Y = 'Y';
const POSITION_Z = 'Z';
export default class {
constructor(settings) {
this.gcode = '';
this.current = {};
constructor(settings) {
this.gcode = '';
this.current = {};
this.extruder = 0.0;
this.bottom = true;
this.isRetracted = false;
this.isFanOn = false;
this._nozzlePosition = new THREE.Vector2(0, 0);
this.extruder = 0.0;
this.bottom = true;
this.isRetracted = false;
this.isFanOn = false;
this._nozzlePosition = new THREE.Vector2(0, 0);
if (settings !== undefined) {
this.setSettings(settings);
}
}
if (settings !== undefined) {
this.setSettings(settings);
}
}
_addGCode(command) {
let str = '';
let first = true;
_addGCode(command) {
let str = '';
let first = true;
for (const action in command) {
const value = command[action];
const currentValue = this.current[action];
if (first) {
str = action + value;
for (const action in command) {
const value = command[action];
const currentValue = this.current[action];
if (first) {
str = action + value;
first = false;
} else if (currentValue !== value) {
str += ` ${action}${value}`;
first = false;
} else if (currentValue !== value) {
str += ` ${action}${value}`;
this.current[action] = value;
}
}
this.current[action] = value;
}
}
this.gcode += `${str}\n`;
}
this.gcode += `${str}\n`;
}
setSettings(settings) {
this.settings = settings;
setSettings(settings) {
this.settings = settings;
return this;
}
return this;
}
turnFanOn(fanSpeed) {
this.isFanOn = true;
turnFanOn(fanSpeed) {
this.isFanOn = true;
const gcode = { [M_COMMAND]: 106 }
if (fanSpeed !== undefined) gcode[FAN_SPEED] = fanSpeed;
const gcode = { [M_COMMAND]: 106 }
if (fanSpeed !== undefined) gcode[FAN_SPEED] = fanSpeed;
this._addGCode(gcode);
this._addGCode(gcode);
return this;
}
return this;
}
turnFanOff() {
this.isFanOn = false;
turnFanOff() {
this.isFanOn = false;
this._addGCode({ [M_COMMAND]: 107 });
this._addGCode({ [M_COMMAND]: 107 });
return this;
}
return this;
}
moveTo(x, y, layer) {
const {
layerHeight,
travelSpeed
} = this.settings.config;
moveTo(x, y, layer) {
const {
layerHeight,
travelSpeed
} = this.settings.config;
const z = (layer + 1) * layerHeight;
const speed = travelSpeed * 60;
const z = (layer + 1) * layerHeight;
const speed = travelSpeed * 60;
this._addGCode({
[G_COMMAND]: 0,
[POSITION_X]: x.toFixed(3),
[POSITION_Y]: y.toFixed(3),
[POSITION_Z]: z.toFixed(3),
[SPEED]: speed.toFixed(3)
});
this._addGCode({
[G_COMMAND]: 0,
[POSITION_X]: x.toFixed(3),
[POSITION_Y]: y.toFixed(3),
[POSITION_Z]: z.toFixed(3),
[SPEED]: speed.toFixed(3)
});
this._nozzlePosition.set(x, y);
this._nozzlePosition.set(x, y);
return this;
}
return this;
}
lineTo(x, y, layer, type) {
const newNozzlePosition = new THREE.Vector2(x, y);
lineTo(x, y, layer, type) {
const newNozzlePosition = new THREE.Vector2(x, y);
const {
layerHeight,
nozzleDiameter,
filamentThickness,
travelSpeed
} = this.settings.config;
const {
layerHeight,
nozzleDiameter,
filamentThickness,
travelSpeed
} = this.settings.config;
const profile = this.settings.config[(this.bottom ? 'bottom' : type)];
const profile = this.settings.config[(this.bottom ? 'bottom' : type)];
let {
speed,
flowRate
} = profile;
let {
speed,
flowRate
} = profile;
speed *= 60;
const z = (layer + 1) * layerHeight;
speed *= 60;
const z = (layer + 1) * layerHeight;
const lineLength = this._nozzlePosition.distanceTo(newNozzlePosition);
const lineLength = this._nozzlePosition.distanceTo(newNozzlePosition);
const filamentSurfaceArea = Math.pow((filamentThickness / 2), 2) * Math.PI;
this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate;
const filamentSurfaceArea = Math.pow((filamentThickness / 2), 2) * Math.PI;
this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate;
this._addGCode({
[G_COMMAND]: 1,
[POSITION_X]: x.toFixed(3),
[POSITION_Y]: y.toFixed(3),
[POSITION_Z]: z.toFixed(3),
[SPEED]: speed.toFixed(3),
[EXTRUDER]: this.extruder.toFixed(3)
});
this._addGCode({
[G_COMMAND]: 1,
[POSITION_X]: x.toFixed(3),
[POSITION_Y]: y.toFixed(3),
[POSITION_Z]: z.toFixed(3),
[SPEED]: speed.toFixed(3),
[EXTRUDER]: this.extruder.toFixed(3)
});
this._nozzlePosition.copy(newNozzlePosition);
this._nozzlePosition.copy(newNozzlePosition);
return this;
}
return this;
}
unRetract() {
const {
retractionEnabled,
retractionMinDistance,
retractionSpeed
} = this.settings.config;
unRetract() {
const {
retractionEnabled,
retractionMinDistance,
retractionSpeed
} = this.settings.config;
if (this.isRetracted && retractionEnabled) {
this.isRetracted = false;
if (this.isRetracted && retractionEnabled) {
this.isRetracted = false;
const speed = retractionSpeed * 60;
const speed = retractionSpeed * 60;
if (this.extruder > retractionMinDistance) {
this._addGCode({
[G_COMMAND]: 0,
[EXTRUDER]: this.extruder.toFixed(3),
[SPEED]: speed.toFixed(3)
});
}
}
if (this.extruder > retractionMinDistance) {
this._addGCode({
[G_COMMAND]: 0,
[EXTRUDER]: this.extruder.toFixed(3),
[SPEED]: speed.toFixed(3)
});
}
}
return this;
}
return this;
}
retract() {
const {
retractionAmount,
retractionEnabled,
retractionMinDistance,
retractionSpeed
} = this.settings.config;
retract() {
const {
retractionAmount,
retractionEnabled,
retractionMinDistance,
retractionSpeed
} = this.settings.config;
if (!this.isRetracted && retractionEnabled) {
this.isRetracted = true;
if (!this.isRetracted && retractionEnabled) {
this.isRetracted = true;
const speed = retractionSpeed * 60;
const speed = retractionSpeed * 60;
if (this.extruder > retractionMinDistance && retractionEnabled) {
this._addGCode({
[G_COMMAND]: 0,
[EXTRUDER]: (this.extruder - retractionAmount).toFixed(3),
[SPEED]: speed.toFixed(3)
});
}
}
if (this.extruder > retractionMinDistance && retractionEnabled) {
this._addGCode({
[G_COMMAND]: 0,
[EXTRUDER]: (this.extruder - retractionAmount).toFixed(3),
[SPEED]: speed.toFixed(3)
});
}
}
return this;
}
return this;
}
getGCode() {
return this.settings.startCode() + this.gcode + this.settings.endCode();
}
getGCode() {
return this.settings.startCode() + this.gcode + this.settings.endCode();
}
}

View File

@ -1,53 +1,53 @@
export default class {
constructor(config = {}) {
this.config = config;
}
updateConfig(config) {
this.config = { ...this.config, ...config };
constructor(config = {}) {
this.config = config;
}
updateConfig(config) {
this.config = { ...this.config, ...config };
return this;
}
startCode() {
const { startCode } = this.config;
const gcode = this._subsituteVariables(startCode);
return gcode;
}
endCode() {
const { endCode } = this.config;
const gcode = this._subsituteVariables(endCode);
return gcode;
}
_subsituteVariables(gcode) {
let {
temperature,
bedTemperature,
heatTemperature,
heatBedTemperature,
travelSpeed,
printerType,
heatedbed
} = this.config;
return this;
}
startCode() {
const { startCode } = this.config;
const gcode = this._subsituteVariables(startCode);
return gcode;
}
endCode() {
const { endCode } = this.config;
const gcode = this._subsituteVariables(endCode);
return gcode;
}
_subsituteVariables(gcode) {
let {
temperature,
bedTemperature,
heatTemperature,
heatBedTemperature,
travelSpeed,
printerType,
heatedbed
} = this.config;
travelSpeed *= 60;
travelSpeed *= 60;
switch (printerType) {
case 'makerbot_replicator2': printerType = 'r2'; break;
case 'makerbot_replicator2x': printerType = 'r2x'; break;
case 'makerbot_thingomatic': printerType = 't6'; break;
case 'makerbot_generic': printerType = 'r2'; break;
case '_3Dison_plus': printerType = 'r2'; break;
}
switch (printerType) {
case 'makerbot_replicator2': printerType = 'r2'; break;
case 'makerbot_replicator2x': printerType = 'r2x'; break;
case 'makerbot_thingomatic': printerType = 't6'; break;
case 'makerbot_generic': printerType = 'r2'; break;
case '_3Dison_plus': printerType = 'r2'; break;
}
const heatedBedReplacement = heatedbed ? '' : ';';
const heatedBedReplacement = heatedbed ? '' : ';';
gcode = gcode.replace(/{printingTemp}/gi, temperature);
gcode = gcode.replace(/{printingBedTemp}/gi, bedTemperature);
gcode = gcode.replace(/{preheatTemp}/gi, heatTemperature);
gcode = gcode.replace(/{preheatBedTemp}/gi, heatBedTemperature);
gcode = gcode.replace(/{printerType}/gi, printerType);
gcode = gcode.replace(/{travelSpeed}/gi, travelSpeed);
gcode = gcode.replace(/{if heatedBed}/gi, heatedBedReplacement);
gcode = gcode.replace(/{printingTemp}/gi, temperature);
gcode = gcode.replace(/{printingBedTemp}/gi, bedTemperature);
gcode = gcode.replace(/{preheatTemp}/gi, heatTemperature);
gcode = gcode.replace(/{preheatBedTemp}/gi, heatBedTemperature);
gcode = gcode.replace(/{printerType}/gi, printerType);
gcode = gcode.replace(/{travelSpeed}/gi, travelSpeed);
gcode = gcode.replace(/{if heatedBed}/gi, heatedBedReplacement);
return gcode;
}
return gcode;
}
}

View File

@ -1,31 +1,31 @@
import Shape from 'Doodle3D/clipper-js';
export default class {
constructor() {
this.parts = [];
}
getOutline() {
const outLines = new Shape([], true);
constructor() {
this.parts = [];
}
getOutline() {
const outLines = new Shape([], true);
for (let i = 0; i < this.parts.length; i ++) {
const part = this.parts[i];
for (let i = 0; i < this.parts.length; i ++) {
const part = this.parts[i];
if (part.shape.closed) {
outLines.join(this.parts[i].outerLine);
}
}
if (part.shape.closed) {
outLines.join(this.parts[i].outerLine);
}
}
return outLines;
}
add(shape) {
const part = { shape };
return outLines;
}
add(shape) {
const part = { shape };
if (shape.closed) {
part.innerLines = [];
part.outerLine = new Shape([], true);
part.fill = new Shape([], false);
}
if (shape.closed) {
part.innerLines = [];
part.outerLine = new Shape([], true);
part.fill = new Shape([], false);
}
this.parts.push(part);
}
this.parts.push(part);
}
}

View File

@ -3,60 +3,60 @@ import slice from './sliceActions/slice.js';
import SlicerWorker from './slicerWorker.js!worker';
export default class {
setMesh(mesh) {
mesh.updateMatrix();
setMesh(mesh) {
mesh.updateMatrix();
this.setGeometry(mesh.geometry, mesh.matrix);
this.setGeometry(mesh.geometry, mesh.matrix);
return this;
}
setGeometry(geometry, matrix) {
if (geometry.type === 'BufferGeometry') {
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
} else if (geometry.type === 'Geometry') {
geometry = geometry.clone();
} else {
throw new Error('Geometry is not an instance of BufferGeometry or Geometry');
}
return this;
}
setGeometry(geometry, matrix) {
if (geometry.type === 'BufferGeometry') {
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
} else if (geometry.type === 'Geometry') {
geometry = geometry.clone();
} else {
throw new Error('Geometry is not an instance of BufferGeometry or Geometry');
}
if (matrix) {
geometry.applyMatrix(matrix);
}
if (matrix) {
geometry.applyMatrix(matrix);
}
geometry.mergeVertices();
geometry.computeFaceNormals();
geometry.mergeVertices();
geometry.computeFaceNormals();
this.geometry = geometry;
this.geometry = geometry;
return this;
}
sliceSync(settings) {
return slice(this.geometry, settings);
}
slice(settings) {
const slicerWorker = new SlicerWorker();
return this;
}
sliceSync(settings) {
return slice(this.geometry, settings);
}
slice(settings) {
const slicerWorker = new SlicerWorker();
const geometry = this.geometry.toJSON();
const { config } = settings;
const geometry = this.geometry.toJSON();
const { config } = settings;
return new Promise((resolve, reject) => {
slicerWorker.onerror = reject;
return new Promise((resolve, reject) => {
slicerWorker.onerror = reject;
slicerWorker.addEventListener('message', (event) => {
const { message, data } = event.data;
switch (message) {
case 'SLICE': {
slicerWorker.terminate();
resolve(data.gcode);
break;
}
}
});
slicerWorker.addEventListener('message', (event) => {
const { message, data } = event.data;
switch (message) {
case 'SLICE': {
slicerWorker.terminate();
resolve(data.gcode);
break;
}
}
});
slicerWorker.postMessage({
message: 'SLICE',
data: { geometry, config }
});
});
}
slicerWorker.postMessage({
message: 'SLICE',
data: { geometry, config }
});
});
}
}

View File

@ -1,38 +1,38 @@
{
"ultimaker": {
"dimensionsX": 200,
"dimensionsY": 200,
"dimensionsZ": 200,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": false,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker"
},
"ultimaker2": {
"dimensionsX": 223,
"dimensionsY": 223,
"dimensionsZ": 205,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+5.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": true,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (ultimaker2)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG0 X0 Y0 F{travelSpeed} ;home position is not X0 Y0\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker2"
},
"ultimaker2go": {
"dimensionsX": 120,
"dimensionsY": 120,
"dimensionsZ": 115,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": false,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (ultimaker2go)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG0 X0 Y0 F{travelSpeed} ;home position is not X0 Y0\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker2g0"
}
"ultimaker": {
"dimensionsX": 200,
"dimensionsY": 200,
"dimensionsZ": 200,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": false,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker"
},
"ultimaker2": {
"dimensionsX": 223,
"dimensionsY": 223,
"dimensionsZ": 205,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+5.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": true,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (ultimaker2)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG0 X0 Y0 F{travelSpeed} ;home position is not X0 Y0\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker2"
},
"ultimaker2go": {
"dimensionsX": 120,
"dimensionsY": 120,
"dimensionsZ": 115,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": false,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (ultimaker2go)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG0 X0 Y0 F{travelSpeed} ;home position is not X0 Y0\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker2g0"
}
}

View File

@ -1,47 +1,47 @@
{
"heatupBedTemperature": 70,
"heatupTemperature": 20,
"temperature": 210.0,
"layerHeight": 0.15,
"bottomThickness": 0.4,
"topThickness": 0.8,
"shellThickness": 0.4,
"brimOffset": 4.0,
"fillGridSize": 5.0,
"infillOverlap": 0.0,
"travelSpeed": 200.0,
"retractionAmount": 3.0,
"retractionEnabled": true,
"retractionSpeed": 50.0,
"retractionMinDistance": 0.0,
"supportAcceptanceMargin": 1.5,
"supportDistanceY": 0.4,
"supportEnabled": false,
"supportGridSize": 6.0,
"supportMargin": 2.0,
"supportPlateSize": 4.0,
"outerLine": {
"flowRate": 1.0,
"speed": 40.0
},
"innerLine": {
"flowRate": 1.0,
"speed": 50.0
},
"fill": {
"flowRate": 1.0,
"speed": 50.0
},
"brim": {
"flowRate": 1.0,
"speed": 40.0
},
"support": {
"flowRate": 0.8,
"speed": 40.0
},
"bottom": {
"flowRate": 1.2,
"speed": 40.0
}
"heatupBedTemperature": 70,
"heatupTemperature": 20,
"temperature": 210.0,
"layerHeight": 0.15,
"bottomThickness": 0.4,
"topThickness": 0.8,
"shellThickness": 0.4,
"brimOffset": 4.0,
"fillGridSize": 5.0,
"infillOverlap": 0.0,
"travelSpeed": 200.0,
"retractionAmount": 3.0,
"retractionEnabled": true,
"retractionSpeed": 50.0,
"retractionMinDistance": 0.0,
"supportAcceptanceMargin": 1.5,
"supportDistanceY": 0.4,
"supportEnabled": false,
"supportGridSize": 6.0,
"supportMargin": 2.0,
"supportPlateSize": 4.0,
"outerLine": {
"flowRate": 1.0,
"speed": 40.0
},
"innerLine": {
"flowRate": 1.0,
"speed": 50.0
},
"fill": {
"flowRate": 1.0,
"speed": 50.0
},
"brim": {
"flowRate": 1.0,
"speed": 40.0
},
"support": {
"flowRate": 0.8,
"speed": 40.0
},
"bottom": {
"flowRate": 1.2,
"speed": 40.0
}
}

View File

@ -10,72 +10,72 @@ export default function optimizePaths(slices, settings) {
const slice = slices[layer];
if (slice.brim !== undefined && slice.brim.paths.length > 0) {
slice.brim = optimizeShape(slice.brim, start);
start.copy(slice.brim.lastPoint(true));
slice.brim = optimizeShape(slice.brim, start);
start.copy(slice.brim.lastPoint(true));
}
const parts = [];
while (slice.parts.length > 0) {
let closestDistance = Infinity;
let closestPart;
let closestDistance = Infinity;
let closestPart;
for (let i = 0; i < slice.parts.length; i ++) {
const part = slice.parts[i];
for (let i = 0; i < slice.parts.length; i ++) {
const part = slice.parts[i];
let bounds;
if (part.shape.closed) {
bounds = part.outerLine.shapeBounds();
} else {
bounds = part.shape.shapeBounds();
}
if (part.shape.closed) {
bounds = part.outerLine.shapeBounds();
} else {
bounds = part.shape.shapeBounds();
}
const top = bounds.top - start.y;
const bottom = start.y - bounds.bottom;
const left = bounds.left - start.x;
const right = start.x - bounds.right;
const top = bounds.top - start.y;
const bottom = start.y - bounds.bottom;
const left = bounds.left - start.x;
const right = start.x - bounds.right;
const distance = Math.max(top, bottom, left, right);
const distance = Math.max(top, bottom, left, right);
if (distance < closestDistance) {
closestDistance = distance;
closestPart = i;
}
}
if (distance < closestDistance) {
closestDistance = distance;
closestPart = i;
}
}
const part = slice.parts.splice(closestPart, 1)[0];
parts.push(part);
const part = slice.parts.splice(closestPart, 1)[0];
parts.push(part);
if (part.shape.closed) {
if (part.outerLine.paths.length > 0) {
part.outerLine = optimizeShape(part.outerLine, start);
start.copy(part.outerLine.lastPoint(true));
}
if (part.shape.closed) {
if (part.outerLine.paths.length > 0) {
part.outerLine = optimizeShape(part.outerLine, start);
start.copy(part.outerLine.lastPoint(true));
}
for (let i = 0; i < part.innerLines.length; i ++) {
const innerLine = part.innerLines[i];
for (let i = 0; i < part.innerLines.length; i ++) {
const innerLine = part.innerLines[i];
if (innerLine.paths.length > 0) {
part.innerLines[i] = optimizeShape(innerLine, start);
start.copy(part.innerLines[i].lastPoint(true));
}
}
if (innerLine.paths.length > 0) {
part.innerLines[i] = optimizeShape(innerLine, start);
start.copy(part.innerLines[i].lastPoint(true));
}
}
if (part.fill.paths.length > 0) {
part.fill = optimizeShape(part.fill, start);
start.copy(part.fill.lastPoint(true));
}
} else {
part.shape = optimizeShape(part.shape, start);
start.copy(part.shape.lastPoint(true));
}
if (part.fill.paths.length > 0) {
part.fill = optimizeShape(part.fill, start);
start.copy(part.fill.lastPoint(true));
}
} else {
part.shape = optimizeShape(part.shape, start);
start.copy(part.shape.lastPoint(true));
}
}
slice.parts = parts;
if (slice.support !== undefined && slice.support.length > 0) {
slice.support = optimizeShape(slice.support, start);
start.copy(slice.support.lastPoint(true));
slice.support = optimizeShape(slice.support, start);
start.copy(slice.support.lastPoint(true));
}
}
}