diff --git a/modules/3d-party/primitive_box/docs/index.md b/modules/3d-party/primitive_box/docs/index.md new file mode 100644 index 00000000..e332fb6d --- /dev/null +++ b/modules/3d-party/primitive_box/docs/index.md @@ -0,0 +1 @@ +place holder \ No newline at end of file diff --git a/modules/3d-party/primitive_box/icon32.png b/modules/3d-party/primitive_box/icon32.png new file mode 100644 index 00000000..5973e383 Binary files /dev/null and b/modules/3d-party/primitive_box/icon32.png differ diff --git a/modules/3d-party/primitive_box/icon96.png b/modules/3d-party/primitive_box/icon96.png new file mode 100644 index 00000000..4ce9e783 Binary files /dev/null and b/modules/3d-party/primitive_box/icon96.png differ diff --git a/modules/3d-party/primitive_box/index.ts b/modules/3d-party/primitive_box/index.ts new file mode 100644 index 00000000..0699e39a --- /dev/null +++ b/modules/3d-party/primitive_box/index.ts @@ -0,0 +1,56 @@ +import { ApplicationContext } from 'context'; +import { MBrepShell } from '../../../web/app/cad/model/mshell'; +import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper'; +import { occ2brep } from '../../../web/app/cad/occ/occ2models'; + +export const primitive_box = { + id: 'primitive_box', + label: 'primitive_box', + icon: 'img/cad/extrude', + info: 'primitive_box', + mutualExclusiveFields: [], + paramsInfo: ({ boxX, boxY, boxZ }) => `(${r(boxX)} ${r(boxY)}) ${r(boxZ)})`, + run: ({ boxX, boxY, boxZ }, ctx: ApplicationContext) => { + //const occObj = createCylinder(diameter, height, ctx.occService.occContext); + const oc = ctx.occService.occContext; + + //const myLocation = new oc.gp_Pnt_3(0, 0, 0); + //const cylinderCenterline = oc.gp.DZ(); + //const cylinderOrientationAndLocation = new oc.gp_Ax2_3(myLocation, cylinderCenterline); + console.log(boxX, boxY, boxZ, oc.BRepPrimAPI_MakeBox_1(boxX, boxY, boxZ)) + + let myBody = new oc.BRepPrimAPI_MakeBox_1(boxX, boxY, boxZ ); + //let myBody = new oc.BRepPrimAPI_Make + + const aRes = new oc.TopoDS_Compound(); + const aBuilder = new oc.BRep_Builder(); + aBuilder.MakeCompound(aRes); + aBuilder.Add(aRes, myBody.Shape()); + + + + const mobject = new MBrepShell(occ2brep(aRes, ctx.occService.occContext)); + return { + consumed: [], + created: [mobject] + }; + }, + schema: { + boxX: { + type: 'number', + defaultValue: 200, + label: 'X' + }, + boxY: { + type: 'number', + defaultValue: 280, + label: 'Y' + }, + BoxZ: { + type: 'number', + defaultValue: 280, + label: 'Z' + }, + } +} + diff --git a/modules/3d-party/primitive_cone/docs/index.md b/modules/3d-party/primitive_cone/docs/index.md new file mode 100644 index 00000000..e332fb6d --- /dev/null +++ b/modules/3d-party/primitive_cone/docs/index.md @@ -0,0 +1 @@ +place holder \ No newline at end of file diff --git a/modules/3d-party/primitive_cone/icon32.png b/modules/3d-party/primitive_cone/icon32.png new file mode 100644 index 00000000..cb44dec0 Binary files /dev/null and b/modules/3d-party/primitive_cone/icon32.png differ diff --git a/modules/3d-party/primitive_cone/icon96.png b/modules/3d-party/primitive_cone/icon96.png new file mode 100644 index 00000000..d9b6ebab Binary files /dev/null and b/modules/3d-party/primitive_cone/icon96.png differ diff --git a/modules/3d-party/primitive_cone/index.ts b/modules/3d-party/primitive_cone/index.ts new file mode 100644 index 00000000..40845ef9 --- /dev/null +++ b/modules/3d-party/primitive_cone/index.ts @@ -0,0 +1,50 @@ +import { ApplicationContext } from 'context'; +import { MBrepShell } from '../../../web/app/cad/model/mshell'; +import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper'; +import { occ2brep } from '../../../web/app/cad/occ/occ2models'; + +export const primitive_cone = { + id: 'primitive_cone', + label: 'primitive_cone', + icon: 'img/cad/extrude', + info: 'primitive_cone', + mutualExclusiveFields: [], + paramsInfo: ({ diameter, height }) => `(${r(diameter)} ${r(height)})`, + run: ({ diameter, height, }, ctx: ApplicationContext) => { + //const occObj = createcone(diameter, height, ctx.occService.occContext); + const oc = ctx.occService.occContext; + + const myLocation = new oc.gp_Pnt_3(0, 0, 0); + const coneCenterline = oc.gp.DZ(); + const coneOrientationAndLocation = new oc.gp_Ax2_3(myLocation, coneCenterline); + + let myBody = new oc.BRepPrimAPI_MakeCone_1(10,20,100); + //let myBody = new oc.BRepPrimAPI_Make + + const aRes = new oc.TopoDS_Compound(); + const aBuilder = new oc.BRep_Builder(); + aBuilder.MakeCompound(aRes); + aBuilder.Add(aRes, myBody.Shape()); + + + + const mobject = new MBrepShell(occ2brep(aRes, ctx.occService.occContext)); + return { + consumed: [], + created: [mobject] + }; + }, + schema: { + diameter: { + type: 'number', + defaultValue: 200, + label: 'diameter' + }, + height: { + type: 'number', + defaultValue: 280, + label: 'height' + }, + } +} + diff --git a/modules/3d-party/primitive_cylinder/docs/index.md b/modules/3d-party/primitive_cylinder/docs/index.md new file mode 100644 index 00000000..e332fb6d --- /dev/null +++ b/modules/3d-party/primitive_cylinder/docs/index.md @@ -0,0 +1 @@ +place holder \ No newline at end of file diff --git a/modules/3d-party/primitive_cylinder/icon32.png b/modules/3d-party/primitive_cylinder/icon32.png new file mode 100644 index 00000000..45ca5ba6 Binary files /dev/null and b/modules/3d-party/primitive_cylinder/icon32.png differ diff --git a/modules/3d-party/primitive_cylinder/icon96.png b/modules/3d-party/primitive_cylinder/icon96.png new file mode 100644 index 00000000..e8a21cdd Binary files /dev/null and b/modules/3d-party/primitive_cylinder/icon96.png differ diff --git a/modules/3d-party/primitive_cylinder/index.ts b/modules/3d-party/primitive_cylinder/index.ts new file mode 100644 index 00000000..9ceb1f9f --- /dev/null +++ b/modules/3d-party/primitive_cylinder/index.ts @@ -0,0 +1,51 @@ +import { ApplicationContext } from 'context'; +import { MBrepShell } from '../../../web/app/cad/model/mshell'; +import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper'; +import { occ2brep } from '../../../web/app/cad/occ/occ2models'; + +export const primitive_cylinder = { + id: 'primitive_cylinder', + label: 'primitive_cylinder', + icon: 'img/cad/extrude', + info: 'primitive_cylinder', + mutualExclusiveFields: [], + paramsInfo: ({ diameter, height }) => `(${r(diameter)} ${r(height)})`, + run: ({ diameter, height, }, ctx: ApplicationContext) => { + //const occObj = createCylinder(diameter, height, ctx.occService.occContext); + const oc = ctx.occService.occContext; + + const myLocation = new oc.gp_Pnt_3(0, 0, 0); + const cylinderCenterline = oc.gp.DZ(); + const cylinderOrientationAndLocation = new oc.gp_Ax2_3(myLocation, cylinderCenterline); + + + let myBody = new oc.BRepPrimAPI_MakeCylinder_3(cylinderOrientationAndLocation, diameter, height,); + //let myBody = new oc.BRepPrimAPI_Make + + const aRes = new oc.TopoDS_Compound(); + const aBuilder = new oc.BRep_Builder(); + aBuilder.MakeCompound(aRes); + aBuilder.Add(aRes, myBody.Shape()); + + + + const mobject = new MBrepShell(occ2brep(aRes, ctx.occService.occContext)); + return { + consumed: [], + created: [mobject] + }; + }, + schema: { + diameter: { + type: 'number', + defaultValue: 200, + label: 'diameter' + }, + height: { + type: 'number', + defaultValue: 280, + label: 'height' + }, + } +} + diff --git a/modules/3d-party/primitive_cylinder/partOperationsPlugin.js b/modules/3d-party/primitive_cylinder/partOperationsPlugin.js new file mode 100644 index 00000000..d211c030 --- /dev/null +++ b/modules/3d-party/primitive_cylinder/partOperationsPlugin.js @@ -0,0 +1,57 @@ +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), + ]) +} \ No newline at end of file diff --git a/modules/3d-party/primitive_sphere/docs/index.md b/modules/3d-party/primitive_sphere/docs/index.md new file mode 100644 index 00000000..e332fb6d --- /dev/null +++ b/modules/3d-party/primitive_sphere/docs/index.md @@ -0,0 +1 @@ +place holder \ No newline at end of file diff --git a/modules/3d-party/primitive_sphere/icon32.png b/modules/3d-party/primitive_sphere/icon32.png new file mode 100644 index 00000000..43a52e2c Binary files /dev/null and b/modules/3d-party/primitive_sphere/icon32.png differ diff --git a/modules/3d-party/primitive_sphere/icon96.png b/modules/3d-party/primitive_sphere/icon96.png new file mode 100644 index 00000000..f9bd1874 Binary files /dev/null and b/modules/3d-party/primitive_sphere/icon96.png differ diff --git a/modules/3d-party/primitive_sphere/index.ts b/modules/3d-party/primitive_sphere/index.ts new file mode 100644 index 00000000..b23202e9 --- /dev/null +++ b/modules/3d-party/primitive_sphere/index.ts @@ -0,0 +1,46 @@ +import { ApplicationContext } from 'context'; +import { MBrepShell } from '../../../web/app/cad/model/mshell'; +import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper'; +import { occ2brep } from '../../../web/app/cad/occ/occ2models'; + +export const primitive_sphere = { + id: 'primitive_sphere', + label: 'primitive_sphere', + icon: 'img/cad/extrude', + info: 'primitive_sphere', + mutualExclusiveFields: [], + paramsInfo: ({ diameter }) => `(${r(diameter)} )`, + run: ({ diameter, }, ctx: ApplicationContext) => { + + const oc = ctx.occService.occContext; + + const myLocation = new oc.gp_Pnt_3(0, 0, 0); + const sphereCenterline = oc.gp.DZ(); + const sphereOrientationAndLocation = new oc.gp_Ax2_3(myLocation, sphereCenterline); + + + let myBody = new oc.BRepPrimAPI_MakeSphere_1(diameter); + //let myBody = new oc.BRepPrimAPI_Make + + const aRes = new oc.TopoDS_Compound(); + const aBuilder = new oc.BRep_Builder(); + aBuilder.MakeCompound(aRes); + aBuilder.Add(aRes, myBody.Shape()); + + + + const mobject = new MBrepShell(occ2brep(aRes, ctx.occService.occContext)); + return { + consumed: [], + created: [mobject] + }; + }, + schema: { + diameter: { + type: 'number', + defaultValue: 200, + label: 'diameter' + }, + } +} + diff --git a/modules/3d-party/primitive_torus/docs/index.md b/modules/3d-party/primitive_torus/docs/index.md new file mode 100644 index 00000000..e332fb6d --- /dev/null +++ b/modules/3d-party/primitive_torus/docs/index.md @@ -0,0 +1 @@ +place holder \ No newline at end of file diff --git a/modules/3d-party/primitive_torus/icon32.png b/modules/3d-party/primitive_torus/icon32.png new file mode 100644 index 00000000..8c7438e0 Binary files /dev/null and b/modules/3d-party/primitive_torus/icon32.png differ diff --git a/modules/3d-party/primitive_torus/icon96.png b/modules/3d-party/primitive_torus/icon96.png new file mode 100644 index 00000000..d6bb4e8c Binary files /dev/null and b/modules/3d-party/primitive_torus/icon96.png differ diff --git a/modules/3d-party/primitive_torus/index.ts b/modules/3d-party/primitive_torus/index.ts new file mode 100644 index 00000000..526415a1 --- /dev/null +++ b/modules/3d-party/primitive_torus/index.ts @@ -0,0 +1,51 @@ +import { ApplicationContext } from 'context'; +import { MBrepShell } from '../../../web/app/cad/model/mshell'; +import { roundValueForPresentation as r } from '../../../web/app/cad/craft/operationHelper'; +import { occ2brep } from '../../../web/app/cad/occ/occ2models'; + +export const primitive_torus = { + id: 'primitive_torus', + label: 'primitive_torus', + icon: 'img/cad/extrude', + info: 'primitive_torus', + mutualExclusiveFields: [], + paramsInfo: ({ radius, tubeRadius }) => `(${r(radius)} ${r(tubeRadius)} )`, + run: ({ radius, tubeRadius }, ctx: ApplicationContext) => { + + const oc = ctx.occService.occContext; + + const myLocation = new oc.gp_Pnt_3(0, 0, 0); + const torusCenterline = oc.gp.DZ(); + const torusOrientationAndLocation = new oc.gp_Ax2_3(myLocation, torusCenterline); + + + let myBody = new oc.BRepPrimAPI_MakeTorus_1(radius, tubeRadius); + //let myBody = new oc.BRepPrimAPI_Make + + const aRes = new oc.TopoDS_Compound(); + const aBuilder = new oc.BRep_Builder(); + aBuilder.MakeCompound(aRes); + aBuilder.Add(aRes, myBody.Shape()); + + + + const mobject = new MBrepShell(occ2brep(aRes, ctx.occService.occContext)); + return { + consumed: [], + created: [mobject] + }; + }, + schema: { + radius : { + type: 'number', + defaultValue: 200, + label: 'radius' + }, + tubeRadius: { + type: 'number', + defaultValue: 50, + label: 'tube radius' + }, + } +} + diff --git a/package-lock.json b/package-lock.json index 34c80665..ca5c4454 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,7 +73,6 @@ "integrity": "sha512-XXLgAm6LBbaNxaGhMAznXXaxtCWfuv6PIDJ9Alsy9JYTOh+j2jJz+L/162kkfU1j/pTSxK1xGmlwI4pdIMkoag==", "dev": true, "dependencies": { - "chokidar": "^2.1.8", "commander": "^4.0.1", "convert-source-map": "^1.1.0", "fs-readdir-recursive": "^1.1.0", @@ -3327,7 +3326,6 @@ "anymatch": "^2.0.0", "async-each": "^1.0.1", "braces": "^2.3.2", - "fsevents": "^1.2.7", "glob-parent": "^3.1.0", "inherits": "^2.0.3", "is-binary-path": "^1.0.0", @@ -8544,12 +8542,9 @@ "clone": "^2.1.2", "errno": "^0.1.1", "graceful-fs": "^4.1.2", - "image-size": "~0.5.0", "mime": "^1.4.1", "mkdirp": "^0.5.0", "promise": "^7.1.1", - "request": "^2.83.0", - "source-map": "~0.6.0", "tslib": "^1.10.0" }, "bin": { diff --git a/web/app/cad/part/menuConfig.js b/web/app/cad/part/menuConfig.js index 683b58b1..7188790d 100644 --- a/web/app/cad/part/menuConfig.js +++ b/web/app/cad/part/menuConfig.js @@ -16,7 +16,7 @@ export default [ label: 'add', cssIcons: ['cube'], info: 'set of available solid creation operations', - actions: ['PLANE', 'BOX', 'SPHERE', 'CONE', 'CYLINDER', 'TORUS'] + actions: ['PLANE', "primitive_cylinder", "primitive_box", "primitive_cone", "primitive_sphere", "primitive_torus"] }, { id: 'views', diff --git a/web/app/cad/part/partOperationsPlugin.js b/web/app/cad/part/partOperationsPlugin.js index 9ae417b5..adb6c11f 100644 --- a/web/app/cad/part/partOperationsPlugin.js +++ b/web/app/cad/part/partOperationsPlugin.js @@ -18,6 +18,11 @@ import {intersectionOperation, subtractOperation, unionOperation} from '../craft 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_sphere } from '3d-party/primitive_sphere/index'; +import { primitive_torus } from '3d-party/primitive_torus/index'; export function activate({services}) { @@ -42,6 +47,11 @@ export function activate({services}) { intersectionOperation, subtractOperation, unionOperation, - loadMDFCommand(OCC_BOTTLE_OPERATION) + loadMDFCommand(OCC_BOTTLE_OPERATION), + loadMDFCommand(primitive_cylinder), + loadMDFCommand(primitive_box), + loadMDFCommand(primitive_cone), + loadMDFCommand(primitive_sphere), + loadMDFCommand(primitive_torus), ]) } \ No newline at end of file diff --git a/web/app/cad/part/uiConfigPlugin.js b/web/app/cad/part/uiConfigPlugin.js index 726e3ced..1e5fffde 100644 --- a/web/app/cad/part/uiConfigPlugin.js +++ b/web/app/cad/part/uiConfigPlugin.js @@ -12,7 +12,7 @@ import {GrSelect} from "react-icons/gr"; export const STANDARD_MODE_HEADS_UP_TOOLBAR = ['DATUM_CREATE', 'PLANE', 'EditFace', 'EXTRUDE', 'CUT', 'REVOLVE', 'LOFT', '-', 'FILLET', '-', 'INTERSECTION', 'SUBTRACT', 'UNION', '-', 'IMPORT_PART', "IMPORT_STEP_FILE", "IMPORT_STEP_LOCAL_FILE", - "ExportFaceToDXF", 'OCC_BOTTLE']; + "ExportFaceToDXF", 'OCC_BOTTLE', "primitive_cylinder", "primitive_box", "primitive_cone", "primitive_sphere","primitive_torus"]; export function activate({services, streams}) { streams.ui.controlBars.left.value = ['menu.file', 'menu.craft', 'menu.boolean', 'menu.primitives', 'menu.views', 'Donate', 'GitHub'];