mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 08:25:19 +01:00
Added fillet tool
This commit is contained in:
parent
264c995848
commit
6c96cf1c59
7 changed files with 98 additions and 2 deletions
|
|
@ -0,0 +1 @@
|
|||
place holder
|
||||
10
modules/workbenches/modeler/features/fillet_tool/icon.svg
Normal file
10
modules/workbenches/modeler/features/fillet_tool/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 |
BIN
modules/workbenches/modeler/features/fillet_tool/icon32.png
Normal file
BIN
modules/workbenches/modeler/features/fillet_tool/icon32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
modules/workbenches/modeler/features/fillet_tool/icon96.png
Normal file
BIN
modules/workbenches/modeler/features/fillet_tool/icon96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
84
modules/workbenches/modeler/features/fillet_tool/index.ts
Normal file
84
modules/workbenches/modeler/features/fillet_tool/index.ts
Normal file
|
|
@ -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]
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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,
|
||||
]
|
||||
}
|
||||
|
|
@ -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'];
|
||||
|
|
|
|||
Loading…
Reference in a new issue