fixed clipper alert error

This commit is contained in:
casperlamboo 2015-08-26 18:27:56 +02:00
parent aa71eb5b67
commit fa38d8117e
6 changed files with 54 additions and 47 deletions

View File

@ -15,8 +15,8 @@ System.config({
System.config({
"map": {
"babel": "npm:babel-core@5.6.20",
"babel-runtime": "npm:babel-runtime@5.6.20",
"babel": "npm:babel-core@5.8.21",
"babel-runtime": "npm:babel-runtime@5.8.20",
"clipper-lib": "npm:clipper-lib@1.0.0",
"core-js": "npm:core-js@0.9.18",
"json": "github:systemjs/plugin-json@0.1.0",
@ -39,7 +39,7 @@ System.config({
"npm:argparse@1.0.2": {
"assert": "github:jspm/nodelibs-assert@0.1.0",
"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",
"process": "github:jspm/nodelibs-process@0.1.1",
"sprintf-js": "npm:sprintf-js@1.0.3",
@ -48,7 +48,7 @@ System.config({
"npm:assert@1.3.0": {
"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"
},
"npm:clipper-lib@1.0.0": {
@ -75,7 +75,7 @@ System.config({
"systemjs-json": "github:systemjs/plugin-json@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"
},
"npm:path-browserify@0.0.0": {

View File

@ -2,7 +2,7 @@ import THREE from 'three.js';
export default class {
constructor () {
this.gcode = "";
this.gcode = '';
this.current = {};
this.extruder = 0.0;
@ -13,7 +13,7 @@ export default class {
}
_addGCode (command) {
var str = "";
var str = '';
var first = true;
for (var i in command) {
@ -23,13 +23,13 @@ export default class {
first = false;
}
else if (this.current[i] !== command[i]) {
str += " " + i + command[i];
str += ' ' + i + command[i];
this.current[i] = command[i];
}
}
this.gcode += str + "\n";
this.gcode += str + '\n';
}
setSettings (settings) {
@ -42,11 +42,11 @@ export default class {
this.isFanOn = true;
var gcode = {
"M": 106
'M': 106
}
if (fanSpeed !== undefined) {
gcode["S"] = fanSpeed;
gcode['S'] = fanSpeed;
}
this._addGCode(gcode);
@ -58,23 +58,23 @@ export default class {
this.isFanOn = false;
this._addGCode({
"M": 107
'M': 107
});
return this;
}
moveTo (x, y, layer) {
var layerHeight = this.settings.config["layerHeight"];
var travelSpeed = this.settings.config["travelSpeed"];
var layerHeight = this.settings.config['layerHeight'];
var travelSpeed = this.settings.config['travelSpeed'];
var z = (layer + 1) * layerHeight;
var speed = travelSpeed * 60;
this._addGCode({
"G": 0,
"X": x.toFixed(3), "Y": y.toFixed(3), "Z": z.toFixed(3),
"F": speed.toFixed(3)
'G': 0,
'X': x.toFixed(3), 'Y': y.toFixed(3), 'Z': z.toFixed(3),
'F': speed.toFixed(3)
});
this._nozzlePosition.set(x, y);
@ -85,15 +85,15 @@ export default class {
lineTo (x, y, layer, type) {
var newNozzlePosition = new THREE.Vector2(x, y);
var layerHeight = this.settings.config["layerHeight"];
var nozzleDiameter = this.settings.config["nozzleDiameter"];
var filamentThickness = this.settings.config["filamentThickness"];
var travelSpeed = this.settings.config["travelSpeed"];
var layerHeight = this.settings.config['layerHeight'];
var nozzleDiameter = this.settings.config['nozzleDiameter'];
var filamentThickness = this.settings.config['filamentThickness'];
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 flowRate = profile["flowRate"];
var speed = profile['speed'] * 60;
var flowRate = profile['flowRate'];
var z = (layer + 1) * layerHeight;
var lineLength = this._nozzlePosition.distanceTo(newNozzlePosition);
@ -102,10 +102,10 @@ export default class {
this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate;
this._addGCode({
"G": 1,
"X": x.toFixed(3), "Y": y.toFixed(3), "Z": z.toFixed(3),
"F": speed.toFixed(3),
"E": this.extruder.toFixed(3)
'G': 1,
'X': x.toFixed(3), 'Y': y.toFixed(3), 'Z': z.toFixed(3),
'F': speed.toFixed(3),
'E': this.extruder.toFixed(3)
});
this._nozzlePosition.copy(newNozzlePosition);
@ -114,9 +114,9 @@ export default class {
}
unRetract () {
var retractionEnabled = this.settings.config["retractionEnabled"];
var retractionMinDistance = this.settings.config["retractionMinDistance"];
var retractionSpeed = this.settings.config["retractionSpeed"];
var retractionEnabled = this.settings.config['retractionEnabled'];
var retractionMinDistance = this.settings.config['retractionMinDistance'];
var retractionSpeed = this.settings.config['retractionSpeed'];
if (this.isRetracted && retractionEnabled) {
this.isRetracted = false;
@ -125,9 +125,9 @@ export default class {
if (this.extruder > retractionMinDistance) {
this._addGCode({
"G": 0,
"E": this.extruder.toFixed(3),
"F": speed.toFixed(3)
'G': 0,
'E': this.extruder.toFixed(3),
'F': speed.toFixed(3)
});
}
}
@ -136,10 +136,10 @@ export default class {
}
retract () {
var retractionAmount = this.settings.config["retractionAmount"];
var retractionEnabled = this.settings.config["retractionEnabled"];
var retractionMinDistance = this.settings.config["retractionMinDistance"];
var retractionSpeed = this.settings.config["retractionSpeed"];
var retractionAmount = this.settings.config['retractionAmount'];
var retractionEnabled = this.settings.config['retractionEnabled'];
var retractionMinDistance = this.settings.config['retractionMinDistance'];
var retractionSpeed = this.settings.config['retractionSpeed'];
if (!this.isRetracted && retractionEnabled) {
this.isRetracted = true;
@ -148,9 +148,9 @@ export default class {
if (this.extruder > retractionMinDistance && retractionEnabled) {
this._addGCode({
"G": 0,
"E": (this.extruder - retractionAmount).toFixed(3),
"F": speed.toFixed(3)
'G': 0,
'E': (this.extruder - retractionAmount).toFixed(3),
'F': speed.toFixed(3)
});
}
}

View File

@ -1,5 +1,10 @@
import Slicer from './slicer.js';
import SlicerWorker from './slicerworker.js';
import Settings from './settings.js';
import ClipperLib from 'clipper-lib';
ClipperLib.Error = function (message) {
console.error(message);
};
export {Slicer, SlicerWorker, Settings};

View File

@ -212,9 +212,6 @@ export default class Paths extends Array {
}
isHole () {
if (this.length !== 1) {
console.log('wtf?');
}
return !ClipperLib.Clipper.Orientation(this[0]);
}

View File

@ -21,9 +21,10 @@ export default class {
}
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);
j --;
}
}
}

View File

@ -338,6 +338,10 @@ export default class {
}
}
outlines.sort((a, b) => {
return a.boundSize() - b.boundSize();
});
for (var i = 0; i < holes.length; i ++) {
var hole = holes[i];
@ -384,8 +388,8 @@ export default class {
continue;
}
var outerLine = part.intersect.clone().scaleUp(scale).offset(-nozzleRadius);
//var outerLine = part.intersect.scaleUp(scale).offset(-nozzleRadius);
// var outerLine = part.intersect.clone().scaleUp(scale).offset(-nozzleRadius);
var outerLine = part.intersect.scaleUp(scale).offset(-nozzleRadius);
if (outerLine.length > 0) {
part.outerLine = outerLine;