upgrade engine fixing boolean bugs

This commit is contained in:
Mike Molinari 2023-02-04 06:57:16 +00:00
parent b809dcfee8
commit 2326c75b9d
3 changed files with 1631 additions and 1410 deletions

2980
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -149,7 +149,7 @@
"earcut": "^2.2.4",
"font-awesome": "4.7.0",
"immer": "^9.0.16",
"jsketcher-occ-engine": "1.0.1-2fbef9cdf8e1167a4142c396f9abda510a2d2d26",
"jsketcher-occ-engine": "1.0.1-f505cdcb9f37685cdadb937bc3b11b9b75f9267c",
"jszip": "^3.10.1",
"libtess": "1.2.2",
"lodash": "^4.17.21",

View file

@ -1,13 +1,13 @@
import { SketchGeom } from "cad/sketch/sketchReader";
import { ApplicationContext } from "cad/context";
import CSys from "math/csys";
import {OperationResult} from "cad/craft/craftBundle";
import {BooleanDefinition, BooleanKind} from "cad/craft/schema/common/BooleanDefinition";
import {WireRef} from "cad/craft/e0/occSketchLoader";
import {FromMObjectProductionAnalyzer, ProductionAnalyzer} from "cad/craft/production/productionAnalyzer";
import {MObject} from "cad/model/mobject";
import {Shell} from "brep/topo/shell";
import {MOpenFaceShell} from "cad/model/mopenFace";
import { OperationResult } from "cad/craft/craftBundle";
import { BooleanDefinition, BooleanKind } from "cad/craft/schema/common/BooleanDefinition";
import { WireRef } from "cad/craft/e0/occSketchLoader";
import { FromMObjectProductionAnalyzer, ProductionAnalyzer } from "cad/craft/production/productionAnalyzer";
import { MObject } from "cad/model/mobject";
import { Shell } from "brep/topo/shell";
import { MOpenFaceShell } from "cad/model/mopenFace";
export interface OCCUtils {
@ -16,10 +16,10 @@ export interface OCCUtils {
sketchToFaces(sketch: SketchGeom, csys: CSys): FaceRef[];
applyBooleanModifier(tools: MObject[],
booleanDef: BooleanDefinition,
sketchSource?: MObject,
mustAdvance? : MObject[],
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult;
booleanDef: BooleanDefinition,
sketchSource?: MObject,
mustAdvance?: MObject[],
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult;
}
export interface FaceRef extends WireRef {
@ -53,10 +53,10 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
function applyBooleanModifier(tools: MObject[],
booleanDef: BooleanDefinition,
sketchSource: MObject,
mustAdvance? : MObject[],
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult {
booleanDef: BooleanDefinition,
sketchSource: MObject,
mustAdvance?: MObject[],
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult {
const occ = ctx.occService;
const oci = ctx.occService.commandInterface;
@ -93,14 +93,15 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
}).filter(targetName => !!targetName);
oci.boptions("-default");
oci.bclearobjects();
oci.bcleartools();
targetNames.forEach(targetName => oci.baddobjects(targetName));
tools.forEach(tool => oci.baddtools(tool));
console.log("booleanDef", booleanDef);
tools.forEach(tool => {
oci.baddtools(tool)
oci.settolerance(tool, 0.0001);
});
if (booleanDef.simplify === true){
oci.bsimplify("-e", 1, "-f", 1);
}else{
@ -112,20 +113,8 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
oci.bfillds();
oci.bapibop("BooleanResult", booleanKindToOCCBopType(kind));
// let resultShell = occ.io.getShell("BooleanResult");
// if (resultShell.edges.length < 0) {
// oci.bsimplify("-e", 0, "-f", 0);
// oci.baddobjects("BooleanResult");
// oci.baddtools("BooleanResult");
// oci.bcheckinverted(1);
// oci.bfillds();
// oci.bapibop("BooleanResult", OccBBOPTypes.FUSE);
// }
oci.fixshape("BooleanResult", "BooleanResult");
if (booleanDef.simplify === true) oci.unifysamedom("BooleanResult", "BooleanResult");
targets.forEach(t => consumed.push(t));
tools.forEach(t => consumed.push(t));