diff --git a/modules/workbenches/modeler/features/fillet_tool/docs/index.md b/modules/workbenches/modeler/features/fillet_tool/docs/index.md new file mode 100644 index 00000000..e332fb6d --- /dev/null +++ b/modules/workbenches/modeler/features/fillet_tool/docs/index.md @@ -0,0 +1 @@ +place holder \ No newline at end of file diff --git a/modules/workbenches/modeler/features/fillet_tool/icon.svg b/modules/workbenches/modeler/features/fillet_tool/icon.svg new file mode 100644 index 00000000..78b99920 --- /dev/null +++ b/modules/workbenches/modeler/features/fillet_tool/icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/modules/workbenches/modeler/features/fillet_tool/icon32.png b/modules/workbenches/modeler/features/fillet_tool/icon32.png new file mode 100644 index 00000000..5973e383 Binary files /dev/null and b/modules/workbenches/modeler/features/fillet_tool/icon32.png differ diff --git a/modules/workbenches/modeler/features/fillet_tool/icon96.png b/modules/workbenches/modeler/features/fillet_tool/icon96.png new file mode 100644 index 00000000..4ce9e783 Binary files /dev/null and b/modules/workbenches/modeler/features/fillet_tool/icon96.png differ diff --git a/modules/workbenches/modeler/features/fillet_tool/index.ts b/modules/workbenches/modeler/features/fillet_tool/index.ts new file mode 100644 index 00000000..1f2be71d --- /dev/null +++ b/modules/workbenches/modeler/features/fillet_tool/index.ts @@ -0,0 +1,84 @@ +import { ApplicationContext } from 'context'; +import { MBrepShell } from 'cad/model/mshell'; +import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; +import { occ2brep } from 'cad/occ/occ2models'; +import icon from './icon.svg'; + +export default { + id: 'fillet_tool', + label: 'fillet_tool', + icon, + info: 'fillet_tool', + mutualExclusiveFields: [], + paramsInfo: ({ radius, }) => `(${r(radius)} })`, + schema: { + edgeOperationType: { + type: 'TextField', + defaultValue: "FILLET", + label: 'Operation Type', + children: [ + "Fillet", + "Champher", + "2 Sided Champher", + ], + }, + + edgeSelection: { + type: 'number', + defaultValue: 280, + label: 'Edge Selection' + }, + + radius: { + type: 'number', + defaultValue: 10, + label: 'radius' + }, + }, + + run: ({ edgeOperationType, edgeSelection, radius, }, ctx: ApplicationContext) => { + const oc = ctx.occService.occContext; + + let myBody = new oc.BRepPrimAPI_MakeBox_1(200, 200, 200); + + if (edgeOperationType.toUpperCase() == "FILLET") { + + const mkFillet = new oc.BRepFilletAPI_MakeFillet(myBody.Shape(), oc.ChFi3d_FilletShape.ChFi3d_Rational); + const anEdgeExplorer = new oc.TopExp_Explorer_2(myBody.Shape(), oc.TopAbs_ShapeEnum.TopAbs_EDGE, oc.TopAbs_ShapeEnum.TopAbs_SHAPE); + + const anEdge = oc.TopoDS.Edge_1(anEdgeExplorer.Current()); + + // Add edge to fillet + mkFillet.Add_2(radius, anEdge); + myBody = mkFillet; + + } else if (edgeOperationType.toUpperCase() == "CHAMPHER") { + // BRepFilletAPI_MakeChamfer() + const mkChampher = new oc.BRepFilletAPI_MakeChamfer(myBody.Shape()); + const anEdgeExplorer = new oc.TopExp_Explorer_2(myBody.Shape(), oc.TopAbs_ShapeEnum.TopAbs_EDGE, oc.TopAbs_ShapeEnum.TopAbs_SHAPE); + + const anEdge = oc.TopoDS.Edge_1(anEdgeExplorer.Current()); + + // Add edge to fillet + mkChampher.Add_2(radius, anEdge); + myBody = mkChampher; + } + + + + 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] + }; + }, + +} + diff --git a/modules/workbenches/modeler/index.ts b/modules/workbenches/modeler/index.ts index b3499630..e4fafc40 100644 --- a/modules/workbenches/modeler/index.ts +++ b/modules/workbenches/modeler/index.ts @@ -1,11 +1,11 @@ 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'; import hole_tool from './features/hole_tool'; +import fillet_tool from './features/fillet_tool'; export default { @@ -18,5 +18,6 @@ export default { primitive_sphere, primitive_torus, hole_tool, + fillet_tool, ] } \ No newline at end of file diff --git a/web/app/cad/part/uiConfigPlugin.js b/web/app/cad/part/uiConfigPlugin.js index 8118a9d7..eee5bff5 100644 --- a/web/app/cad/part/uiConfigPlugin.js +++ b/web/app/cad/part/uiConfigPlugin.js @@ -10,7 +10,7 @@ import Expressions from '../expressions/Expressions'; import {SelectionView} from "../dom/components/SelectionView"; import {GrSelect} from "react-icons/gr"; -export const STANDARD_MODE_HEADS_UP_TOOLBAR = ['DATUM_CREATE', 'PLANE', 'EditFace', '-', 'INTERSECTION', 'SUBTRACT', 'UNION', '-', "primitive_cylinder", "primitive_box", "primitive_cone", "primitive_sphere", "primitive_torus", "hole_tool", ]; +export const STANDARD_MODE_HEADS_UP_TOOLBAR = ['DATUM_CREATE', 'PLANE', 'EditFace', '-', "OCC_BOTTLE", '-', "primitive_cylinder", "primitive_box", "primitive_cone", "primitive_sphere", "primitive_torus", "hole_tool", "fillet_tool" ]; export function activate({services, streams}) { streams.ui.controlBars.left.value = ['menu.file', 'menu.craft', 'menu.boolean', 'menu.primitives', 'menu.views', 'Donate', 'GitHub'];