mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 19:43:48 +01:00
move brim code to separate function
This commit is contained in:
parent
78052f79e8
commit
492a09cce9
18
src/sliceActions/addBrim.js
Normal file
18
src/sliceActions/addBrim.js
Normal 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);
|
||||||
|
}
|
@ -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 ++) {
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user