operations under workbenches
|
|
@ -1 +0,0 @@
|
||||||
console.log("Hello World")
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
import extrudeOperation from '../craft/cutExtrude/extrudeOperation';
|
|
||||||
import cutOperation from '../craft/cutExtrude/cutOperation';
|
|
||||||
import planeOperation from '../craft/primitives/simplePlane/simplePlaneOperation';
|
|
||||||
import filletOperation from '../craft/fillet/filletOperation';
|
|
||||||
import revolveOperation from '../craft/revolve/revolveOperation';
|
|
||||||
import createDatumOperation from '../craft/datum/create/createDatumOperation';
|
|
||||||
import moveDatumOperation from '../craft/datum/move/moveDatumOperation';
|
|
||||||
import rotateDatumOperation from '../craft/datum/rotate/rotateDatumOperation';
|
|
||||||
import datumOperation from '../craft/primitives/plane/planeOperation';
|
|
||||||
import boxOperation from '../craft/primitives/box/boxOperation';
|
|
||||||
import sphereOperation from '../craft/primitives/sphere/sphereOperation';
|
|
||||||
import cylinderOperation from '../craft/primitives/cylinder/cylinderOperation';
|
|
||||||
import torusOperation from '../craft/primitives/torus/torusOperation';
|
|
||||||
import coneOperation from '../craft/primitives/cone/coneOperation';
|
|
||||||
import spatialCurveOperation from '../craft/spatialCurve/spatialCurveOperation';
|
|
||||||
import loftOperation from '../craft/loft/loftOperation';
|
|
||||||
import {intersectionOperation, subtractOperation, unionOperation} from '../craft/boolean/booleanOperation';
|
|
||||||
import { loadMDFCommand } from '../mdf/mdf';
|
|
||||||
import { MDF_EXTRUDE_EXAMPLE } from '../mdf/mdfExtrudeExample';
|
|
||||||
import { OCC_BOTTLE_OPERATION } from '3d-party/occ-bottle/bottleOperation';
|
|
||||||
import { primitive_cylinder } from '3d-party/primitive_cylinder/index';
|
|
||||||
import { primitive_box } from '3d-party/primitive_box/index';
|
|
||||||
import { primitive_cone } from '3d-party/primitive_cone/index';
|
|
||||||
//import { primitive_box } from '3d-party/primitive_sphere/index';
|
|
||||||
//import { primitive_box } from '3d-party/primitive_torus/index';
|
|
||||||
|
|
||||||
|
|
||||||
export function activate({services}) {
|
|
||||||
services.operation.registerOperations([
|
|
||||||
planeOperation,
|
|
||||||
boxOperation,
|
|
||||||
// extrudeOperation,
|
|
||||||
loadMDFCommand(MDF_EXTRUDE_EXAMPLE),
|
|
||||||
cutOperation,
|
|
||||||
revolveOperation,
|
|
||||||
filletOperation,
|
|
||||||
createDatumOperation,
|
|
||||||
moveDatumOperation,
|
|
||||||
rotateDatumOperation,
|
|
||||||
datumOperation,
|
|
||||||
sphereOperation,
|
|
||||||
cylinderOperation,
|
|
||||||
torusOperation,
|
|
||||||
coneOperation,
|
|
||||||
spatialCurveOperation,
|
|
||||||
loftOperation,
|
|
||||||
intersectionOperation,
|
|
||||||
subtractOperation,
|
|
||||||
unionOperation,
|
|
||||||
loadMDFCommand(OCC_BOTTLE_OPERATION),
|
|
||||||
loadMDFCommand(primitive_cylinder),
|
|
||||||
loadMDFCommand(primitive_box),
|
|
||||||
loadMDFCommand(primitive_cone),
|
|
||||||
loadMDFCommand(primitive_sphere),
|
|
||||||
//loadMDFCommand(primitive_torus),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
import React, {useMemo} from 'react';
|
import React, {useMemo} from 'react';
|
||||||
|
|
||||||
export function SvgIcon({content, size, ...props}) {
|
export function SvgIcon({content, size, ...props}: {
|
||||||
|
content: string,
|
||||||
|
size?: number|string
|
||||||
|
} & React.HTMLAttributes<HTMLDivElement>) {
|
||||||
|
|
||||||
const className = size&&'icon-'+size;
|
const className = size&&'icon-'+size;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
id: 'EXTRUDE',
|
||||||
|
label: 'Extrude',
|
||||||
|
icon: 'img/cad/extrude',
|
||||||
|
info: 'extrudes 2D sketch',
|
||||||
|
paramsInfo: ({ value }) => `(${r(value)})`,
|
||||||
|
mutualExclusiveFields: ['datumAxisVector', 'edgeVector', 'sketchSegmentVector'],
|
||||||
|
run: (params, ctx) => {
|
||||||
|
return ctx.craftEngine.cutExtrude(false, params);
|
||||||
|
},
|
||||||
|
schema: {
|
||||||
|
value: {
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 50,
|
||||||
|
label: 'height'
|
||||||
|
},
|
||||||
|
wierdField: {
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 50,
|
||||||
|
label: 'weird field'
|
||||||
|
},
|
||||||
|
prism: {
|
||||||
|
type: 'number',
|
||||||
|
min: 0,
|
||||||
|
defaultValue: 1
|
||||||
|
},
|
||||||
|
angle: {
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 0
|
||||||
|
},
|
||||||
|
rotation: {
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 0
|
||||||
|
},
|
||||||
|
face: {
|
||||||
|
type: 'face',
|
||||||
|
initializeBySelection: 0
|
||||||
|
},
|
||||||
|
datumAxisVector: {
|
||||||
|
type: 'datumAxis',
|
||||||
|
optional: true,
|
||||||
|
label: 'datum axis'
|
||||||
|
},
|
||||||
|
edgeVector: {
|
||||||
|
type: 'edge',
|
||||||
|
optional: true,
|
||||||
|
label: 'edge',
|
||||||
|
accept: edge => edge.brepEdge.curve.degree === 1
|
||||||
|
},
|
||||||
|
sketchSegmentVector: {
|
||||||
|
type: 'sketchObject',
|
||||||
|
optional: true,
|
||||||
|
label: 'sketch segment',
|
||||||
|
accept: obj => obj.isSegment
|
||||||
|
},
|
||||||
|
flip: {
|
||||||
|
type: 'boolean',
|
||||||
|
defaultValue: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
10
modules/workbenches/modeler/features/occ-bottle/icon.svg
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 512 512">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path d="m409.1,150.1h-306.2c-11.3,0-20.4,9.1-20.4,20.4v310.1c0,11.3 9.1,20.4 20.4,20.4h306.3c11.3,0 20.4-9.1 20.4-20.4v-310.1c-0.1-11.3-9.2-20.4-20.5-20.4zm-20.4,310.1h-265.4v-269.3h265.4v269.3z"/>
|
||||||
|
<path d="m170,135.9h175c11.3,0 20.4-9.1 20.4-20.4v-84.1c0-11.3-9.1-20.4-20.4-20.4h-175c-11.3,0-20.4,9.1-20.4,20.4v84.1c-0.1,11.3 9.1,20.4 20.4,20.4zm20.4-84.1h134.2v43.3h-134.2v-43.3z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 729 B |
|
|
@ -1,15 +1,18 @@
|
||||||
import { ApplicationContext } from 'context';
|
import { ApplicationContext } from 'context';
|
||||||
import { MBrepShell } from '../../../web/app/cad/model/mshell';
|
import { MBrepShell } from 'cad/model/mshell';
|
||||||
import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper';
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
import { createOCCBottle } from './bottle.occ';
|
import { createOCCBottle } from './bottle.occ';
|
||||||
import { occ2brep } from '../../../web/app/cad/occ/occ2models';
|
import { occ2brep } from 'cad/occ/occ2models';
|
||||||
|
import icon from './icon.svg';
|
||||||
|
|
||||||
export const OCC_BOTTLE_OPERATION = {
|
export default {
|
||||||
id: 'OCC_BOTTLE',
|
id: 'OCC_BOTTLE',
|
||||||
label: 'OCC Bottle',
|
label: 'OCC Bottle',
|
||||||
icon: 'img/cad/extrude',
|
icon,
|
||||||
info: 'create occ bottle',
|
info: 'create occ bottle',
|
||||||
mutualExclusiveFields: [],
|
mutualExclusiveFields: [],
|
||||||
|
|
||||||
|
|
||||||
paramsInfo: ({ width, height, thickness }) => `(${r(width)} ${r(height)} ${r(thickness)})`,
|
paramsInfo: ({ width, height, thickness }) => `(${r(width)} ${r(height)} ${r(thickness)})`,
|
||||||
run: ({ width, height, thickness }, ctx: ApplicationContext) => {
|
run: ({ width, height, thickness }, ctx: ApplicationContext) => {
|
||||||
const occObj = createOCCBottle(width, height, thickness, ctx.occService.occContext);
|
const occObj = createOCCBottle(width, height, thickness, ctx.occService.occContext);
|
||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
|
@ -1,9 +1,9 @@
|
||||||
import { ApplicationContext } from 'context';
|
import { ApplicationContext } from 'context';
|
||||||
import { MBrepShell } from '../../../web/app/cad/model/mshell';
|
import { MBrepShell } from 'cad/model/mshell';
|
||||||
import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper';
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
import { occ2brep } from '../../../web/app/cad/occ/occ2models';
|
import { occ2brep } from 'cad/occ/occ2models';
|
||||||
|
|
||||||
export const primitive_box = {
|
export default {
|
||||||
id: 'primitive_box',
|
id: 'primitive_box',
|
||||||
label: 'primitive_box',
|
label: 'primitive_box',
|
||||||
icon: 'img/cad/extrude',
|
icon: 'img/cad/extrude',
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
|
@ -1,9 +1,9 @@
|
||||||
import { ApplicationContext } from 'context';
|
import { ApplicationContext } from 'context';
|
||||||
import { MBrepShell } from '../../../web/app/cad/model/mshell';
|
import { MBrepShell } from 'cad/model/mshell';
|
||||||
import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper';
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
import { occ2brep } from '../../../web/app/cad/occ/occ2models';
|
import { occ2brep } from 'cad/occ/occ2models';
|
||||||
|
|
||||||
export const primitive_cone = {
|
export default {
|
||||||
id: 'primitive_cone',
|
id: 'primitive_cone',
|
||||||
label: 'primitive_cone',
|
label: 'primitive_cone',
|
||||||
icon: 'img/cad/extrude',
|
icon: 'img/cad/extrude',
|
||||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
|
@ -1,9 +1,9 @@
|
||||||
import { ApplicationContext } from 'context';
|
import { ApplicationContext } from 'context';
|
||||||
import { MBrepShell } from '../../../web/app/cad/model/mshell';
|
import { MBrepShell } from 'cad/model/mshell';
|
||||||
import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper';
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
import { occ2brep } from '../../../web/app/cad/occ/occ2models';
|
import { occ2brep } from 'cad/occ/occ2models';
|
||||||
|
|
||||||
export const primitive_cylinder = {
|
export default {
|
||||||
id: 'primitive_cylinder',
|
id: 'primitive_cylinder',
|
||||||
label: 'primitive_cylinder',
|
label: 'primitive_cylinder',
|
||||||
icon: 'img/cad/extrude',
|
icon: 'img/cad/extrude',
|
||||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
|
|
@ -1,9 +1,9 @@
|
||||||
import { ApplicationContext } from 'context';
|
import { ApplicationContext } from 'context';
|
||||||
import { MBrepShell } from '../../../web/app/cad/model/mshell';
|
import { MBrepShell } from 'cad/model/mshell';
|
||||||
import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper';
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
import { occ2brep } from '../../../web/app/cad/occ/occ2models';
|
import { occ2brep } from 'cad/occ/occ2models';
|
||||||
|
|
||||||
export const primitive_sphere = {
|
export default {
|
||||||
id: 'primitive_sphere',
|
id: 'primitive_sphere',
|
||||||
label: 'primitive_sphere',
|
label: 'primitive_sphere',
|
||||||
icon: 'img/cad/extrude',
|
icon: 'img/cad/extrude',
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
|
@ -1,9 +1,9 @@
|
||||||
import { ApplicationContext } from 'context';
|
import { ApplicationContext } from 'context';
|
||||||
import { MBrepShell } from '../../../web/app/cad/model/mshell';
|
import { MBrepShell } from 'cad/model/mshell';
|
||||||
import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper';
|
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||||
import { occ2brep } from '../../../web/app/cad/occ/occ2models';
|
import { occ2brep } from 'cad/occ/occ2models';
|
||||||
|
|
||||||
export const primitive_torus = {
|
export default {
|
||||||
id: 'primitive_torus',
|
id: 'primitive_torus',
|
||||||
label: 'primitive_torus',
|
label: 'primitive_torus',
|
||||||
icon: 'img/cad/extrude',
|
icon: 'img/cad/extrude',
|
||||||
4
modules/workbenches/modeler/features/registry.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
export default [
|
||||||
|
];
|
||||||
21
modules/workbenches/modeler/index.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
import EXTRUDE from './features/extrude/extrude.operation';
|
||||||
|
import OCC_BOTTLE from './features/occ-bottle';
|
||||||
|
import primitive_box from './features/primitive_box';
|
||||||
|
import primitive_cone from './features/primitive_cone';
|
||||||
|
import primitive_cylinder from './features/primitive_cylinder';
|
||||||
|
import primitive_sphere from './features/primitive_sphere';
|
||||||
|
import primitive_torus from './features/primitive_torus';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
|
||||||
|
workbenchId: 'modeler',
|
||||||
|
features: [
|
||||||
|
EXTRUDE,
|
||||||
|
OCC_BOTTLE,
|
||||||
|
primitive_box,
|
||||||
|
primitive_cone,
|
||||||
|
primitive_cylinder,
|
||||||
|
primitive_sphere,
|
||||||
|
primitive_torus
|
||||||
|
]
|
||||||
|
}
|
||||||
5
modules/workbenches/registry.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import ModelerWorkbench from './modeler';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
ModelerWorkbench
|
||||||
|
]
|
||||||
|
|
@ -125,7 +125,7 @@ export interface OperationDescriptor<R> {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string;
|
||||||
info: string;
|
info: string;
|
||||||
icon: IconType | string;
|
icon: IconType | string | ((props: any) => JSX.Element);
|
||||||
actionParams?: any;
|
actionParams?: any;
|
||||||
run: (request: R, opContext: CoreContext) => OperationResult | Promise<OperationResult>;
|
run: (request: R, opContext: CoreContext) => OperationResult | Promise<OperationResult>;
|
||||||
paramsInfo: (params: R) => string,
|
paramsInfo: (params: R) => string,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { IconType } from "react-icons";
|
||||||
import { OperationResult } from "../craft/craftPlugin";
|
import { OperationResult } from "../craft/craftPlugin";
|
||||||
import { OperationDescriptor } from "../craft/operationPlugin";
|
import { OperationDescriptor } from "../craft/operationPlugin";
|
||||||
import { generateForm } from "./generateForm";
|
import { generateForm } from "./generateForm";
|
||||||
|
import { resolveMDFIcon } from "./mdfIconResolver";
|
||||||
|
|
||||||
|
|
||||||
interface MDFCommand<R> {
|
interface MDFCommand<R> {
|
||||||
|
|
@ -33,7 +34,7 @@ export function loadMDFCommand<R>(mdfCommand: MDFCommand<R>): OperationDescripto
|
||||||
return {
|
return {
|
||||||
id: mdfCommand.id,
|
id: mdfCommand.id,
|
||||||
label: mdfCommand.label,
|
label: mdfCommand.label,
|
||||||
icon: mdfCommand.icon,
|
icon: resolveMDFIcon(mdfCommand.icon),
|
||||||
info: mdfCommand.info,
|
info: mdfCommand.info,
|
||||||
paramsInfo: mdfCommand.paramsInfo,
|
paramsInfo: mdfCommand.paramsInfo,
|
||||||
onParamsUpdate: (params, name, value) => {
|
onParamsUpdate: (params, name, value) => {
|
||||||
|
|
|
||||||
6
web/app/cad/mdf/mdfIconResolver.tsx
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { SvgIcon } from "svg/SvgIcon";
|
||||||
|
|
||||||
|
export function resolveMDFIcon(iconDef: any) {
|
||||||
|
return () => <SvgIcon content={iconDef} />
|
||||||
|
}
|
||||||
|
|
@ -16,21 +16,13 @@ import spatialCurveOperation from '../craft/spatialCurve/spatialCurveOperation';
|
||||||
import loftOperation from '../craft/loft/loftOperation';
|
import loftOperation from '../craft/loft/loftOperation';
|
||||||
import {intersectionOperation, subtractOperation, unionOperation} from '../craft/boolean/booleanOperation';
|
import {intersectionOperation, subtractOperation, unionOperation} from '../craft/boolean/booleanOperation';
|
||||||
import { loadMDFCommand } from '../mdf/mdf';
|
import { loadMDFCommand } from '../mdf/mdf';
|
||||||
import { MDF_EXTRUDE_EXAMPLE } from '../mdf/mdfExtrudeExample';
|
import WorkbenchRegistry from 'workbenches/registry';
|
||||||
import { OCC_BOTTLE_OPERATION } from '3d-party/occ-bottle/bottleOperation';
|
|
||||||
import { primitive_cylinder } from '3d-party/primitive_cylinder/index';
|
|
||||||
import { primitive_box } from '3d-party/primitive_box/index';
|
|
||||||
import { primitive_cone } from '3d-party/primitive_cone/index';
|
|
||||||
import { primitive_sphere } from '3d-party/primitive_sphere/index';
|
|
||||||
import { primitive_torus } from '3d-party/primitive_torus/index';
|
|
||||||
|
|
||||||
|
|
||||||
export function activate({services}) {
|
export function activate({services}) {
|
||||||
services.operation.registerOperations([
|
services.operation.registerOperations([
|
||||||
planeOperation,
|
planeOperation,
|
||||||
boxOperation,
|
boxOperation,
|
||||||
// extrudeOperation,
|
// extrudeOperation,
|
||||||
loadMDFCommand(MDF_EXTRUDE_EXAMPLE),
|
|
||||||
cutOperation,
|
cutOperation,
|
||||||
revolveOperation,
|
revolveOperation,
|
||||||
filletOperation,
|
filletOperation,
|
||||||
|
|
@ -47,11 +39,8 @@ export function activate({services}) {
|
||||||
intersectionOperation,
|
intersectionOperation,
|
||||||
subtractOperation,
|
subtractOperation,
|
||||||
unionOperation,
|
unionOperation,
|
||||||
loadMDFCommand(OCC_BOTTLE_OPERATION),
|
]);
|
||||||
loadMDFCommand(primitive_cylinder),
|
WorkbenchRegistry.forEach(w => {
|
||||||
loadMDFCommand(primitive_box),
|
services.operation.registerOperations(w.features.map(loadMDFCommand));
|
||||||
loadMDFCommand(primitive_cone),
|
});
|
||||||
loadMDFCommand(primitive_sphere),
|
|
||||||
loadMDFCommand(primitive_torus),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||