non working start of new utility function to make face with holes in it

This commit is contained in:
mmiscool 2023-09-03 16:26:20 +00:00
parent dfa5280524
commit 063b8d23d5

View file

@ -15,6 +15,8 @@ export interface OCCUtils {
sketchToFaces(sketch: SketchGeom, csys: CSys): FaceRef[]; sketchToFaces(sketch: SketchGeom, csys: CSys): FaceRef[];
sketchToFace(sketch: SketchGeom, csys: CSys): FaceRef[];
applyBooleanModifier(tools: MObject[], applyBooleanModifier(tools: MObject[],
booleanDef: BooleanDefinition, booleanDef: BooleanDefinition,
sketchSource?: MObject, sketchSource?: MObject,
@ -36,6 +38,14 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
return wiresToFaces(wires); return wiresToFaces(wires);
} }
function sketchToFace(sketch: SketchGeom, csys: CSys): FaceRef[] {
const occ = ctx.occService;
const wires = occ.io.sketchLoader.pushSketchAsWires(sketch.contours, csys);
return wiresToFace(wires);
}
function wiresToFaces(wires: WireRef[]): FaceRef[] { function wiresToFaces(wires: WireRef[]): FaceRef[] {
const oci = ctx.occService.commandInterface; const oci = ctx.occService.commandInterface;
return wires.map((wire, i) => { return wires.map((wire, i) => {
@ -52,6 +62,28 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
} }
function wiresToFace(wires: WireRef[]): FaceRef[] {
const oci = ctx.occService.commandInterface;
const faceName = "Face";
oci.mkplane(faceName, wires[0].wire);
const brepShell = ctx.occService.io.getLightShell(faceName);
wires.forEach((wire, index) => {
if (index == 0) return;
oci.add(faceName, wire.wire);
})
return [{
face: faceName,
topoShape: brepShell,
}]
}
function applyBooleanModifier(tools: MObject[], function applyBooleanModifier(tools: MObject[],
booleanDef: BooleanDefinition, booleanDef: BooleanDefinition,
sketchSource: MObject, sketchSource: MObject,
@ -102,9 +134,9 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
oci.baddtools(tool) oci.baddtools(tool)
oci.settolerance(tool, 0.0001); oci.settolerance(tool, 0.0001);
}); });
if (booleanDef.simplify === true){ if (booleanDef.simplify === true) {
oci.bsimplify("-e", 1, "-f", 1); oci.bsimplify("-e", 1, "-f", 1);
}else{ } else {
oci.bsimplify("-e", 0, "-f", 0); oci.bsimplify("-e", 0, "-f", 0);
} }
oci.bfuzzyvalue(0.0001); oci.bfuzzyvalue(0.0001);
@ -131,7 +163,7 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
return { return {
wiresToFaces, sketchToFaces, applyBooleanModifier wiresToFaces, sketchToFaces, applyBooleanModifier, wiresToFace, sketchToFace,
} }
} }