Skip to content

Commit

Permalink
non working start of new utility function to make face with holes in it
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiscool authored and mmiscool committed Sep 3, 2023
1 parent dfa5280 commit 063b8d2
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions web/app/cad/craft/e0/OCCUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface OCCUtils {

sketchToFaces(sketch: SketchGeom, csys: CSys): FaceRef[];

sketchToFace(sketch: SketchGeom, csys: CSys): FaceRef[];

applyBooleanModifier(tools: MObject[],
booleanDef: BooleanDefinition,
sketchSource?: MObject,
Expand All @@ -36,6 +38,14 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
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[] {
const oci = ctx.occService.commandInterface;
return wires.map((wire, i) => {
Expand All @@ -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[],
booleanDef: BooleanDefinition,
sketchSource: MObject,
Expand Down Expand Up @@ -100,11 +132,11 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
targetNames.forEach(targetName => oci.baddobjects(targetName));
tools.forEach(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);
}else{
} else {
oci.bsimplify("-e", 0, "-f", 0);
}
oci.bfuzzyvalue(0.0001);
Expand All @@ -131,7 +163,7 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {


return {
wiresToFaces, sketchToFaces, applyBooleanModifier
wiresToFaces, sketchToFaces, applyBooleanModifier, wiresToFace, sketchToFace,
}

}
Expand Down

0 comments on commit 063b8d2

Please sign in to comment.