implimented multi body fillet and champher

This commit is contained in:
Mike Molinari 2022-02-15 00:03:57 +00:00 committed by Val Erastov
parent 1fe387ba66
commit 0c6458cf76

View file

@ -4,11 +4,11 @@ import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
import { occ2brep } from 'cad/occ/occ2models';
import icon32 from './icon32.png';
import icon96 from './icon96.png';
import {EntityKind} from "cad/model/entities";
import { EntityKind } from "cad/model/entities";
export default {
id: 'fillet_tool',
label: 'fillet_tool',
label: 'Fillet/Chapher',
icon: {
iconSet: {
medium: {
@ -21,16 +21,25 @@ export default {
}
},
},
info: 'fillet_tool',
info: 'Fillet/Champher',
mutualExclusiveFields: [],
paramsInfo: ({ size, }) => `(${r(size)} })`,
paramsInfo: ({ size, opperationType, }) => `(${r(size)} ${r(opperationType)}})`,
form: [
{
type: 'choice',
style: "dropdown",
label: 'opperationType',
name: 'opperationType',
values: ["Fillet", "Champher"],
defaultValue: "Fillet",
},
{
type: 'number',
label: 'size',
name: 'size',
defaultValue: 5,
},
{
type: 'selection',
name: 'edges',
@ -49,24 +58,50 @@ export default {
let occ = ctx.occService;
const oci = occ.commandInterface;
let returnObject = {
consumed: [],
created: [],
}
var edgesAndValue = [];
//add all the edges and size to seperate arrays for each shell that edges are selected from
params.edges.forEach((edge) => {
edgesAndValue.push(params.size);
edgesAndValue.push(edge);
if (!returnObject.consumed.includes(edge.shell)) {
returnObject.consumed.push(edge.shell);
edgesAndValue[edge.shell.id] = [];
}
if (params.opperationType == "Fillet") {
//order of parameters is diferent between fillet and champher
edgesAndValue[edge.shell.id].push(params.size);
edgesAndValue[edge.shell.id].push(edge);
}
if (params.opperationType == "Champher") {
//order of parameters is diferent between fillet and champher
edgesAndValue[edge.shell.id].push(edge);
edgesAndValue[edge.shell.id].push(params.size);
}
});
console.log(edgesAndValue);
//perform the opperations on each of the bodies.
Object.keys(edgesAndValue).forEach((shellToOpperateOnName) => {
var shellToOpperateOn = edgesAndValue[shellToOpperateOnName];
var newShellName = shellToOpperateOnName + "f";
oci.blend("b", params.edges[0].shell, ...edgesAndValue);
if (params.opperationType == "Fillet") oci.blend(newShellName, shellToOpperateOn[1].shell, ...shellToOpperateOn);
if (params.opperationType == "Champher") oci.chamf(newShellName, shellToOpperateOn[0].shell, ...shellToOpperateOn);
returnObject.created.push(occ.io.getShell(newShellName));
});
return {
consumed: [params.edges[0].shell],
created: [occ.io.getShell("b")]
}; },
console.log(returnObject);
return returnObject;
},
}