Merge remote-tracking branch 'origin/feature/split-settings' into develop

# Conflicts:
#	example/save.js
#	example/viewer.js
#	jspm.config.js
#	package.json
#	src/GCode.js
#	src/Slicer.js
#	src/index.js
#	src/sliceActions/addBrim.js
#	src/sliceActions/calculateLayersIntersections.js
#	src/sliceActions/createLines.js
#	src/sliceActions/detectOpenClosed.js
#	src/sliceActions/generateInfills.js
#	src/sliceActions/generateInnerLines.js
#	src/sliceActions/generateSupport.js
#	src/sliceActions/intersectionsToShapes.js
#	src/sliceActions/removePrecision.js
#	src/sliceActions/slice.js
This commit is contained in:
casperlamboo 2017-07-18 11:26:11 +02:00
commit 622be82706
22 changed files with 187067 additions and 135 deletions

View File

@ -1,11 +1,17 @@
import 'three.js';
import { Settings, printerSettings, userSettings, Slicer } from 'src/index.js';
import { Settings, defaultSettings, Slicer } from 'src/index.js';
import { saveAs } from 'file-saver';
const settings = new Settings({
...printerSettings['ultimaker2go'],
...userSettings
});
console.log('defaultSettings: ', defaultSettings);
const settings = {
...defaultSettings.base,
...defaultSettings.material.pla,
...defaultSettings.printer.ultimaker2go,
...defaultSettings.quality.high,
startCode: '',
endCode: ''
};
const jsonLoader = new THREE.JSONLoader();
jsonLoader.load('models/airplane.json', async geometry => {

55582
example/stl/Airplane.stl Normal file

File diff suppressed because it is too large Load Diff

94222
example/stl/Rocket.stl Normal file

File diff suppressed because it is too large Load Diff

BIN
example/stl/castle.stl Normal file

Binary file not shown.

36906
example/stl/traktor.stl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -139,7 +139,8 @@ SystemJS.config({
}
},
map: {
"babel": "npm:babel-core@5.8.38"
"babel": "npm:babel-core@5.8.38",
"three.js/loaders/STLLoader": "github:mrdoob/three.js@r83/examples/js/loaders/STLLoader.js"
}
});
@ -150,27 +151,29 @@ SystemJS.config({
"github:*/*.json"
],
map: {
"text": "github:systemjs/plugin-text@0.0.11",
"js-yaml": "npm:js-yaml@3.9.0",
"clipper-js": "github:Doodle3D/clipper-js@1.0.2",
"three.js": "github:mrdoob/three.js@r83",
"assert": "npm:jspm-nodelibs-assert@0.2.0",
"buffer": "npm:jspm-nodelibs-buffer@0.2.0",
"buffer": "github:jspm/nodelibs-buffer@0.2.0-alpha",
"child_process": "npm:jspm-nodelibs-child_process@0.2.0",
"constants": "npm:jspm-nodelibs-constants@0.2.0",
"crypto": "npm:jspm-nodelibs-crypto@0.2.0",
"events": "npm:jspm-nodelibs-events@0.2.0",
"fs": "npm:jspm-nodelibs-fs@0.2.0",
"fs": "github:jspm/nodelibs-fs@0.2.0-alpha",
"http": "npm:jspm-nodelibs-http@0.2.0",
"json": "github:systemjs/plugin-json@0.1.2",
"Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master",
"module": "npm:jspm-nodelibs-module@0.2.0",
"os": "npm:jspm-nodelibs-os@0.2.0",
"path": "npm:jspm-nodelibs-path@0.2.0",
"process": "npm:jspm-nodelibs-process@0.2.0",
"path": "github:jspm/nodelibs-path@0.2.3",
"process": "github:jspm/nodelibs-process@0.2.0-alpha",
"stream": "npm:jspm-nodelibs-stream@0.2.0",
"string_decoder": "npm:jspm-nodelibs-string_decoder@0.2.0",
"tty": "npm:jspm-nodelibs-tty@0.2.0",
"url": "npm:jspm-nodelibs-url@0.2.0",
"util": "npm:jspm-nodelibs-util@0.2.0",
"util": "github:jspm/nodelibs-util@0.2.0-alpha",
"vm": "npm:jspm-nodelibs-vm@0.2.0",
"worker": "github:casperlamboo/plugin-worker@master"
},
@ -388,11 +391,6 @@ SystemJS.config({
"os-browserify": "npm:os-browserify@0.2.1"
}
},
"npm:jspm-nodelibs-buffer@0.2.0": {
"map": {
"buffer-browserify": "npm:buffer@4.9.1"
}
},
"npm:jspm-nodelibs-stream@0.2.0": {
"map": {
"stream-browserify": "npm:stream-browserify@2.0.1"
@ -410,7 +408,24 @@ SystemJS.config({
},
"github:Doodle3D/clipper-js@1.0.2": {
"map": {
"Breush/clipper-lib": "github:Breush/clipper-lib@patch-1"
"Breush/clipper-lib": "github:Breush/clipper-lib@patch-1",
"clipper-lib": "npm:clipper-lib@6.2.1"
}
},
"npm:js-yaml@3.9.0": {
"map": {
"argparse": "npm:argparse@1.0.9",
"esprima": "npm:esprima@4.0.0"
}
},
"npm:argparse@1.0.9": {
"map": {
"sprintf-js": "npm:sprintf-js@1.0.3"
}
},
"github:jspm/nodelibs-buffer@0.2.0-alpha": {
"map": {
"buffer-browserify": "npm:buffer@4.9.1"
}
}
}

View File

@ -8,7 +8,9 @@
"dependencies": {
"Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master",
"clipper-js": "github:Doodle3D/clipper-js@1.0.2",
"js-yaml": "npm:js-yaml@^3.9.0",
"json": "github:systemjs/plugin-json@^0.1.2",
"text": "github:systemjs/plugin-text@^0.0.11",
"three.js": "github:mrdoob/three.js@r83",
"worker": "github:casperlamboo/plugin-worker@master"
},
@ -26,22 +28,22 @@
},
"peerDependencies": {
"assert": "npm:jspm-nodelibs-assert@^0.2.0",
"buffer": "npm:jspm-nodelibs-buffer@^0.2.0",
"buffer": "github:jspm/nodelibs-buffer@^0.2.0-alpha",
"child_process": "npm:jspm-nodelibs-child_process@^0.2.0",
"constants": "npm:jspm-nodelibs-constants@^0.2.0",
"crypto": "npm:jspm-nodelibs-crypto@^0.2.0",
"events": "npm:jspm-nodelibs-events@^0.2.0",
"fs": "npm:jspm-nodelibs-fs@^0.2.0",
"fs": "github:jspm/nodelibs-fs@^0.2.0-alpha",
"http": "npm:jspm-nodelibs-http@^0.2.0",
"module": "npm:jspm-nodelibs-module@^0.2.0",
"os": "npm:jspm-nodelibs-os@^0.2.0",
"path": "npm:jspm-nodelibs-path@^0.2.0",
"process": "npm:jspm-nodelibs-process@^0.2.0",
"path": "github:jspm/nodelibs-path@^0.2.0-alpha",
"process": "github:jspm/nodelibs-process@^0.2.0-alpha",
"stream": "npm:jspm-nodelibs-stream@^0.2.0",
"string_decoder": "npm:jspm-nodelibs-string_decoder@^0.2.0",
"tty": "npm:jspm-nodelibs-tty@^0.2.0",
"url": "npm:jspm-nodelibs-url@^0.2.0",
"util": "npm:jspm-nodelibs-util@^0.2.0",
"util": "github:jspm/nodelibs-util@^0.2.0-alpha",
"vm": "npm:jspm-nodelibs-vm@^0.2.0"
},
"overrides": {
@ -77,7 +79,9 @@
}
}
},
"dependencies": {},
"dependencies": {
"js-yaml": "^3.9.0"
},
"devDependencies": {
"jspm": "^0.17.0-beta.28"
}

