mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-16 11:07:57 +01:00
improves slicing algorithm
fixed https://github.com/Doodle3D/Doodle3D-Slicer/issues/4
This commit is contained in:
parent
890bc8bb56
commit
c0cfa8de9d
@ -61,13 +61,13 @@ D3D.Slicer.prototype.getGCode = function (printer) {
|
|||||||
var slices = this._slice(lines, printer);
|
var slices = this._slice(lines, printer);
|
||||||
|
|
||||||
this._generateInnerLines(slices, printer);
|
this._generateInnerLines(slices, printer);
|
||||||
|
|
||||||
this._generateInfills(slices, printer);
|
this._generateInfills(slices, printer);
|
||||||
|
|
||||||
if (useSupport) {
|
if (useSupport) {
|
||||||
this._generateSupport(slices, printer);
|
this._generateSupport(slices, printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._optimizePaths(slices, printer);
|
this._optimizePaths(slices, printer);
|
||||||
|
|
||||||
var gcode = this._slicesToGCode(slices, printer);
|
var gcode = this._slicesToGCode(slices, printer);
|
||||||
@ -132,15 +132,13 @@ D3D.Slicer.prototype._slice = function (lines, printer) {
|
|||||||
var layerHeight = printer.config["layerHeight"];
|
var layerHeight = printer.config["layerHeight"];
|
||||||
var height = printer.config["dimensionsZ"];
|
var height = printer.config["dimensionsZ"];
|
||||||
|
|
||||||
//var testData = [];
|
|
||||||
|
|
||||||
var numLayers = height / layerHeight;
|
var numLayers = height / layerHeight;
|
||||||
|
|
||||||
var layersIntersections = [];
|
var layersIntersections = [];
|
||||||
for (var layer = 0; layer < numLayers; layer ++) {
|
for (var layer = 0; layer < numLayers; layer ++) {
|
||||||
layersIntersections[layer] = [];
|
layersIntersections[layer] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
|
for (var lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
|
||||||
var line = lines[lineIndex].line;
|
var line = lines[lineIndex].line;
|
||||||
|
|
||||||
@ -155,7 +153,6 @@ D3D.Slicer.prototype._slice = function (lines, printer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var slices = [];
|
var slices = [];
|
||||||
//var testPoints = [];
|
|
||||||
|
|
||||||
for (var layer = 1; layer < layersIntersections.length; layer ++) {
|
for (var layer = 1; layer < layersIntersections.length; layer ++) {
|
||||||
var layerIntersections = layersIntersections[layer];
|
var layerIntersections = layersIntersections[layer];
|
||||||
@ -179,14 +176,6 @@ D3D.Slicer.prototype._slice = function (lines, printer) {
|
|||||||
var z = line.end.z * alpha + line.start.z * (1 - alpha);
|
var z = line.end.z * alpha + line.start.z * (1 - alpha);
|
||||||
}
|
}
|
||||||
intersections[index] = new THREE.Vector2(z, x);
|
intersections[index] = new THREE.Vector2(z, x);
|
||||||
|
|
||||||
/*testPoints.push({
|
|
||||||
x: z,
|
|
||||||
y: x,
|
|
||||||
connects: lines[index].connects,
|
|
||||||
index: index,
|
|
||||||
normals: lines[index].normals
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var done = [];
|
var done = [];
|
||||||
@ -216,7 +205,7 @@ D3D.Slicer.prototype._slice = function (lines, printer) {
|
|||||||
|
|
||||||
var faceNormal = faceNormals[Math.floor(j/2)];
|
var faceNormal = faceNormals[Math.floor(j/2)];
|
||||||
|
|
||||||
if (a.distanceTo(b) === 0 || faceNormal.length() === 0) {
|
if (a.distanceTo(b) < 0.0001 || faceNormal.length() === 0) {
|
||||||
done.push(index);
|
done.push(index);
|
||||||
|
|
||||||
connects = connects.concat(lines[index].connects);
|
connects = connects.concat(lines[index].connects);
|
||||||
@ -268,18 +257,9 @@ D3D.Slicer.prototype._slice = function (lines, printer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
slices.push(slice);
|
slices.push(slice);
|
||||||
|
|
||||||
/*if (layer === 218) {
|
|
||||||
testData.push({
|
|
||||||
testPoints: testPoints,
|
|
||||||
pathData: slice.parts
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(JSON.stringify(testData));
|
|
||||||
|
|
||||||
this.progress.sliced = true;
|
this.progress.sliced = true;
|
||||||
this._updateProgress(printer);
|
this._updateProgress(printer);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ Sidebar.Slicer = function ( editor ) {
|
|||||||
|
|
||||||
slicer.setSettings(USER_SETTINGS, PRINTER_SETTINGS[selectedPrinter]);
|
slicer.setSettings(USER_SETTINGS, PRINTER_SETTINGS[selectedPrinter]);
|
||||||
|
|
||||||
var matrix = new THREE.Matrix().setPosition(new THREE.Vector(0, -geometryCombined.boundingBox.min.y, 0));
|
var matrix = new THREE.Matrix4().setPosition(new THREE.Vector3(0, -geometryCombined.boundingBox.min.y, 0));
|
||||||
slicer.setGeometry(geometryCombined, matrix);
|
slicer.setGeometry(geometryCombined, matrix);
|
||||||
|
|
||||||
slicer.slice();
|
slicer.slice();
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<style>
|
<style>
|
||||||
canvas {border: 1px solid black;}
|
canvas {border: 1px solid black;}
|
||||||
#progress {height: 20px; width: 200px; border: 1px solid black; overflow: hidden;}
|
#progress {height: 20px; width: 200px; border: 1px solid black; overflow: hidden;}
|
||||||
#progress_bar {height: 20px; background-color: lightblue; width: 0%;}
|
#progress_bar {height: 20px; background-color: lightblue; width: 0%; transition: width 0.5s;}
|
||||||
.block {border: 1px solid black; width: 400px; height: 400px; display: inline-block;}
|
.block {border: 1px solid black; width: 400px; height: 400px; display: inline-block;}
|
||||||
#start_print, #download {display: none;}
|
#start_print, #download {display: none;}
|
||||||
</style>
|
</style>
|
||||||
@ -57,7 +57,7 @@ function init () {
|
|||||||
document.getElementById('current_line').innerHTML = data.current_line;
|
document.getElementById('current_line').innerHTML = data.current_line;
|
||||||
document.getElementById('buffered_lines').innerHTML = data.buffered_lines;
|
document.getElementById('buffered_lines').innerHTML = data.buffered_lines;
|
||||||
document.getElementById('total_lines').innerHTML = data.total_lines;
|
document.getElementById('total_lines').innerHTML = data.total_lines;
|
||||||
document.getElementById('print_batches').innerHTML = doodleBox.printBatches.length;
|
document.getElementById('print_batches').innerHTML = doodleBox._printBatches.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
printer = new D3D.Printer().updateConfig(USER_SETTINGS).updateConfig(PRINTER_SETTINGS['ultimaker2go']);
|
printer = new D3D.Printer().updateConfig(USER_SETTINGS).updateConfig(PRINTER_SETTINGS['ultimaker2go']);
|
||||||
@ -101,7 +101,7 @@ function init () {
|
|||||||
var mesh = new THREE.Mesh(geometry, material);
|
var mesh = new THREE.Mesh(geometry, material);
|
||||||
|
|
||||||
mesh.rotation.x = -Math.PI/2;
|
mesh.rotation.x = -Math.PI/2;
|
||||||
mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.7;
|
//mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.7;
|
||||||
mesh.position.x = 60;
|
mesh.position.x = 60;
|
||||||
mesh.position.z = 60;
|
mesh.position.z = 60;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user