add all boolean operations to revolve operation

This commit is contained in:
Val Erastov 2018-12-15 01:40:48 -08:00
parent f4a67e91b0
commit 76b154362e
4 changed files with 18 additions and 14 deletions

View file

@ -23,9 +23,6 @@ export function activate(ctx) {
loadWasm(ctx);
ctx.services.operation.handlers.push(operationHandler);
function shellsToPointers(shells) {
return shells.filter(managedByE0).map(m => m.brepShell.data.externals.ptr);
}
function booleanBasedOperation(engineParams, params, impl) {
engineParams.deflection = DEFLECTION;
if (params.boolean && BOOLEAN_TYPES[params.boolean.type] > 0) {
@ -105,6 +102,10 @@ export function activate(ctx) {
}
}
function shellsToPointers(shells) {
return shells.filter(managedByE0).map(m => m.brepShell.data.externals.ptr);
}
function writeCsys(csys, swapToY) {
return {
origin: csys.origin.data(),
@ -133,12 +134,6 @@ function operationHandler(id, request, services) {
}
case 'REVOLVE': {
let {request: engineReq, face} = createRevolveCommand(request, services);
if (managedByE0(face.shell)) {
engineReq.boolean = {
type: request.subtract ? BOOLEAN_TYPES.SUBTRACT : BOOLEAN_TYPES.UNION,
operand: face.shell.brepShell.data.externals.ptr
}
}
let data = callEngine(engineReq, Module._SPI_revolve);
return singleShellRespone(face.shell, data);
}
@ -252,7 +247,7 @@ function createRevolveCommand(request, {cadRegistry, sketcher}) {
let axisOrigin = tr._apply3(pivot.a.data());
let axisDir = vec._normalize(vec._sub(tr._apply3(pivot.b.data()), axisOrigin))
return {
let res = {
face,
request: {
axisOrigin,
@ -263,6 +258,13 @@ function createRevolveCommand(request, {cadRegistry, sketcher}) {
deflection: DEFLECTION
}
};
if (managedByE0(face.shell) && request.boolean && BOOLEAN_TYPES[request.boolean] > 0) {
res.request.boolean = {
type: BOOLEAN_TYPES[request.boolean],
operand: face.shell.brepShell.data.externals.ptr
}
}
return res;
}

View file

@ -43,7 +43,7 @@ export default function materializeParams(services, params, schema, result, erro
}
} else if (md.type === 'enum') {
if (md.values.indexOf(value) === -1) {
errors.push({path: [...parentPath, field], message: 'invalid value'});
value = md.defaultValue || md.values[0];
}
} else if (isEntityType(md.type)) {
if (typeof value !== 'string') {

View file

@ -2,6 +2,7 @@ import React from 'react';
import {CheckboxField, NumberField} from '../wizard/components/form/Fields';
import {Group} from '../wizard/components/form/Form';
import Entity from '../wizard/components/form/Entity';
import BooleanChoice from '../wizard/components/form/BooleanChioce';
export default function RevolveForm() {
@ -9,6 +10,6 @@ export default function RevolveForm() {
<NumberField name='angle' />
<Entity name='face' entity='face' />
<Entity name='axis' entity='sketchObject' />
<CheckboxField name='cut' />
<BooleanChoice name='boolean' />
</Group>;
}

View file

@ -13,7 +13,8 @@ export default {
},
boolean: {
type: 'enum',
values: ['union', 'subtract', 'intersect', 'none'],
defaultValue: 'none'
values: ['INTERSECT', 'SUBTRACT', 'UNION'],
defaultValue: 'UNION',
optional: true
}
}