implement brim

This commit is contained in:
casperlamboo 2018-01-15 16:30:20 +01:00
parent 9a37e8a928
commit 1ebbe7fc6a
3 changed files with 19 additions and 7 deletions

View File

@ -147,7 +147,7 @@ class Settings extends React.Component {
<TextField name="settings.outerInfill.speed" fullWidth floatingLabelText="Speed" type="number" /> <TextField name="settings.outerInfill.speed" fullWidth floatingLabelText="Speed" type="number" />
<TextField name="settings.outerInfill.flowRate" fullWidth floatingLabelText="Flow rate" type="number" /> <TextField name="settings.outerInfill.flowRate" fullWidth floatingLabelText="Flow rate" type="number" />
<p>Brim</p> <p>Brim</p>
<TextField name="settings.brim.offset" fullWidth floatingLabelText="Offset" type="number" /> <TextField name="settings.brim.size" fullWidth floatingLabelText="Size" type="number" />
<TextField name="settings.brim.speed" fullWidth floatingLabelText="Speed" type="number" /> <TextField name="settings.brim.speed" fullWidth floatingLabelText="Speed" type="number" />
<TextField name="settings.brim.flowRate" fullWidth floatingLabelText="Flow rate" type="number" /> <TextField name="settings.brim.flowRate" fullWidth floatingLabelText="Flow rate" type="number" />
<p>First layer</p> <p>First layer</p>

View File

@ -44,7 +44,7 @@ outerInfill:
flowRate: 1.0 flowRate: 1.0
speed: 50.0 speed: 50.0
brim: brim:
offset: 4.0 size: 4.0
flowRate: 1.0 flowRate: 1.0
speed: 40.0 speed: 40.0
firstLayer: firstLayer:

View File

@ -4,21 +4,33 @@ import { PRECISION } from '../constants.js';
const offsetOptions = { const offsetOptions = {
jointType: 'jtRound', jointType: 'jtRound',
miterLimit: 2.0, miterLimit: 2.0,
roundPrecision: 0.25 roundPrecision: 0.25,
endType: 'etClosedPolygon'
}; };
export default function addBrim(slices, settings) { export default function addBrim(slices, settings) {
let { let {
brim: { offset: brimOffset } brim: { size: brimSize },
nozzleDiameter
} = settings; } = settings;
brimOffset /= PRECISION;
nozzleDiameter /= PRECISION;
brimSize /= PRECISION;
const nozzleRadius = nozzleDiameter / 2;
const [firstLayer] = slices; const [firstLayer] = slices;
firstLayer.brim = firstLayer.parts.reduce((brim, { shape }) => ( const brim = firstLayer.parts.reduce((brim, { shape }) => (
brim.join(shape.offset(brimOffset, { brim.join(shape.offset(nozzleRadius, {
...offsetOptions, ...offsetOptions,
endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound' endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound'
})) }))
), new Shape([], true)).simplify('pftNonZero'); ), new Shape([], true)).simplify('pftNonZero');
firstLayer.brim = new Shape([], true);
for (let offset = 0; offset < brimSize; offset += nozzleDiameter) {
const brimPart = brim.offset(offset, offsetOptions);
firstLayer.brim = firstLayer.brim.join(brimPart);
}
} }