Merge branch 'feature/support' into develop

This commit is contained in:
casperlamboo 2018-01-24 14:29:28 +01:00
commit 6628b9cf13
6 changed files with 48 additions and 65 deletions

View File

@ -165,6 +165,14 @@ class Settings extends React.Component {
case 'settings.brim.flowRate': case 'settings.brim.flowRate':
case 'settings.firstLayer.speed': case 'settings.firstLayer.speed':
case 'settings.firstLayer.flowRate': case 'settings.firstLayer.flowRate':
case 'settings.support.enabled':
case 'settings.support.speed':
case 'settings.support.distanceY':
case 'settings.support.density':
case 'settings.support.minArea':
case 'settings.support.margin':
case 'settings.support.speed':
case 'settings.support.flowRate':
if (!localStorage.active) return this.openAddPrinterDialog(); if (!localStorage.active) return this.openAddPrinterDialog();
if (value === null) { if (value === null) {
@ -374,6 +382,15 @@ class Settings extends React.Component {
<NumberField name="settings.brim.size" min={0} max={20} fullWidth floatingLabelText="Size" /> <NumberField name="settings.brim.size" min={0} max={20} fullWidth floatingLabelText="Size" />
<NumberField name="settings.brim.speed" min={10} max={200} fullWidth floatingLabelText="Speed" /> <NumberField name="settings.brim.speed" min={10} max={200} fullWidth floatingLabelText="Speed" />
<NumberField name="settings.brim.flowRate" min={0.1} max={4} fullWidth floatingLabelText="Flow rate" /> <NumberField name="settings.brim.flowRate" min={0.1} max={4} fullWidth floatingLabelText="Flow rate" />
<p>Support</p>
<Checkbox name="settings.support.enabled" label="Enabled" />
<NumberField name="settings.support.speed" min={0.1} fullWidth floatingLabelText="Accaptance Margin" />
<NumberField name="settings.support.distanceY" min={0.1} fullWidth floatingLabelText="Distance Y" />
<NumberField name="settings.support.density" min={0} max={100} fullWidth floatingLabelText="Density" />
<NumberField name="settings.support.margin" min={0.1} fullWidth floatingLabelText="Margin" />
<NumberField name="settings.support.minArea" min={1} fullWidth floatingLabelText="Min Area" />
<NumberField name="settings.support.speed" min={10} max={200} fullWidth floatingLabelText="Speed" />
<NumberField name="settings.support.flowRate" min={0.1} max={4} fullWidth floatingLabelText="Flow rate" />
<p>First layer</p> <p>First layer</p>
<NumberField name="settings.firstLayer.speed" min={10} max={200} fullWidth floatingLabelText="Speed" /> <NumberField name="settings.firstLayer.speed" min={10} max={200} fullWidth floatingLabelText="Speed" />
<NumberField name="settings.firstLayer.flowRate" min={0.1} max={4} fullWidth floatingLabelText="Flow rate" /> <NumberField name="settings.firstLayer.flowRate" min={0.1} max={4} fullWidth floatingLabelText="Flow rate" />

View File

@ -22,11 +22,10 @@ travel:
speed: 200.0 speed: 200.0
support: support:
enabled: false enabled: false
acceptanceMargin: 1.5 minArea: 2
distanceY: 0.4 distanceY: 0.4
gridSize: 6.0 density: 5.0
margin: 2.0 margin: 2.0
plateSize: 4.0
flowRate: 0.8 flowRate: 0.8
speed: 40.0 speed: 40.0
innerShell: innerShell:

View File

@ -5,7 +5,7 @@ import Shape from 'clipper-js';
export default function generateInfills(slices, settings) { export default function generateInfills(slices, settings) {
let { let {
layerHeight, layerHeight,
innerInfill: { density: infillDensity }, innerInfill: { density },
thickness: { thickness: {
top: topThickness, top: topThickness,
bottom: bottomThickness bottom: bottomThickness
@ -13,11 +13,11 @@ export default function generateInfills(slices, settings) {
nozzleDiameter nozzleDiameter
} = settings; } = settings;
infillDensity /= 100; density /= 100;
nozzleDiameter /= PRECISION; nozzleDiameter /= PRECISION;
const bidirectionalInfill = infillDensity < 0.8; const bidirectionalInfill = density < 0.8;
const infillGridSize = nozzleDiameter * (bidirectionalInfill ? 2 : 1) / infillDensity; const infillGridSize = nozzleDiameter * (bidirectionalInfill ? 2 : 1) / density;
const bottomSkinCount = Math.ceil(bottomThickness / layerHeight); const bottomSkinCount = Math.ceil(bottomThickness / layerHeight);
const topSkinCount = Math.ceil(topThickness / layerHeight); const topSkinCount = Math.ceil(topThickness / layerHeight);

View File

@ -2,75 +2,42 @@ import getFillTemplate from './getFillTemplate.js';
import Shape from 'clipper-js'; import Shape from 'clipper-js';
import { PRECISION } from '../constants.js'; import { PRECISION } from '../constants.js';
const PRECISION_SQUARED = Math.pow(PRECISION, 2);
export default function generateSupport(slices, settings) { export default function generateSupport(slices, settings) {
if (!settings.support.enabled) return; if (!settings.support.enabled) return;
let { let {
layerHeight, layerHeight,
support: { support: { density, margin, minArea, distanceY },
gridSize: supportGridSize,
margin: supportMargin,
plateSize: plateSize,
distanceY: supportDistanceY
},
nozzleDiameter nozzleDiameter
} = settings; } = settings;
supportGridSize /= PRECISION; density /= 100;
supportMargin /= PRECISION; margin /= PRECISION;
plateSize /= PRECISION;
nozzleDiameter /= PRECISION; nozzleDiameter /= PRECISION;
var supportDistanceLayers = Math.max(Math.ceil(supportDistanceY / layerHeight), 1);
var supportAreas = new Shape([], true); const infillGridSize = nozzleDiameter * 2 / density;
const supportDistanceLayers = Math.max(Math.ceil(distanceY / layerHeight), 1);
for (var layer = slices.length - 1 - supportDistanceLayers; layer >= 0; layer --) { let supportArea = new Shape([], true);
var currentSlice = slices[layer];
if (supportAreas.length > 0) { for (let layer = slices.length - 1 - supportDistanceLayers; layer >= supportDistanceLayers; layer --) {
const currentLayer = slices[layer + supportDistanceLayers - 1];
const upSkin = slices[layer + supportDistanceLayers];
const downSkin = slices[layer - supportDistanceLayers];
if (layer >= supportDistanceLayers) { const neededSupportArea = upSkin.outline.difference(currentLayer.outline.offset(margin));
var sliceSkin = slices[layer - supportDistanceLayers].outline;
sliceSkin = sliceSkin;
var supportAreasSlimmed = supportAreas.difference(sliceSkin.offset(supportMargin)); if (neededSupportArea.totalArea() * PRECISION_SQUARED > minArea) {
if (supportAreasSlimmed.area() < 100.0) { supportArea = supportArea.union(neededSupportArea);
supportAreas = supportAreas.difference(sliceSkin);
}
else {
supportAreas = supportAreasSlimmed;
}
} }
if (downSkin) supportArea = supportArea.difference(downSkin.outline.offset(margin));
var supportTemplate = getFillTemplate(supportAreas.bounds(), supportGridSize, true, true); const bounds = supportArea.shapeBounds();
var supportFill = supportTemplate.intersect(supportAreas); const innerFillTemplate = getFillTemplate(bounds, infillGridSize, true, true);
if (supportFill.length === 0) {
currentSlice.support = supportAreas.clone();
}
else {
currentSlice.support = supportFill;
}
}
var supportSkin = slices[layer + supportDistanceLayers - 1].outline; slices[layer].support = supportArea.clone().join(supportArea.intersect(innerFillTemplate));
slices[layer].supportOutline = supportArea;
var slice = slices[layer + supportDistanceLayers];
for (var i = 0; i < slice.parts.length; i ++) {
var slicePart = slice.parts[i];
if (slicePart.intersect.closed) {
var outerLine = slicePart.outerLine;
}
else {
var outerLine = slicePart.intersect.offset(supportMargin);
}
var overlap = supportSkin.offset(supportMargin).intersect(outerLine);
var overhang = outerLine.difference(overlap);
if (overlap.length === 0 || overhang.length > 0) {
supportAreas = supportAreas.join(overhang);
}
}
} }
} }

View File

@ -74,7 +74,7 @@ export default function optimizePaths(slices, settings) {
slice.parts = parts; slice.parts = parts;
if (typeof slice.support !== 'undefined' && slice.support.length > 0) { if (typeof slice.support !== 'undefined' && slice.support.paths.length > 0) {
slice.support = optimizeShape(slice.support, start); slice.support = optimizeShape(slice.support, start);
start.copy(slice.support.lastPoint(true)); start.copy(slice.support.lastPoint(true));
} }

View File

@ -62,11 +62,11 @@ export default function slicesToGCode(slices, settings) {
const unRetract = isOuterShell; const unRetract = isOuterShell;
const profile = isOuterShell ? profiles.outerShell : profiles.innerShell; const profile = isOuterShell ? profiles.outerShell : profiles.innerShell;
pathToGCode(outline, combing && true, gcode, shell, false, unRetract, z, profile); pathToGCode(outline, combing, gcode, shell, false, unRetract, z, profile);
} }
pathToGCode(outline, combing && true, gcode, part.outerFill, false, false, z, profiles.outerInfill); pathToGCode(outline, combing, gcode, part.outerFill, false, false, z, profiles.outerInfill);
pathToGCode(outline, combing && true, gcode, part.innerFill, true, false, z, profiles.innerInfill); pathToGCode(outline, combing, gcode, part.innerFill, true, false, z, profiles.innerInfill);
} else { } else {
const retract = !(slice.parts.length === 1 && typeof slice.support === 'undefined'); const retract = !(slice.parts.length === 1 && typeof slice.support === 'undefined');
pathToGCode(null, false, gcode, part.shape, retract, retract, z, profiles.outerShell); pathToGCode(null, false, gcode, part.shape, retract, retract, z, profiles.outerShell);
@ -74,7 +74,7 @@ export default function slicesToGCode(slices, settings) {
} }
if (typeof slice.support !== 'undefined') { if (typeof slice.support !== 'undefined') {
pathToGCode(null, false, gcode, slice.support, true, true, z, profiles.support); pathToGCode(slice.supportOutline, combing, gcode, slice.support, true, true, z, profiles.support);
} }
} }