Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/operation-diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const hide = [

const types = {
'Laser Cut': { show: ['LaserCut'] },
'Laser Cut (unoptimized)': { show: ['LaserCut'] },
'Laser Cut Inside': { show: ['LaserCutInside', 'laserDia'] },
'Laser Cut Outside': { show: ['LaserCutOutside', 'laserDia'] },
'Laser Fill Path': { show: ['LaserFill', 'lineSpace'] },
Expand Down
1 change: 1 addition & 0 deletions src/components/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ const tabFields = [

export const OPERATION_TYPES = {
'Laser Cut': { allowTabs: true, tabFields: false, fields: ['name', 'filterFillColor', 'filterStrokeColor', 'laserPower', 'passes', 'passDepth', 'startHeight', 'cutRate', 'useA', 'aAxisDiameter', 'useBlower', 'segmentLength', ...OPERATION_GROUPS.Macros.fields] },
'Laser Cut (unoptimized)': { allowTabs: true, tabFields: false, fields: ['name', 'filterFillColor', 'filterStrokeColor', 'laserPower', 'passes', 'passDepth', 'startHeight', 'cutRate', 'useA', 'aAxisDiameter', 'useBlower', 'segmentLength', ...OPERATION_GROUPS.Macros.fields] },
'Laser Cut Inside': { allowTabs: true, tabFields: false, fields: ['name', 'filterFillColor', 'filterStrokeColor', 'laserDiameter', 'laserPower', 'margin', 'passes', 'passDepth', 'startHeight', 'cutRate', 'useA', 'aAxisDiameter', 'useBlower', 'segmentLength', ...OPERATION_GROUPS.Macros.fields] },
'Laser Cut Outside': { allowTabs: true, tabFields: false, fields: ['name', 'filterFillColor', 'filterStrokeColor', 'laserDiameter', 'laserPower', 'margin', 'passes', 'passDepth', 'startHeight', 'cutRate', 'useA', 'aAxisDiameter', 'useBlower', 'segmentLength', ...OPERATION_GROUPS.Macros.fields] },
'Laser Fill Path': { allowTabs: false, tabFields: false, fields: ['name', 'filterFillColor', 'filterStrokeColor', 'lineDistance', 'lineAngle', 'laserPower', 'margin', 'passes', 'passDepth', 'startHeight', 'cutRate', 'useA', 'aAxisDiameter', 'useBlower', ...OPERATION_GROUPS.Macros.fields] },
Expand Down
4 changes: 3 additions & 1 deletion src/lib/cam-gcode-laser-cut.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function getLaserCutGcode(props) {
export function getLaserCutGcodeFromOp(settings, opIndex, op, geometry, openGeometry, tabGeometry, showAlert, done, progress) {
let ok = true;

if (op.type !== 'Laser Cut' && op.type !== 'Laser Fill Path') {
if (op.type !== 'Laser Cut' && op.type !== 'Laser Cut (unoptimized)' && op.type !== 'Laser Fill Path') {
if (op.laserDiameter <= 0) {
showAlert("Laser Diameter must be greater than 0", "danger");
ok = false;
Expand Down Expand Up @@ -209,6 +209,8 @@ export function getLaserCutGcodeFromOp(settings, opIndex, op, geometry, openGeom
let camPaths = [];
if (op.type === 'Laser Cut') {
camPaths = cut(geometry, openGeometry, false);
} else if (op.type === 'Laser Cut (unoptimized)') {
camPaths = cut(geometry, openGeometry, false, false);
} else if (op.type === 'Laser Cut Inside') {
if (op.margin)
geometry = offset(geometry, -op.margin * mmToClipperScale);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cam-gcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function getGcode(settings, documents, operations, documentCacheHolder, s
.then((preflight) => {
let { geometry, openGeometry, tabGeometry, filteredDocIds, docsWithImages } = preflight;
console.log('Queueing Worker: ' + op.type + "->" + opIndex);
if (op.type === 'Laser Cut' || op.type === 'Laser Cut Inside' || op.type === 'Laser Cut Outside' || op.type === 'Laser Fill Path') {
if (op.type === 'Laser Cut' || op.type === 'Laser Cut (unoptimized)' || op.type === 'Laser Cut Inside' || op.type === 'Laser Cut Outside' || op.type === 'Laser Fill Path') {
laserOps = true;
if (startCode === "") startCode = settings.gcodeStart;
if (endCode === "") endCode = settings.gcodeEnd;
Expand Down
12 changes: 7 additions & 5 deletions src/lib/cam.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function closeClipperPaths(paths) {
// Try to merge paths. A merged path doesn't cross outside of bounds. Returns array of CamPath.
// If paths contains both open and closed paths, then the closed paths must be before the open
// paths within the array.
function mergePaths(bounds, paths) {
function mergePaths(bounds, paths, optimized) {
if (paths.length === 0)
return [];

Expand Down Expand Up @@ -117,13 +117,13 @@ function mergePaths(bounds, paths) {
paths[closestPathIndex] = [];
numLeft -= 1;
let needNew;
if (pathIsClosed(path)) {
if (pathIsClosed(path) && optimized) {
needNew = crosses(bounds, currentPoint, path[closestPointIndex]);
path = path.slice(closestPointIndex, path.length).concat(path.slice(1, closestPointIndex));
path.push(path[0]);
} else {
needNew = true;
if (closestReverse) {
if (closestReverse && optimized) {
path = path.slice();
path.reverse();
}
Expand Down Expand Up @@ -225,7 +225,7 @@ export function insideOutside(geometry, cutterDia, isInside, width, stepover, cl

// Compute paths for cut operation on Clipper geometry. Returns array
// of CamPath.
export function cut(geometry, openGeometry, climb) {
export function cut(geometry, openGeometry, climb, optimized = true) {
let allPaths = [];
for (let i = 0; i < geometry.length; ++i) {
let path = geometry[i].slice(0);
Expand All @@ -236,7 +236,9 @@ export function cut(geometry, openGeometry, climb) {
}
for (let path of openGeometry)
allPaths.push(path.slice());
let result = mergePaths(null, allPaths);

let result = mergePaths(null, allPaths, optimized);

for (let i = 0; i < result.length; ++i)
result[i].safeToClose = pathIsClosed(result[i].path);
return result;
Expand Down
4 changes: 2 additions & 2 deletions src/reducers/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { getParentIds, object, objectArray } from '../reducers/object'

import arrayMove from 'array-move'
import { arrayMoveImmutable } from 'array-move'

import { GlobalStore } from '../index';

Expand Down Expand Up @@ -147,7 +147,7 @@ export const operations = (state, action) => {
newIndex = 0;
if (newIndex > state.length - 1)
newIndex = state.length - 1;
return arrayMove(state.slice(), index, newIndex);
return arrayMoveImmutable(state.slice(), index, newIndex);
case 'OPERATION_SET_ATTRS':
if (action.payload.attrs.expanded)
state = state.map(op => ({ ...op, expanded: op.id === action.payload.id }));
Expand Down