mirror of
https://github.com/xibyte/jsketcher
synced 2026-04-01 11:06:51 +02:00
Add simplify body feature.
This commit is contained in:
parent
3ea841b301
commit
9250ccf55a
4 changed files with 174 additions and 1 deletions
106
modules/workbenches/modeler/features/simplify/SIMPLIFY.svg
Normal file
106
modules/workbenches/modeler/features/simplify/SIMPLIFY.svg
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<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="g1fabafa724e_0_0.0"><path
|
||||
d="m0 0l96.0 0l0 96.0l-96.0 0l0 -96.0z"
|
||||
clip-rule="nonzero"
|
||||
/></clipPath><g clip-path="url(#g1fabafa724e_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="#000000"
|
||||
fill-opacity="0.0"
|
||||
d="m49.115547 30.809946l0 0c0 -8.392988 6.9589767 -15.19685 15.543304 -15.19685l0 0c4.122345 0 8.075844 1.6010914 10.990784 4.4510536c2.9149323 2.8499622 4.5525284 6.7153416 4.5525284 10.745796l0 0c0 8.392988 -6.9589767 15.196852 -15.543312 15.196852l0 0c-8.584328 0 -15.543304 -6.8038635 -15.543304 -15.196852z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
stroke="#000000"
|
||||
stroke-width="4.0"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="butt"
|
||||
d="m49.115547 30.809946l0 0c0 -8.392988 6.9589767 -15.19685 15.543304 -15.19685l0 0c4.122345 0 8.075844 1.6010914 10.990784 4.4510536c2.9149323 2.8499622 4.5525284 6.7153416 4.5525284 10.745796l0 0c0 8.392988 -6.9589767 15.196852 -15.543312 15.196852l0 0c-8.584328 0 -15.543304 -6.8038635 -15.543304 -15.196852z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#000000"
|
||||
fill-opacity="0.0"
|
||||
d="m65.87686 2.935681l25.732285 0l0 26.519686l-25.732285 0z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
stroke="#000000"
|
||||
stroke-width="4.0"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="butt"
|
||||
d="m65.87686 2.935681l25.732285 0l0 26.519686l-25.732285 0z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#ffff00"
|
||||
d="m22.267939 49.959305l25.732283 0l0 26.519684l-25.732283 0z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#ffff00"
|
||||
d="m5.5066233 77.83357l0 0c0 -8.39299 6.958976 -15.196854 15.543307 -15.196854l0 0c4.122341 0 8.075842 1.6010895 10.990776 4.4510574c2.914936 2.8499603 4.552532 6.7153397 4.552532 10.745796l0 0c0 8.3929825 -6.9589767 15.196846 -15.543308 15.196846l0 0c-8.5843315 0 -15.543307 -6.8038635 -15.543307 -15.196846z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#000000"
|
||||
fill-opacity="0.0"
|
||||
d="m5.5066233 77.83357l0 0c0 -8.39299 6.958976 -15.196854 15.543307 -15.196854l0 0c4.122341 0 8.075842 1.6010895 10.990776 4.4510574c2.914936 2.8499603 4.552532 6.7153397 4.552532 10.745796l0 0c0 8.3929825 -6.9589767 15.196846 -15.543308 15.196846l0 0c-8.5843315 0 -15.543307 -6.8038635 -15.543307 -15.196846z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
stroke="#000000"
|
||||
stroke-width="4.0"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="butt"
|
||||
d="m5.5066233 77.83357l0 0c0 -8.39299 6.958976 -15.196854 15.543307 -15.196854l0 0c4.122341 0 8.075842 1.6010895 10.990776 4.4510574c2.914936 2.8499603 4.552532 6.7153397 4.552532 10.745796l0 0c0 8.3929825 -6.9589767 15.196846 -15.543308 15.196846l0 0c-8.5843315 0 -15.543307 -6.8038635 -15.543307 -15.196846z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#000000"
|
||||
fill-opacity="0.0"
|
||||
d="m22.267939 49.959305l25.732283 0l0 26.519684l-25.732283 0z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
stroke="#000000"
|
||||
stroke-width="4.0"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="butt"
|
||||
d="m22.267939 49.959305l25.732283 0l0 26.519684l-25.732283 0z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#000000"
|
||||
fill-opacity="0.0"
|
||||
d="m15.726296 47.00619l0 0c-2.3476791 -7.9329987 -0.21601295 -16.47208 5.6070814 -22.460993c5.8230934 -5.9889107 14.472679 -8.538086 22.751656 -6.705284l-5.2824707 22.75931z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#000000"
|
||||
fill-opacity="0.0"
|
||||
d="m15.726296 47.00619l0 0c-2.3476791 -7.9329987 -0.21601295 -16.47208 5.6070814 -22.460993c5.8230934 -5.9889107 14.472679 -8.538086 22.751656 -6.705284"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
stroke="#4285f4"
|
||||
stroke-width="4.0"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="butt"
|
||||
d="m15.726295 47.00619l0 0c-2.3476772 -7.9329987 -0.216012 -16.47208 5.6070824 -22.460993c1.4557724 -1.4972267 3.0882015 -2.7794704 4.847332 -3.8320103l0.12354469 -0.07258797"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#4285f4"
|
||||
stroke="#4285f4"
|
||||
stroke-width="4.0"
|
||||
stroke-linecap="butt"
|
||||
d="m26.992462 25.009842l11.316181 -6.2600765l-12.692596 -2.478405z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#999999"
|
||||
d="m67.8294 4.8083987l21.826767 0l0 22.771654l-21.826767 0z"
|
||||
fill-rule="evenodd"
|
||||
/><path
|
||||
fill="#999999"
|
||||
d="m51.09974 30.811024l0 0c0 -7.4884605 6.070595 -13.559055 13.5590515 -13.559055l0 0c3.5960846 0 7.0448837 1.4285393 9.5877 3.9713554c2.5428162 2.5428162 3.9713593 5.9916134 3.9713593 9.5877l0 0c0 7.4884605 -6.070595 13.559055 -13.559059 13.559055l0 0c-7.4884567 0 -13.5590515 -6.070595 -13.5590515 -13.559055z"
|
||||
fill-rule="evenodd"
|
||||
/></g></svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
|
|
@ -0,0 +1,7 @@
|
|||
# Simplify shape
|
||||
Simplify shape cleans up geometry and unifies adjacent coplanar faces.
|
||||
Un-needed edges internal to a face are eliminated.
|
||||
Connected edges with continuity are merged.
|
||||
|
||||
Useful for cleaning up tricky geometry that has been imported or the result of difficult boolean operations.
|
||||
|
||||
|
|
@ -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 icon from "./SIMPLIFY.svg";
|
||||
import { MShell } from 'cad/model/mshell';
|
||||
import {FromMObjectProductionAnalyzer} from "cad/craft/production/productionAnalyzer";
|
||||
|
||||
interface SimplifyParams {
|
||||
tools: MShell[];
|
||||
}
|
||||
|
||||
export const SimplifyOperation: OperationDescriptor<SimplifyParams> = {
|
||||
id: 'SIMPLIFY',
|
||||
label: 'Simplify',
|
||||
icon,
|
||||
info: 'Simplify faces',
|
||||
path:__dirname,
|
||||
paramsInfo: ({tools, Simplify}) => `(${r(tools)} ${r(Simplify)})`,
|
||||
run: (params: SimplifyParams, ctx: ApplicationContext) => {
|
||||
const occ = ctx.occService;
|
||||
const oci = occ.commandInterface;
|
||||
|
||||
let created = [];
|
||||
let consumed = [];
|
||||
|
||||
|
||||
params.tools.forEach((bodyToSimplify) => {
|
||||
const analyzer = new FromMObjectProductionAnalyzer([bodyToSimplify]);
|
||||
oci.fixshape("SimplifiedShell", bodyToSimplify);
|
||||
oci.unifysamedom("SimplifiedShell", "SimplifiedShell");
|
||||
|
||||
created.push(occ.io.getShell("SimplifiedShell", analyzer));
|
||||
consumed.push(bodyToSimplify)
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
created,
|
||||
consumed
|
||||
};
|
||||
|
||||
},
|
||||
form: [
|
||||
{
|
||||
type: 'selection',
|
||||
name: 'tools',
|
||||
capture: [EntityKind.SHELL],
|
||||
label: 'Body',
|
||||
optional: false,
|
||||
multi: true,
|
||||
defaultValue: {
|
||||
usePreselection: true,
|
||||
preselectionIndex: 0
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import {PrimitiveTorusOperation} from "./features/primitiveTorus/PrimitiveTorus.
|
|||
import {HoleOperation} from "./features/hole/Hole.operation";
|
||||
import {FilletOperation} from "./features/fillet/fillet.operation";
|
||||
import {BooleanOperation} from "./features/boolean/boolean.operation";
|
||||
import {SimplifyOperation} from "./features/simplify/simplify.operation";
|
||||
import {RevolveOperation} from "./features/revolve/revolve.operation";
|
||||
import {ShellOperation} from "./features/shell/shell.operation";
|
||||
import {SweepOperation} from "./features/sweep/sweep.operation";
|
||||
|
|
@ -56,6 +57,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
|||
DefeatureRemoveFaceOperation,
|
||||
WireLineOperation,
|
||||
MoveBodyOperation,
|
||||
SimplifyOperation,
|
||||
|
||||
GetInfo,
|
||||
ExportBREP,
|
||||
|
|
@ -69,7 +71,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
|||
|
||||
["EXTRUDE", "CUT", "REVOLVE", "LOFT", "SWEEP"],
|
||||
|
||||
["UNION", "SUBTRACT", "INTERSECT"],
|
||||
["UNION", "SUBTRACT", "INTERSECT", "SIMPLIFY"],
|
||||
|
||||
["SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY", "DEFEATURE_REMOVE_FACE"],
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue