implement support

#33
This commit is contained in:
casperlamboo 2018-01-24 12:50:41 +01:00
parent 5b934f0e71
commit 88291ba549
5 changed files with 41 additions and 58 deletions

View File

@ -166,6 +166,14 @@ class Settings extends React.Component {
case 'settings.brim.flowRate':
case 'settings.firstLayer.speed':
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 (value === null) {
@ -357,6 +365,15 @@ class Settings extends React.Component {
<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.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>
<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" />

View File

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

View File

@ -7,70 +7,37 @@ export default function generateSupport(slices, settings) {
let {
layerHeight,
support: {
gridSize: supportGridSize,
margin: supportMargin,
plateSize: plateSize,
distanceY: supportDistanceY
},
support: { density, margin, minArea, distanceY },
nozzleDiameter
} = settings;
supportGridSize /= PRECISION;
supportMargin /= PRECISION;
plateSize /= PRECISION;
density /= 100;
margin /= PRECISION;
nozzleDiameter /= PRECISION;
var supportDistanceLayers = Math.max(Math.ceil(supportDistanceY / layerHeight), 1);
var supportAreas = new Shape([], true);
const bidirectionalInfill = density < 0.8;
const infillGridSize = nozzleDiameter * 2 / density;
const supportDistanceLayers = Math.max(Math.ceil(distanceY / layerHeight), 1);
for (var layer = slices.length - 1 - supportDistanceLayers; layer >= 0; layer --) {
var currentSlice = slices[layer];
let supportArea = new Shape([], true);
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) {
var sliceSkin = slices[layer - supportDistanceLayers].outline;
sliceSkin = sliceSkin;
const neededSupportArea = upSkin.outline.difference(currentLayer.outline.offset(margin));
var supportAreasSlimmed = supportAreas.difference(sliceSkin.offset(supportMargin));
if (supportAreasSlimmed.area() < 100.0) {
supportAreas = supportAreas.difference(sliceSkin);
}
else {
supportAreas = supportAreasSlimmed;
}
}
var supportTemplate = getFillTemplate(supportAreas.bounds(), supportGridSize, true, true);
var supportFill = supportTemplate.intersect(supportAreas);
if (supportFill.length === 0) {
currentSlice.support = supportAreas.clone();
}
else {
currentSlice.support = supportFill;
}
if (neededSupportArea.totalArea() * Math.pow(PRECISION, 2) > minArea) {
supportArea = supportArea.union(neededSupportArea);
}
if (downSkin) supportArea = supportArea.difference(downSkin.outline.offset(margin));
var supportSkin = slices[layer + supportDistanceLayers - 1].outline;
const even = (layer % 2 === 0);
const bounds = supportArea.shapeBounds();
const innerFillTemplate = getFillTemplate(bounds, infillGridSize, bidirectionalInfill || even, bidirectionalInfill || !even);
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);
}
}
slices[layer].support = supportArea.clone().join(supportArea.intersect(innerFillTemplate));
slices[layer].supportOutline = supportArea;
}
}

View File

@ -74,7 +74,7 @@ export default function optimizePaths(slices, settings) {
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);
start.copy(slice.support.lastPoint(true));
}

View File

@ -74,7 +74,7 @@ export default function slicesToGCode(slices, settings) {
}
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);
}
}