mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
upgrade engine fixing boolean bugs
This commit is contained in:
parent
b809dcfee8
commit
2326c75b9d
3 changed files with 1631 additions and 1410 deletions
2980
package-lock.json
generated
2980
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -149,7 +149,7 @@
|
||||||
"earcut": "^2.2.4",
|
"earcut": "^2.2.4",
|
||||||
"font-awesome": "4.7.0",
|
"font-awesome": "4.7.0",
|
||||||
"immer": "^9.0.16",
|
"immer": "^9.0.16",
|
||||||
"jsketcher-occ-engine": "1.0.1-2fbef9cdf8e1167a4142c396f9abda510a2d2d26",
|
"jsketcher-occ-engine": "1.0.1-f505cdcb9f37685cdadb937bc3b11b9b75f9267c",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"libtess": "1.2.2",
|
"libtess": "1.2.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { SketchGeom } from "cad/sketch/sketchReader";
|
import { SketchGeom } from "cad/sketch/sketchReader";
|
||||||
import { ApplicationContext } from "cad/context";
|
import { ApplicationContext } from "cad/context";
|
||||||
import CSys from "math/csys";
|
import CSys from "math/csys";
|
||||||
import {OperationResult} from "cad/craft/craftBundle";
|
import { OperationResult } from "cad/craft/craftBundle";
|
||||||
import {BooleanDefinition, BooleanKind} from "cad/craft/schema/common/BooleanDefinition";
|
import { BooleanDefinition, BooleanKind } from "cad/craft/schema/common/BooleanDefinition";
|
||||||
import {WireRef} from "cad/craft/e0/occSketchLoader";
|
import { WireRef } from "cad/craft/e0/occSketchLoader";
|
||||||
import {FromMObjectProductionAnalyzer, ProductionAnalyzer} from "cad/craft/production/productionAnalyzer";
|
import { FromMObjectProductionAnalyzer, ProductionAnalyzer } from "cad/craft/production/productionAnalyzer";
|
||||||
import {MObject} from "cad/model/mobject";
|
import { MObject } from "cad/model/mobject";
|
||||||
import {Shell} from "brep/topo/shell";
|
import { Shell } from "brep/topo/shell";
|
||||||
import {MOpenFaceShell} from "cad/model/mopenFace";
|
import { MOpenFaceShell } from "cad/model/mopenFace";
|
||||||
|
|
||||||
export interface OCCUtils {
|
export interface OCCUtils {
|
||||||
|
|
||||||
|
|
@ -16,10 +16,10 @@ export interface OCCUtils {
|
||||||
sketchToFaces(sketch: SketchGeom, csys: CSys): FaceRef[];
|
sketchToFaces(sketch: SketchGeom, csys: CSys): FaceRef[];
|
||||||
|
|
||||||
applyBooleanModifier(tools: MObject[],
|
applyBooleanModifier(tools: MObject[],
|
||||||
booleanDef: BooleanDefinition,
|
booleanDef: BooleanDefinition,
|
||||||
sketchSource?: MObject,
|
sketchSource?: MObject,
|
||||||
mustAdvance? : MObject[],
|
mustAdvance?: MObject[],
|
||||||
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult;
|
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FaceRef extends WireRef {
|
export interface FaceRef extends WireRef {
|
||||||
|
|
@ -53,10 +53,10 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
|
||||||
|
|
||||||
|
|
||||||
function applyBooleanModifier(tools: MObject[],
|
function applyBooleanModifier(tools: MObject[],
|
||||||
booleanDef: BooleanDefinition,
|
booleanDef: BooleanDefinition,
|
||||||
sketchSource: MObject,
|
sketchSource: MObject,
|
||||||
mustAdvance? : MObject[],
|
mustAdvance?: MObject[],
|
||||||
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult {
|
analyzerCreator?: (targets: MObject[], tools: MObject[]) => ProductionAnalyzer): OperationResult {
|
||||||
const occ = ctx.occService;
|
const occ = ctx.occService;
|
||||||
const oci = ctx.occService.commandInterface;
|
const oci = ctx.occService.commandInterface;
|
||||||
|
|
||||||
|
|
@ -93,14 +93,15 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
|
||||||
}).filter(targetName => !!targetName);
|
}).filter(targetName => !!targetName);
|
||||||
|
|
||||||
|
|
||||||
|
oci.boptions("-default");
|
||||||
|
|
||||||
oci.bclearobjects();
|
oci.bclearobjects();
|
||||||
oci.bcleartools();
|
oci.bcleartools();
|
||||||
|
|
||||||
targetNames.forEach(targetName => oci.baddobjects(targetName));
|
targetNames.forEach(targetName => oci.baddobjects(targetName));
|
||||||
tools.forEach(tool => oci.baddtools(tool));
|
tools.forEach(tool => {
|
||||||
console.log("booleanDef", booleanDef);
|
oci.baddtools(tool)
|
||||||
|
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{
|
||||||
|
|
@ -112,20 +113,8 @@ export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
|
||||||
oci.bfillds();
|
oci.bfillds();
|
||||||
oci.bapibop("BooleanResult", booleanKindToOCCBopType(kind));
|
oci.bapibop("BooleanResult", booleanKindToOCCBopType(kind));
|
||||||
|
|
||||||
// let resultShell = occ.io.getShell("BooleanResult");
|
|
||||||
// if (resultShell.edges.length < 0) {
|
|
||||||
|
|
||||||
// oci.bsimplify("-e", 0, "-f", 0);
|
if (booleanDef.simplify === true) oci.unifysamedom("BooleanResult", "BooleanResult");
|
||||||
// oci.baddobjects("BooleanResult");
|
|
||||||
// oci.baddtools("BooleanResult");
|
|
||||||
|
|
||||||
// oci.bcheckinverted(1);
|
|
||||||
// oci.bfillds();
|
|
||||||
// oci.bapibop("BooleanResult", OccBBOPTypes.FUSE);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
oci.fixshape("BooleanResult", "BooleanResult");
|
|
||||||
|
|
||||||
targets.forEach(t => consumed.push(t));
|
targets.forEach(t => consumed.push(t));
|
||||||
tools.forEach(t => consumed.push(t));
|
tools.forEach(t => consumed.push(t));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue