Added defeaturing delete face operation.

This commit is contained in:
Mike Molinari 2022-08-18 01:54:10 +00:00 committed by Val Erastov
parent dde86e056a
commit b4631baccb
5 changed files with 82 additions and 3 deletions

4
externals.d.ts vendored
View file

@ -2,6 +2,10 @@ declare module '*.less' {
const resource: {[key: string]: string};
export = resource;
}
declare module "*.svg" {
const content: any;
export default content;
}
declare const verb: any;
declare const FS: any;

View file

@ -0,0 +1 @@
<svg version="1.1" viewBox="0.0 0.0 96.0 96.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="g145a76981cc_0_0.0"><path d="m0 0l96.0 0l0 96.0l-96.0 0l0 -96.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#g145a76981cc_0_0.0)"><path fill="#000000" fill-opacity="0.0" d="m0 0l96.0 0l0 96.0l-96.0 0z" fill-rule="evenodd"/><path fill="#999999" d="m2.7178478 16.619316l22.155388 -14.16l22.331495 14.256321l-22.15567 13.96736z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m2.7178478 16.619316l22.155388 -14.16l22.331495 14.256321l-22.15567 13.96736z" fill-rule="evenodd"/><path fill="#999999" d="m2.7178478 16.71427l0 28.199999l22.123867 14.004089l0 -28.2z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m2.7178478 16.71427l0 28.199999l22.123867 14.004089l0 -28.2z" fill-rule="evenodd"/><path fill="#999999" d="m25.02383 30.68163l22.15567 -13.96736l0 28.12736l-22.15567 14.16z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m25.02383 30.68163l22.15567 -13.96736l0 28.12736l-22.15567 14.16z" fill-rule="evenodd"/><path fill="#ffff00" d="m11.714962 16.821272l13.072845 -8.218885l12.54863 7.8419228l-12.636 8.406437z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m11.714962 16.821272l13.072845 -8.218885l12.54863 7.8419228l-12.636 8.406437z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m24.84837 9.737011l-0.062992096 7.370079" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m24.84837 9.737011l-0.062992096 7.370079" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m24.875786 16.06565l-6.614174 4.3464565" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m24.875786 16.06565l-6.614174 4.3464565" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m25.02314 15.878095l6.55118 4.157481" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m25.02314 15.878095l6.55118 4.157481" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m51.636265 10.283416l0 0c6.4060555 -1.9204941 13.435429 -0.013095856 18.564892 5.037527c5.129471 5.050622 7.6231613 12.519904 6.5859604 19.726727l-19.151306 -4.3184433z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m51.636265 10.283416l0 0c6.4060555 -1.9204941 13.435429 -0.013095856 18.564892 5.037527c5.129471 5.050622 7.6231613 12.519904 6.5859604 19.726727" fill-rule="evenodd"/><path stroke="#0000ff" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m51.63626 10.283416l0 0c6.406063 -1.9204931 13.435432 -0.013096809 18.564903 5.037527c0.64118195 0.6313286 1.2411804 1.3004465 1.7982483 2.002122c0.069633484 0.08770943 0.13859558 0.17592621 0.20687866 0.26464462l0.03326416 0.043884277" fill-rule="evenodd"/><path fill="#0000ff" stroke="#0000ff" stroke-width="4.0" stroke-linecap="butt" d="m67.95993 18.749058l7.3498306 10.640701l1.2094193 -12.875629z" fill-rule="evenodd"/><path fill="#999999" d="m48.6613 51.07337l22.155388 -14.16l22.331497 14.256321l-22.15567 13.967361z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m48.6613 51.07337l22.155388 -14.16l22.331497 14.256321l-22.15567 13.967361z" fill-rule="evenodd"/><path fill="#999999" d="m48.6613 51.168327l0 28.199997l22.123863 14.004089l0 -28.199997z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m48.6613 51.168327l0 28.199997l22.123863 14.004089l0 -28.199997z" fill-rule="evenodd"/><path fill="#999999" d="m70.967285 65.13569l22.15567 -13.967361l0 28.127357l-22.15567 14.160004z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="4.0" stroke-linejoin="round" stroke-linecap="butt" d="m70.967285 65.13569l22.15567 -13.967361l0 28.127357l-22.15567 14.160004z" fill-rule="evenodd"/></g></svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -0,0 +1,58 @@
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
import { ApplicationContext } from "cad/context";
import { EntityKind } from "cad/model/entities";
import { OperationDescriptor } from "cad/craft/operationBundle";
import { MFace } from "cad/model/mface";
import {FromMObjectProductionAnalyzer} from "cad/craft/production/productionAnalyzer";
import icon from "./DELETE FACE.svg";
interface DefeatureRemoveFaceParams {
tools: MFace[];
}
export const DefeatureRemoveFaceOperation: OperationDescriptor<DefeatureRemoveFaceParams> = {
id: 'DEFEATURE_REMOVE_FACE',
label: 'Delete Face',
icon: icon,
info: 'Delete face helps defeating a model.',
path: __dirname,
paramsInfo: ({ tools }) => `(${r(tools)})`,
run: (params: DefeatureRemoveFaceParams, ctx: ApplicationContext) => {
const occ = ctx.occService;
const oci = occ.commandInterface;
const created = [];
const consumed = [];
consumed.push(params.tools[0].shell);
const analyzer = new FromMObjectProductionAnalyzer(consumed);
oci.removefeatures("resultingShape", params.tools[0].shell, ...params.tools);
created.push(occ.io.getShell("resultingShape",analyzer));
console.log(params.tools)
//consumed.push(tools[0].)
const returnObject = {
created,
consumed
}
return returnObject;
},
form: [
{
type: 'selection',
name: 'tools',
capture: [EntityKind.FACE],
label: 'Tools',
optional: false,
multi: true,
defaultValue: {
usePreselection: true,
preselectionIndex: 0
},
},
],
}

View file

@ -0,0 +1,8 @@
# DELETE FACE
The delete face tool is used to defeature a model.
Select the faces you wish to remove. For example a particular fillet or the bottom and side faces of a hole.
The tool will attempt to extend adjacent faces to fill the hole.
Useful for working with geometry that has been imported or being prepared for developing a casting where the features will be added at a later stage of the manufacturing process.

View file

@ -20,6 +20,7 @@ import {PatternLinearOperation} from "./features/patternLinear/patternLinear.ope
import {PatternRadialOperation} from "./features/patternRadial/patternRadial.operation";
import {ImportModelOperation} from "./features/importModel/importModel.operation";
import {DeleteBodyOperation} from "./features/deleteBody/deleteBody.operation";
import {DefeatureRemoveFaceOperation} from "./features/defeatureRemoveFace/defeatureRemoveFace.operation";
//imports of action type commands
import {GiCubes} from "react-icons/gi";
@ -47,6 +48,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
PatternRadialOperation,
ImportModelOperation,
DeleteBodyOperation,
DefeatureRemoveFaceOperation,
],
actions: [
// GetVolume,
@ -54,12 +56,18 @@ export const ModelerWorkspace: WorkbenchConfig = {
ui: {
toolbar: [
'DATUM_CREATE', 'PLANE', 'EditFace', '-',
"EXTRUDE", "CUT", "REVOLVE", "LOFT", "SWEEP", "-",
"BOOLEAN", "UNION", "SUBTRACT", "INTERSECT", "-",
"SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY","-",
"BOOLEAN", "UNION", "SUBTRACT", "INTERSECT", "-",
"SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY", "DEFEATURE_REMOVE_FACE", "-",
"MIRROR_BODY", "PATTERN_LINEAR", "PATTERN_RADIAL", "-",
"CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-",
"HOLE_TOOL", "-", 'GET_VOLUME', "IMPORT_MODEL","DELETE_BODY",
"HOLE_TOOL", "-", 'GET_VOLUME', "IMPORT_MODEL", "DELETE_BODY",
]
},
icon: GiCubes