View File

@ -125,9 +125,11 @@ export default class {
unRetract() {
const {
retractionEnabled,
retractionMinDistance,
retractionSpeed
retraction: {
enabled: retractionEnabled,
minDistance: retractionMinDistance,
speed: retractionSpeed
}
} = this._settings.config;
if (this._isRetracted && retractionEnabled) {
@ -149,10 +151,12 @@ export default class {
retract() {
const {
retractionAmount,
retractionEnabled,
retractionMinDistance,
retractionSpeed
retraction: {
amount: retractionAmount,
enabled: retractionEnabled,
minDistance: retractionMinDistance,
speed: retractionSpeed
}
} = this._settings.config;
if (!this._isRetracted && retractionEnabled) {

View File

@ -1,4 +1,5 @@
import * as THREE from 'three.js';
import Settings from './Settings.js';
import slice from './sliceActions/slice.js';
import SlicerWorker from './slicerWorker.js!worker';
@ -28,13 +29,13 @@ export default class {
return this;
}
sliceSync(settings) {
return slice(this.geometry, settings);
return slice(this.geometry, new Settings(settings));
}
slice(settings) {
const slicerWorker = new SlicerWorker();
const geometry = this.geometry.toJSON();
const { config } = settings;
const { config } = new Settings(settings);
return new Promise((resolve, reject) => {
slicerWorker.onerror = reject;
@ -47,6 +48,11 @@ export default class {
resolve(data.gcode);
break;
}
case 'PROGRESS': {
if (this.onprogress) {
this.onprogress(data);
}
}
}
});

View File

@ -1,6 +1,18 @@
import Slicer from './Slicer.js';
import Settings from './Settings.js';
import printerSettings from './settings/printer_settings.json!json';
import userSettings from './settings/user_settings.json!json';
import baseSettings from './settings/default.yml!text';
import printerSettings from './settings/printer.yml!text';
import materialSettings from './settings/material.yml!text';
import qualitySettings from './settings/quality.yml!text';
import yaml from 'js-yaml';
export { Slicer, Settings, printerSettings, userSettings };
const defaultSettings = {
base: yaml.safeLoad(baseSettings),
printer: yaml.safeLoad(printerSettings),
material: yaml.safeLoad(materialSettings),
quality: yaml.safeLoad(qualitySettings)
};
export {
Slicer,
defaultSettings
};

51
src/settings/default.yml Normal file
View File

@ -0,0 +1,51 @@
dimensions:
x: 200
y: 200
z: 200
temperature: 210
bedTemperature: 70
# heatBedTemperature: 20
# heatTemperature: 20
# heatupEnabled: true
travelSpeed: 200.0
layerHeight: 0.15
heatedBed: false
nozzleDiameter: 0.4
filamentThickness: 2.85
retraction:
amount: 3.0
enabled: true
speed: 50.0
minDistance: 0.0
support:
acceptanceMargin: 1.5
distanceY: 0.4
enabled: false
gridSize: 6.0
margin: 2.0
plateSize: 4.0
flowRate: 0.8
speed: 40.0
outerLine:
flowRate: 1.0
speed: 40.0
innerLine:
flowRate: 1.0
speed: 50.0
fill:
flowRate: 1.0
speed: 50.0
overlap: 0.0
gridSize: 5.0
brim:
flowRate: 1.0
speed: 40.0
offset: 4.0
top:
thickness: 1.2
bottom:
flowRate: 1.2
speed: 40.0
thickness: 0.4
shell:
thickness: 0.4

View File

@ -0,0 +1,6 @@
pla:
title: PLA
temperature: 210
abs:
title: ABS
temperature: 240

171
src/settings/printer.yml Normal file
View File

@ -0,0 +1,171 @@
_3Dison_plus:
title: 3Dison plus
dimensions:
x: 227
y: 147
z: 150
bigbuilder3d:
title: Big Builder 3D
builder3d:
title: Builder 3D
bukobot:
title: Bukobot
cartesio:
title: Cartesio
colido_2_0_plus:
title: ColiDo 2.0 Plus
heatedBed: true
dimensions:
x: 230
y: 150
z: 140
colido_compact:
title: ColiDo Compact
dimensions:
x: 130
y: 130
z: 115
colido_diy:
title: ColiDo DIY
dimensions:
z: 170
colido_m2020:
title: ColiDo M2020
heatedBed: true
colido_x3045:
title: ColiDo X3045
heatedBed: true
dimensions:
x: 300
y: 300
z: 450
craftbot_plus:
title: CraftBot PLUS
heatedBed: true
filamentThickness: 1.75
dimensions:
x: 250
cyrus:
title: Cyrus
delta_rostockmax:
title: Delta RostockMax
dimensions:
x: 0
y: 0
deltamaker:
title: Deltamaker
dimensions:
x: 0
y: 0
doodle_dream:
title: Doodle Dream
filamentThickness: 1.75
dimensions:
x: 120
y: 120
z: 80
eventorbot:
title: EventorBot
felix:
title: Felix
gigabot:
title: Gigabot
kossel:
title: Kossel
dimensions:
x: 0
y: 0
leapfrog_creatr:
title: LeapFrog Creatr
lulzbot_aO_101:
title: LulzBot AO-101
lulzbot_taz_4:
title: LulzBot TAZ 4
dimensions:
x: 298
y: 275
z: 250
heatedBed: true
makerbot_generic:
title: Generic Makerbot Printer
makerbot_replicator2:
title: MakerBot Replicator2
makerbot_replicator2x:
title: MakerBot Replicator2x
heatedBed: true
makerbot_thingomatic:
title: MakerBot Thing-o-matic
makergear_m2:
title: MakerGear M2
makergear_prusa:
title: MakerGear Prusa
makibox:
title: Makibox
mamba3d:
title: Mamba3D
marlin_generic:
title: Generic Marlin Printer
minifactory:
title: miniFactory
dimensions:
x: 150
y: 150
z: 155
heatedBed: true
orca_0_3:
title: Orca 0.3
ord_bot_hadron:
title: ORD Bot Hadron
printrbot:
title: Printrbot
printxel_3d:
title: Printxel 3D
prusa_i3:
title: Prusa I3
prusa_iteration_2:
title: Prusa Iteration 2
rapman:
title: RapMan
renkforce_rf100:
title: Renkforce RF100
filamentThickness: 1.75
dimensions:
x: 100
y: 100
z: 100
reprappro_huxley:
title: RepRapPro Huxley
reprappro_mendel:
title: RepRapPro Mendel
rigidbot:
title: Rigidbot
robo_3d_printer:
title: RoBo 3D Printer
shapercube:
title: ShaperCube
tantillus:
title: Tantillus
ultimaker:
title: Ultimaker Original
ultimaker2:
title: Ultimaker 2
heatedBed: true
ultimaker2go:
title: Ultimaker 2 Go
dimensions:
x: 120
y: 120
z: 112
ultimaker_original_plus:
title: Ultimaker Original Plus
heatedBed: true
vision_3d_printer:
title: Vision 3D Printer
wanhao_duplicator4:
title: Wanhao Duplicator 4
filamentThickness: 1.75
heatedBed: true
dimensions:
x: 210
y: 140
z: 140

View File

@ -1,38 +0,0 @@
{
"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"
}
}

11
src/settings/quality.yml Normal file
View File

@ -0,0 +1,11 @@
low:
title: "Low"
layerHeight: .2
fill:
gridSize: 15.0
medium:
title: "Medium"
layerHeight: .15
high:
title: "High"
layerHeight: .1

View File

@ -1,48 +0,0 @@
{
"temperature": 210.0,
"bedTemperature": 70,
"heatBedTemperature": 20,
"heatTemperature": 20,
"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,7 +10,7 @@ const offsetOptions = {
export default function addBrim(slices, settings) {
console.log('add brim');
let { brimOffset } = settings.config;
let { brim: { offset: brimOffset } } = settings.config;
brimOffset /= PRECISION;
const [firstLayer] = slices;

View File

@ -3,7 +3,7 @@ import * as THREE from 'three.js';
export default function calculateLayersIntersections(lines, settings) {
console.log('calculating layer intersections');
const { layerHeight, dimensionsZ } = settings.config;
const { layerHeight, dimensions: { z: dimensionsZ } } = settings.config;
const numLayers = Math.floor(dimensionsZ / layerHeight);

View File

@ -7,11 +7,11 @@ export default function generateInfills(slices, settings) {
let {
layerHeight,
fillGridSize,
bottomThickness,
topThickness,
fill: { gridSize: fillGridSize },
bottom: { thickness: bottomThickness },
top: { thickness: topThickness },
nozzleDiameter,
infillOverlap
fill: { overlap: infillOverlap }
} = settings.config;
fillGridSize /= PRECISION;

View File

@ -11,7 +11,7 @@ export default function generateInnerLines(slices, settings) {
console.log('generating outer lines and inner lines');
// need to scale up everything because of clipper rounding errors
let { layerHeight, nozzleDiameter, shellThickness } = settings.config;
let { layerHeight, nozzleDiameter, shell: { thickness: shellThickness } } = settings.config;
nozzleDiameter /= PRECISION;
shellThickness /= PRECISION;
const nozzleRadius = nozzleDiameter / 2;

View File

@ -5,14 +5,16 @@ import { PRECISION } from '../constants.js';
export default function generateSupport(slices, settings) {
console.log('generating support');
if (!settings.config.supportEnabled) return;
if (!settings.config.support.enabled) return;
let {
layerHeight,
supportGridSize,
supportAcceptanceMargin,
supportPlateSize: plateSize,
supportDistanceY,
support: {
gridSize: supportGridSize,
margin: AcceptanceMargin,
plateSize: plateSize,
distanceY: DistanceY
},
nozzleDiameter
} = settings.config;

View File

@ -12,32 +12,52 @@ import detectOpenClosed from './detectOpenClosed.js';
import applyPrecision from './applyPrecision.js';
import removePrecision from './removePrecision.js';
export default function(geometry, settings) {
export default function(geometry, settings, onProgress) {
const totalStages = 12;
let current = 0;
const progressMessage = () => {
current ++;
postMessage({ message: 'PROGRESS', data: { done: current, total: totalStages } });
};
geometry.computeFaceNormals();
// get unique lines from geometry;
const lines = createLines(geometry, settings);
progressMessage();
const openClosed = detectOpenClosed(lines);
progressMessage();
const {
layerIntersectionIndexes,
layerIntersectionPoints
} = calculateLayersIntersections(lines, settings);
progressMessage();
const shapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
progressMessage();
applyPrecision(shapes);
const slices = shapesToSlices(shapes, settings);
progressMessage();
generateInnerLines(slices, settings);
progressMessage();
generateInfills(slices, settings);
progressMessage();
generateSupport(slices, settings);
progressMessage();
addBrim(slices, settings);
progressMessage();
optimizePaths(slices, settings);
progressMessage();
removePrecision(slices);
progressMessage();
const gcode = slicesToGCode(slices, settings);
progressMessage();
return gcode;
}