mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2025-01-11 03:45:08 +01:00
fixed clipper alert error
This commit is contained in:
parent
aa71eb5b67
commit
fa38d8117e
10
config.js
10
config.js
@ -15,8 +15,8 @@ System.config({
|
|||||||
|
|
||||||
System.config({
|
System.config({
|
||||||
"map": {
|
"map": {
|
||||||
"babel": "npm:babel-core@5.6.20",
|
"babel": "npm:babel-core@5.8.21",
|
||||||
"babel-runtime": "npm:babel-runtime@5.6.20",
|
"babel-runtime": "npm:babel-runtime@5.8.20",
|
||||||
"clipper-lib": "npm:clipper-lib@1.0.0",
|
"clipper-lib": "npm:clipper-lib@1.0.0",
|
||||||
"core-js": "npm:core-js@0.9.18",
|
"core-js": "npm:core-js@0.9.18",
|
||||||
"json": "github:systemjs/plugin-json@0.1.0",
|
"json": "github:systemjs/plugin-json@0.1.0",
|
||||||
@ -39,7 +39,7 @@ System.config({
|
|||||||
"npm:argparse@1.0.2": {
|
"npm:argparse@1.0.2": {
|
||||||
"assert": "github:jspm/nodelibs-assert@0.1.0",
|
"assert": "github:jspm/nodelibs-assert@0.1.0",
|
||||||
"fs": "github:jspm/nodelibs-fs@0.1.2",
|
"fs": "github:jspm/nodelibs-fs@0.1.2",
|
||||||
"lodash": "npm:lodash@3.10.0",
|
"lodash": "npm:lodash@3.10.1",
|
||||||
"path": "github:jspm/nodelibs-path@0.1.0",
|
"path": "github:jspm/nodelibs-path@0.1.0",
|
||||||
"process": "github:jspm/nodelibs-process@0.1.1",
|
"process": "github:jspm/nodelibs-process@0.1.1",
|
||||||
"sprintf-js": "npm:sprintf-js@1.0.3",
|
"sprintf-js": "npm:sprintf-js@1.0.3",
|
||||||
@ -48,7 +48,7 @@ System.config({
|
|||||||
"npm:assert@1.3.0": {
|
"npm:assert@1.3.0": {
|
||||||
"util": "npm:util@0.10.3"
|
"util": "npm:util@0.10.3"
|
||||||
},
|
},
|
||||||
"npm:babel-runtime@5.6.20": {
|
"npm:babel-runtime@5.8.20": {
|
||||||
"process": "github:jspm/nodelibs-process@0.1.1"
|
"process": "github:jspm/nodelibs-process@0.1.1"
|
||||||
},
|
},
|
||||||
"npm:clipper-lib@1.0.0": {
|
"npm:clipper-lib@1.0.0": {
|
||||||
@ -75,7 +75,7 @@ System.config({
|
|||||||
"systemjs-json": "github:systemjs/plugin-json@0.1.0",
|
"systemjs-json": "github:systemjs/plugin-json@0.1.0",
|
||||||
"util": "github:jspm/nodelibs-util@0.1.0"
|
"util": "github:jspm/nodelibs-util@0.1.0"
|
||||||
},
|
},
|
||||||
"npm:lodash@3.10.0": {
|
"npm:lodash@3.10.1": {
|
||||||
"process": "github:jspm/nodelibs-process@0.1.1"
|
"process": "github:jspm/nodelibs-process@0.1.1"
|
||||||
},
|
},
|
||||||
"npm:path-browserify@0.0.0": {
|
"npm:path-browserify@0.0.0": {
|
||||||
|
72
src/gcode.js
72
src/gcode.js
@ -2,7 +2,7 @@ import THREE from 'three.js';
|
|||||||
|
|
||||||
export default class {
|
export default class {
|
||||||
constructor () {
|
constructor () {
|
||||||
this.gcode = "";
|
this.gcode = '';
|
||||||
this.current = {};
|
this.current = {};
|
||||||
|
|
||||||
this.extruder = 0.0;
|
this.extruder = 0.0;
|
||||||
@ -13,7 +13,7 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addGCode (command) {
|
_addGCode (command) {
|
||||||
var str = "";
|
var str = '';
|
||||||
var first = true;
|
var first = true;
|
||||||
|
|
||||||
for (var i in command) {
|
for (var i in command) {
|
||||||
@ -23,13 +23,13 @@ export default class {
|
|||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
else if (this.current[i] !== command[i]) {
|
else if (this.current[i] !== command[i]) {
|
||||||
str += " " + i + command[i];
|
str += ' ' + i + command[i];
|
||||||
|
|
||||||
this.current[i] = command[i];
|
this.current[i] = command[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gcode += str + "\n";
|
this.gcode += str + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
setSettings (settings) {
|
setSettings (settings) {
|
||||||
@ -42,11 +42,11 @@ export default class {
|
|||||||
this.isFanOn = true;
|
this.isFanOn = true;
|
||||||
|
|
||||||
var gcode = {
|
var gcode = {
|
||||||
"M": 106
|
'M': 106
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fanSpeed !== undefined) {
|
if (fanSpeed !== undefined) {
|
||||||
gcode["S"] = fanSpeed;
|
gcode['S'] = fanSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._addGCode(gcode);
|
this._addGCode(gcode);
|
||||||
@ -58,23 +58,23 @@ export default class {
|
|||||||
this.isFanOn = false;
|
this.isFanOn = false;
|
||||||
|
|
||||||
this._addGCode({
|
this._addGCode({
|
||||||
"M": 107
|
'M': 107
|
||||||
});
|
});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveTo (x, y, layer) {
|
moveTo (x, y, layer) {
|
||||||
var layerHeight = this.settings.config["layerHeight"];
|
var layerHeight = this.settings.config['layerHeight'];
|
||||||
var travelSpeed = this.settings.config["travelSpeed"];
|
var travelSpeed = this.settings.config['travelSpeed'];
|
||||||
|
|
||||||
var z = (layer + 1) * layerHeight;
|
var z = (layer + 1) * layerHeight;
|
||||||
var speed = travelSpeed * 60;
|
var speed = travelSpeed * 60;
|
||||||
|
|
||||||
this._addGCode({
|
this._addGCode({
|
||||||
"G": 0,
|
'G': 0,
|
||||||
"X": x.toFixed(3), "Y": y.toFixed(3), "Z": z.toFixed(3),
|
'X': x.toFixed(3), 'Y': y.toFixed(3), 'Z': z.toFixed(3),
|
||||||
"F": speed.toFixed(3)
|
'F': speed.toFixed(3)
|
||||||
});
|
});
|
||||||
|
|
||||||
this._nozzlePosition.set(x, y);
|
this._nozzlePosition.set(x, y);
|
||||||
@ -85,15 +85,15 @@ export default class {
|
|||||||
lineTo (x, y, layer, type) {
|
lineTo (x, y, layer, type) {
|
||||||
var newNozzlePosition = new THREE.Vector2(x, y);
|
var newNozzlePosition = new THREE.Vector2(x, y);
|
||||||
|
|
||||||
var layerHeight = this.settings.config["layerHeight"];
|
var layerHeight = this.settings.config['layerHeight'];
|
||||||
var nozzleDiameter = this.settings.config["nozzleDiameter"];
|
var nozzleDiameter = this.settings.config['nozzleDiameter'];
|
||||||
var filamentThickness = this.settings.config["filamentThickness"];
|
var filamentThickness = this.settings.config['filamentThickness'];
|
||||||
var travelSpeed = this.settings.config["travelSpeed"];
|
var travelSpeed = this.settings.config['travelSpeed'];
|
||||||
|
|
||||||
var profile = this.settings.config[(this.bottom ? "bottom" : type)];
|
var profile = this.settings.config[(this.bottom ? 'bottom' : type)];
|
||||||
|
|
||||||
var speed = profile["speed"] * 60;
|
var speed = profile['speed'] * 60;
|
||||||
var flowRate = profile["flowRate"];
|
var flowRate = profile['flowRate'];
|
||||||
var z = (layer + 1) * layerHeight;
|
var z = (layer + 1) * layerHeight;
|
||||||
|
|
||||||
var lineLength = this._nozzlePosition.distanceTo(newNozzlePosition);
|
var lineLength = this._nozzlePosition.distanceTo(newNozzlePosition);
|
||||||
@ -102,10 +102,10 @@ export default class {
|
|||||||
this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate;
|
this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate;
|
||||||
|
|
||||||
this._addGCode({
|
this._addGCode({
|
||||||
"G": 1,
|
'G': 1,
|
||||||
"X": x.toFixed(3), "Y": y.toFixed(3), "Z": z.toFixed(3),
|
'X': x.toFixed(3), 'Y': y.toFixed(3), 'Z': z.toFixed(3),
|
||||||
"F": speed.toFixed(3),
|
'F': speed.toFixed(3),
|
||||||
"E": this.extruder.toFixed(3)
|
'E': this.extruder.toFixed(3)
|
||||||
});
|
});
|
||||||
|
|
||||||
this._nozzlePosition.copy(newNozzlePosition);
|
this._nozzlePosition.copy(newNozzlePosition);
|
||||||
@ -114,9 +114,9 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unRetract () {
|
unRetract () {
|
||||||
var retractionEnabled = this.settings.config["retractionEnabled"];
|
var retractionEnabled = this.settings.config['retractionEnabled'];
|
||||||
var retractionMinDistance = this.settings.config["retractionMinDistance"];
|
var retractionMinDistance = this.settings.config['retractionMinDistance'];
|
||||||
var retractionSpeed = this.settings.config["retractionSpeed"];
|
var retractionSpeed = this.settings.config['retractionSpeed'];
|
||||||
|
|
||||||
if (this.isRetracted && retractionEnabled) {
|
if (this.isRetracted && retractionEnabled) {
|
||||||
this.isRetracted = false;
|
this.isRetracted = false;
|
||||||
@ -125,9 +125,9 @@ export default class {
|
|||||||
|
|
||||||
if (this.extruder > retractionMinDistance) {
|
if (this.extruder > retractionMinDistance) {
|
||||||
this._addGCode({
|
this._addGCode({
|
||||||
"G": 0,
|
'G': 0,
|
||||||
"E": this.extruder.toFixed(3),
|
'E': this.extruder.toFixed(3),
|
||||||
"F": speed.toFixed(3)
|
'F': speed.toFixed(3)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,10 +136,10 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
retract () {
|
retract () {
|
||||||
var retractionAmount = this.settings.config["retractionAmount"];
|
var retractionAmount = this.settings.config['retractionAmount'];
|
||||||
var retractionEnabled = this.settings.config["retractionEnabled"];
|
var retractionEnabled = this.settings.config['retractionEnabled'];
|
||||||
var retractionMinDistance = this.settings.config["retractionMinDistance"];
|
var retractionMinDistance = this.settings.config['retractionMinDistance'];
|
||||||
var retractionSpeed = this.settings.config["retractionSpeed"];
|
var retractionSpeed = this.settings.config['retractionSpeed'];
|
||||||
|
|
||||||
if (!this.isRetracted && retractionEnabled) {
|
if (!this.isRetracted && retractionEnabled) {
|
||||||
this.isRetracted = true;
|
this.isRetracted = true;
|
||||||
@ -148,9 +148,9 @@ export default class {
|
|||||||
|
|
||||||
if (this.extruder > retractionMinDistance && retractionEnabled) {
|
if (this.extruder > retractionMinDistance && retractionEnabled) {
|
||||||
this._addGCode({
|
this._addGCode({
|
||||||
"G": 0,
|
'G': 0,
|
||||||
"E": (this.extruder - retractionAmount).toFixed(3),
|
'E': (this.extruder - retractionAmount).toFixed(3),
|
||||||
"F": speed.toFixed(3)
|
'F': speed.toFixed(3)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import Slicer from './slicer.js';
|
import Slicer from './slicer.js';
|
||||||
import SlicerWorker from './slicerworker.js';
|
import SlicerWorker from './slicerworker.js';
|
||||||
import Settings from './settings.js';
|
import Settings from './settings.js';
|
||||||
|
import ClipperLib from 'clipper-lib';
|
||||||
|
|
||||||
|
ClipperLib.Error = function (message) {
|
||||||
|
console.error(message);
|
||||||
|
};
|
||||||
|
|
||||||
export {Slicer, SlicerWorker, Settings};
|
export {Slicer, SlicerWorker, Settings};
|
||||||
|
@ -212,9 +212,6 @@ export default class Paths extends Array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isHole () {
|
isHole () {
|
||||||
if (this.length !== 1) {
|
|
||||||
console.log('wtf?');
|
|
||||||
}
|
|
||||||
return !ClipperLib.Clipper.Orientation(this[0]);
|
return !ClipperLib.Clipper.Orientation(this[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,10 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (part2.intersect(part1).length > 0) {
|
if (part2.intersect(part1).length > 0) {
|
||||||
this.parts[i].intersect = part1.union(part2);
|
part1 = this.parts[i].intersect = part1.union(part2);
|
||||||
|
|
||||||
this.parts.splice(j, 1);
|
this.parts.splice(j, 1);
|
||||||
|
j --;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,6 +338,10 @@ export default class {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outlines.sort((a, b) => {
|
||||||
|
return a.boundSize() - b.boundSize();
|
||||||
|
});
|
||||||
|
|
||||||
for (var i = 0; i < holes.length; i ++) {
|
for (var i = 0; i < holes.length; i ++) {
|
||||||
var hole = holes[i];
|
var hole = holes[i];
|
||||||
|
|
||||||
@ -384,8 +388,8 @@ export default class {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var outerLine = part.intersect.clone().scaleUp(scale).offset(-nozzleRadius);
|
// var outerLine = part.intersect.clone().scaleUp(scale).offset(-nozzleRadius);
|
||||||
//var outerLine = part.intersect.scaleUp(scale).offset(-nozzleRadius);
|
var outerLine = part.intersect.scaleUp(scale).offset(-nozzleRadius);
|
||||||
|
|
||||||
if (outerLine.length > 0) {
|
if (outerLine.length > 0) {
|
||||||
part.outerLine = outerLine;
|
part.outerLine = outerLine;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user