move brim code to separate function

This commit is contained in:
casperlamboo 2016-05-06 19:52:31 +02:00
parent c8150c3bf7
commit e16a5dda90
3 changed files with 21 additions and 12 deletions

View File

@ -0,0 +1,18 @@
import THREE from 'three.js';
import { PRECISION } from '../constants.js';
const offsetOptions = {
jointType: 'jtSquare',
endType: 'etClosedPolygon',
miterLimit: 2.0,
roundPrecision: 0.25
};
export default function addBrim(slices, settings) {
console.log('add brim');
const brimOffset = settings.config['brimOffset'] / PRECISION;
const fistLayer = slices[0];
fistLayer.brim = fistLayer.getOutline().offset(brimOffset, offsetOptions);
}

View File

@ -1,27 +1,15 @@
import THREE from 'three.js'; import THREE from 'three.js';
import { PRECISION } from '../constants.js'; import { PRECISION } from '../constants.js';
const offsetOptions = {
jointType: 'jtSquare',
endType: 'etClosedPolygon',
miterLimit: 2.0,
roundPrecision: 0.25
};
export default function optimizePaths(slices, settings) { export default function optimizePaths(slices, settings) {
console.log("opimize paths"); console.log("opimize paths");
const brimOffset = settings.config["brimOffset"] / PRECISION;
const start = new THREE.Vector2(0, 0); const start = new THREE.Vector2(0, 0);
for (let layer = 0; layer < slices.length; layer ++) { for (let layer = 0; layer < slices.length; layer ++) {
const slice = slices[layer]; const slice = slices[layer];
if (layer === 0) {
slice.brim = slice.getOutline().offset(brimOffset, offsetOptions);
}
// start = slice.optimizePaths(start); // start = slice.optimizePaths(start);
for (let i = 0; i < slice.parts.length; i ++) { for (let i = 0; i < slice.parts.length; i ++) {

View File

@ -6,6 +6,7 @@ import generateInfills from './sliceActions/generateInfills.js';
import generateInnerLines from './sliceActions/generateInnerLines.js'; import generateInnerLines from './sliceActions/generateInnerLines.js';
import generateSupport from './sliceActions/generateSupport.js'; import generateSupport from './sliceActions/generateSupport.js';
import intersectionsToShapes from './sliceActions/intersectionsToShapes.js'; import intersectionsToShapes from './sliceActions/intersectionsToShapes.js';
import addBrim from './sliceActions/addBrim.js';
import optimizePaths from './sliceActions/optimizePaths.js'; import optimizePaths from './sliceActions/optimizePaths.js';
import shapesToSlices from './sliceActions/shapesToSlices.js'; import shapesToSlices from './sliceActions/shapesToSlices.js';
import slicesToGCode from './sliceActions/slicesToGCode.js'; import slicesToGCode from './sliceActions/slicesToGCode.js';
@ -96,6 +97,8 @@ export default class extends EventDispatcher {
this._updateProgress(settings); this._updateProgress(settings);
} }
addBrim(slices, settings);
optimizePaths(slices, settings); optimizePaths(slices, settings);
this.progress.optimizedPaths = true; this.progress.optimizedPaths = true;
this._updateProgress(settings); this._updateProgress(settings);