mirror of
https://github.com/xibyte/jsketcher
synced 2026-02-13 10:54:19 +01:00
Updated primitive cone to use new widgets
This commit is contained in:
parent
6e0325f29c
commit
fdc58f59a9
1 changed files with 71 additions and 58 deletions
|
|
@ -1,64 +1,77 @@
|
|||
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 icon32 from './icon32.png';
|
||||
import icon96 from './icon96.png';
|
||||
import { EntityKind } from "cad/model/entities";
|
||||
import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition";
|
||||
import { OperationDescriptor } from "cad/craft/operationPlugin";
|
||||
|
||||
export default {
|
||||
id: 'primitive_cone',
|
||||
label: 'primitive_cone',
|
||||
icon: {
|
||||
iconSet: {
|
||||
medium: {
|
||||
iconType: 'image',
|
||||
iconContent: icon32
|
||||
},
|
||||
large: {
|
||||
iconType: 'image',
|
||||
iconContent: icon96
|
||||
}
|
||||
},
|
||||
},
|
||||
info: 'primitive_cone',
|
||||
mutualExclusiveFields: [],
|
||||
paramsInfo: ({ diameter_A, diameter_B, height }) => `(${r(diameter_A)} ${r(diameter_A)} ${r(height)})`,
|
||||
schema: {
|
||||
diameter_A: {
|
||||
type: 'number',
|
||||
defaultValue: 50,
|
||||
label: 'Diameter A'
|
||||
},
|
||||
diameter_B: {
|
||||
type: 'number',
|
||||
defaultValue: 100,
|
||||
label: 'Diameter B'
|
||||
},
|
||||
height: {
|
||||
type: 'number',
|
||||
defaultValue: 200,
|
||||
label: 'height'
|
||||
},
|
||||
},
|
||||
run: ({ diameter_A, diameter_B, height, }, ctx: ApplicationContext) => {
|
||||
const oc = ctx.occService.occContext;
|
||||
|
||||
const myLocation = new oc.gp_Pnt_3(0, 0, 0);
|
||||
const coneCenterline = oc.gp.DZ();
|
||||
const coneOrientationAndLocation = new oc.gp_Ax2_3(myLocation, coneCenterline);
|
||||
|
||||
let myBody = new oc.BRepPrimAPI_MakeCone_1(diameter_A, diameter_B, height);
|
||||
|
||||
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]
|
||||
};
|
||||
},
|
||||
interface PrimitiveConeParams {
|
||||
diameterA: number,
|
||||
diameterB: number,
|
||||
height: number,
|
||||
locations: {},
|
||||
boolean: BooleanDefinition,
|
||||
}
|
||||
|
||||
const PrimitiveConeOperation: OperationDescriptor<PrimitiveConeParams> = {
|
||||
id: 'primitive_cone',
|
||||
label: 'Primitive Cone',
|
||||
icon: 'img/cad/cone',
|
||||
info: 'Primitive Cone',
|
||||
paramsInfo: ({ height, diameterA, diameterB }) => `(${r(height)} , ${r(diameterA)} , ${r(diameterB)} )`,
|
||||
form: [
|
||||
{
|
||||
type: 'number',
|
||||
label: 'Diameter A',
|
||||
name: 'diameterA',
|
||||
defaultValue: 50,
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
label: 'Diameter B',
|
||||
name: 'diameterB',
|
||||
defaultValue: 25,
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
label: 'Height',
|
||||
name: 'height',
|
||||
defaultValue: 50,
|
||||
},
|
||||
{
|
||||
type: 'selection',
|
||||
name: 'locations',
|
||||
capture: [EntityKind.DATUM],
|
||||
label: 'locations',
|
||||
multi: false,
|
||||
optional: true,
|
||||
defaultValue: {
|
||||
usePreselection: true,
|
||||
preselectionIndex: 0
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
type: 'boolean',
|
||||
name: 'boolean',
|
||||
label: 'boolean',
|
||||
optional: true,
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
|
||||
run: (params: PrimitiveConeParams, ctx: ApplicationContext) => {
|
||||
|
||||
let occ = ctx.occService;
|
||||
const oci = occ.commandInterface;
|
||||
|
||||
//pCone cy 5 10
|
||||
oci.pcone("cone", params.diameterA / 2, params.diameterB / 2, params.height);
|
||||
|
||||
return occ.utils.applyBooleanModifier(["cone"], params.boolean);
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
export default PrimitiveConeOperation;
|
||||
Loading…
Reference in a new issue