Change infill gridsize to infill percentage

#31
This commit is contained in:
casperlamboo 2018-01-16 18:52:03 +01:00
parent 7b59ba1108
commit f20f5b95b8
4 changed files with 12 additions and 12 deletions

View File

@ -144,7 +144,7 @@ class Settings extends React.Component {
case 'settings.innerShell.flowRate': case 'settings.innerShell.flowRate':
case 'settings.outerShell.speed': case 'settings.outerShell.speed':
case 'settings.outerShell.flowRate': case 'settings.outerShell.flowRate':
case 'settings.innerInfill.gridSize': case 'settings.innerInfill.precentage':
case 'settings.innerInfill.speed': case 'settings.innerInfill.speed':
case 'settings.innerInfill.flowRate': case 'settings.innerInfill.flowRate':
case 'settings.outerInfill.speed': case 'settings.outerInfill.speed':
@ -306,7 +306,7 @@ class Settings extends React.Component {
<TextField name="settings.outerShell.speed" fullWidth floatingLabelText="Speed" type="number" /> <TextField name="settings.outerShell.speed" fullWidth floatingLabelText="Speed" type="number" />
<TextField name="settings.outerShell.flowRate" fullWidth floatingLabelText="Flow rate" type="number" /> <TextField name="settings.outerShell.flowRate" fullWidth floatingLabelText="Flow rate" type="number" />
<p>Inner infill</p> <p>Inner infill</p>
<TextField name="settings.innerInfill.gridSize" fullWidth floatingLabelText="Grid size" type="number" /> <TextField name="settings.innerInfill.precentage" fullWidth floatingLabelText="Percentage" type="number" />
<TextField name="settings.innerInfill.speed" fullWidth floatingLabelText="Speed" type="number" /> <TextField name="settings.innerInfill.speed" fullWidth floatingLabelText="Speed" type="number" />
<TextField name="settings.innerInfill.flowRate" fullWidth floatingLabelText="Flow rate" type="number" /> <TextField name="settings.innerInfill.flowRate" fullWidth floatingLabelText="Flow rate" type="number" />
<p>Outer infill</p> <p>Outer infill</p>

View File

@ -39,7 +39,7 @@ outerShell:
innerInfill: innerInfill:
flowRate: 1.0 flowRate: 1.0
speed: 80.0 speed: 80.0
gridSize: 15.0 precentage: 20.0
outerInfill: outerInfill:
flowRate: 1.0 flowRate: 1.0
speed: 50.0 speed: 50.0

View File

@ -15,7 +15,7 @@ low:
speed: 70.0 speed: 70.0
innerInfill: innerInfill:
speed: 80.0 speed: 80.0
gridSize: 25.0 precentage: 10.0
medium: medium:
title: "Medium" title: "Medium"
layerHeight: .15 layerHeight: .15
@ -33,7 +33,7 @@ medium:
speed: 40.0 speed: 40.0
innerInfill: innerInfill:
speed: 80.0 speed: 80.0
gridSize: 25.0 precentage: 10.0
high: high:
title: "High" title: "High"
thickness: thickness:
@ -51,4 +51,4 @@ high:
speed: 30.0 speed: 30.0
innerInfill: innerInfill:
speed: 70.0 speed: 70.0
gridSize: 10.0 precentage: 20.0

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: { gridSize: infillGridSize }, innerInfill: { precentage: infillPercentage },
thickness: { thickness: {
top: topThickness, top: topThickness,
bottom: bottomThickness bottom: bottomThickness
@ -13,11 +13,11 @@ export default function generateInfills(slices, settings) {
nozzleDiameter nozzleDiameter
} = settings; } = settings;
infillGridSize /= PRECISION; infillPercentage /= 100;
nozzleDiameter /= PRECISION; nozzleDiameter /= PRECISION;
const bottomSkinCount = Math.ceil(bottomThickness/layerHeight); const bidirectionalInfill = infillPercentage < 0.8;
const topSkinCount = Math.ceil(topThickness/layerHeight); const infillGridSize = nozzleDiameter * (bidirectionalInfill ? 2 : 1) / infillPercentage;
const nozzleRadius = nozzleDiameter / 2; const nozzleRadius = nozzleDiameter / 2;
const outerFillTemplateSize = Math.sqrt(2 * Math.pow(nozzleDiameter, 2)); const outerFillTemplateSize = Math.sqrt(2 * Math.pow(nozzleDiameter, 2));
@ -32,6 +32,7 @@ export default function generateInfills(slices, settings) {
} }
for (let i = 0; i < slice.parts.length; i ++) { for (let i = 0; i < slice.parts.length; i ++) {
const even = (layer % 2 === 0);
const part = slice.parts[i]; const part = slice.parts[i];
if (!part.closed) continue; if (!part.closed) continue;
@ -52,14 +53,13 @@ export default function generateInfills(slices, settings) {
if (innerFillArea && innerFillArea.paths.length > 0) { if (innerFillArea && innerFillArea.paths.length > 0) {
const bounds = innerFillArea.shapeBounds(); const bounds = innerFillArea.shapeBounds();
const innerFillTemplate = getFillTemplate(bounds, infillGridSize, true, true); const innerFillTemplate = getFillTemplate(bounds, infillGridSize, bidirectionalInfill || even, bidirectionalInfill || !even);
part.innerFill.join(innerFillTemplate.intersect(innerFillArea)); part.innerFill.join(innerFillTemplate.intersect(innerFillArea));
} }
if (outerFillArea.paths.length > 0) { if (outerFillArea.paths.length > 0) {
const bounds = outerFillArea.shapeBounds(); const bounds = outerFillArea.shapeBounds();
const even = (layer % 2 === 0);
const outerFillTemplate = getFillTemplate(bounds, outerFillTemplateSize, even, !even); const outerFillTemplate = getFillTemplate(bounds, outerFillTemplateSize, even, !even);
part.outerFill.join(outerFillTemplate.intersect(outerFillArea)); part.outerFill.join(outerFillTemplate.intersect(outerFillArea));