added top & bottom thickness

feature/interface
casperlamboo 7 years ago
parent f38ab10e62
commit ec447ab56e
  1. BIN
      models/stanford_bunny_high.stl
  2. 15
      slice_test.html
  3. 104
      src/slicer.js

Binary file not shown.

@ -48,27 +48,29 @@ var printerConfig = {
"printer.retraction.minDistance": 5,
"printer.retraction.speed": 50,
"printer.screenToMillimeterScale": 0.3, //????
"printer.speed": 70,
"printer.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)",
"printer.temperature": 230,
"printer.travelSpeed": 200,
"printer.type": "ultimaker",
"printer.useSubLayers": true, //wat is dit?
"printer.speed": 50,
"printer.wallThickness": 0.4, //nozzle
"printer.layerHeight": 0.2,
//variabele toevoegen;
//-snelheid, retraction etc voor verschillende types (outerlayer, innerlayer, fill)
"printer.bottomThickness": 0.4,
"printer.topThickness": 0.8,
"printer.shellThickness": 0.4,
"printer.fillSize": 5, //dit is het raster aan de binnen kant van de geometry
"printer.brimOffset": 5,
"printer.bottomTopThickness": 0.8
"printer.brimOffset": 5
};
var printer = new D3D.Printer(printerConfig);
var localIp = location.hash.substring(1);
//var doodleBox = new D3D.Box(localIp);
var doodleBox = new D3D.Box(localIp);
//var printer = doodleBox.printer;
var scene = new THREE.Scene();
@ -88,7 +90,7 @@ camera.add(directionalLight);
applyMouseControls(renderer, camera, new THREE.Vector3(100, 0, 100), 1000);
var loader = new THREE.STLLoader();
loader.load("models/pikachu.stl", function (geometry) {
loader.load("models/d20.stl", function (geometry) {
//var geometry = new THREE.BoxGeometry(10, 10, 10, 1, 1, 1);
//var geometry = new THREE.SphereGeometry(10, 10, 10);
//var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
@ -122,6 +124,7 @@ loader.load("models/pikachu.stl", function (geometry) {
var mesh = new THREE.Mesh(geometry, material);
mesh.rotation.x = -Math.PI/2;
//mesh.rotation.z = Math.PI;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
mesh.position.x = 100;
mesh.position.z = 100;
@ -134,7 +137,7 @@ loader.load("models/pikachu.stl", function (geometry) {
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var img = slicer.drawPaths(printer, 5, 6);
var img = slicer.drawPaths(printer, 0, 1);
context.drawImage(img, 0, 0);
gcode = slicer.getGcode(printer);

@ -252,7 +252,11 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
var shellThickness = printer.config["printer.shellThickness"] * scale;
var fillSize = printer.config["printer.fillSize"] * scale;
var brimOffset = printer.config["printer.brimOffset"] * scale;
var skinCount = Math.ceil(shellThickness/layerHeight);
var bottomThickness = printer.config["printer.bottomThickness"] * scale;
var topThickness = printer.config["printer.topThickness"] * scale;
var bottomSkinCount = Math.ceil(bottomThickness/layerHeight);
var topSkinCount = Math.ceil(topThickness/layerHeight);
var start = new THREE.Vector2(0, 0);
@ -272,15 +276,15 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
data.push(layerData);
var downSkin = new D3D.Paths([], true);
if (layer - skinCount >= 0) {
var downLayer = slices[layer - skinCount];
if (layer - bottomSkinCount >= 0) {
var downLayer = slices[layer - bottomSkinCount];
for (var i = 0; i < downLayer.length; i ++) {
downSkin.join(downLayer[i]);
}
}
var upSkin = new D3D.Paths([], true);
if (layer + skinCount < slices.length) {
var downLayer = slices[layer + skinCount];
if (layer + topSkinCount < slices.length) {
var downLayer = slices[layer + topSkinCount];
for (var i = 0; i < downLayer.length; i ++) {
upSkin.join(downLayer[i]);
}
@ -291,60 +295,62 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
for (var i = 0; i < slice.length; i ++) {
var part = slice[i];
var outerLayer = part.clone();
outerLayer.scaleUp(scale);
//var outerLayer = part.clone();
var outerLayer = part.clone().scaleUp(scale).offset(-wallThickness/2);
var insets = new D3D.Paths([], true);
for (var offset = wallThickness; offset <= shellThickness; offset += wallThickness) {
var inset = outerLayer.offset(-offset);
if (outerLayer.length > 0) {
var insets = new D3D.Paths([], true);
for (var offset = wallThickness; offset <= shellThickness; offset += wallThickness) {
var inset = outerLayer.offset(-offset);
insets.join(inset);
}
insets.join(inset);
}
var fillArea = (inset || outerLayer).offset(-wallThickness/2);
//var fillArea = (inset || outerLayer).clone();
var fillArea = (inset || outerLayer).offset(-wallThickness/2);
//var fillArea = (inset || outerLayer).clone();
var highFillArea = fillArea.difference(surroundingLayer);
var highFillArea = fillArea.difference(surroundingLayer);
var lowFillArea = fillArea.difference(highFillArea);
var lowFillArea = fillArea.difference(highFillArea);
var fill = new D3D.Paths([], false);
var fill = new D3D.Paths([], false);
if (lowFillTemplate.length > 0) {
fill.join(lowFillTemplate.intersect(lowFillArea));
}
if (lowFillTemplate.length > 0) {
fill.join(lowFillTemplate.intersect(lowFillArea));
}
if (highFillArea.length > 0) {
var bounds = highFillArea.bounds();
var even = (layer % 2 === 0);
var highFillTemplate = this.getFillTemplate(bounds, wallThickness, even, !even);
fill.join(highFillTemplate.intersect(highFillArea));
}
outerLayer = outerLayer.optimizePath(start);
if (insets.length > 0) {
insets = insets.optimizePath(outerLayer.lastPoint());
fill = fill.optimizePath(insets.lastPoint());
}
else {
fill = fill.optimizePath(outerLayer.lastPoint());
}
if (highFillArea.length > 0) {
var bounds = highFillArea.bounds();
var even = (layer % 2 === 0);
var highFillTemplate = this.getFillTemplate(bounds, wallThickness, even, !even);
fill.join(highFillTemplate.intersect(highFillArea));
}
outerLayer = outerLayer.optimizePath(start);
if (insets.length > 0) {
insets = insets.optimizePath(outerLayer.lastPoint());
fill = fill.optimizePath(insets.lastPoint());
}
else {
fill = fill.optimizePath(outerLayer.lastPoint());
}
if (fill.length > 0) {
start = fill.lastPoint();
}
else if (insets.length > 0) {
start = insets.lastPoint();
}
else {
start = outerLayer.lastPoint();
if (fill.length > 0) {
start = fill.lastPoint();
}
else if (insets.length > 0) {
start = insets.lastPoint();
}
else {
start = outerLayer.lastPoint();
}
layerData.push({
outerLayer: outerLayer.scaleDown(scale),
fill: fill.scaleDown(scale),
insets: insets.scaleDown(scale)
});
}
layerData.push({
outerLayer: outerLayer.scaleDown(scale),
fill: fill.scaleDown(scale),
insets: insets.scaleDown(scale)
});
}
}

Loading…
Cancel
Save