From 492a09cce9cec1f5bc8cc259d540f11f0ff86f17 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Fri, 6 May 2016 19:52:31 +0200 Subject: [PATCH] move brim code to separate function --- src/sliceActions/addBrim.js | 18 ++++++++++++++++++ src/sliceActions/optimizePaths.js | 12 ------------ src/slicer.js | 3 +++ 3 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 src/sliceActions/addBrim.js diff --git a/src/sliceActions/addBrim.js b/src/sliceActions/addBrim.js new file mode 100644 index 0000000..a39e34e --- /dev/null +++ b/src/sliceActions/addBrim.js @@ -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); +} diff --git a/src/sliceActions/optimizePaths.js b/src/sliceActions/optimizePaths.js index 2c873e5..40e9878 100644 --- a/src/sliceActions/optimizePaths.js +++ b/src/sliceActions/optimizePaths.js @@ -1,27 +1,15 @@ 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 optimizePaths(slices, settings) { console.log("opimize paths"); - const brimOffset = settings.config["brimOffset"] / PRECISION; - const start = new THREE.Vector2(0, 0); for (let layer = 0; layer < slices.length; layer ++) { const slice = slices[layer]; - if (layer === 0) { - slice.brim = slice.getOutline().offset(brimOffset, offsetOptions); - } - // start = slice.optimizePaths(start); for (let i = 0; i < slice.parts.length; i ++) { diff --git a/src/slicer.js b/src/slicer.js index 09b4fcc..6b3f303 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -6,6 +6,7 @@ import generateInfills from './sliceActions/generateInfills.js'; import generateInnerLines from './sliceActions/generateInnerLines.js'; import generateSupport from './sliceActions/generateSupport.js'; import intersectionsToShapes from './sliceActions/intersectionsToShapes.js'; +import addBrim from './sliceActions/addBrim.js'; import optimizePaths from './sliceActions/optimizePaths.js'; import shapesToSlices from './sliceActions/shapesToSlices.js'; import slicesToGCode from './sliceActions/slicesToGCode.js'; @@ -96,6 +97,8 @@ export default class extends EventDispatcher { this._updateProgress(settings); } + addBrim(slices, settings); + optimizePaths(slices, settings); this.progress.optimizedPaths = true; this._updateProgress(settings);