mirror of
https://github.com/xibyte/jsketcher
synced 2026-02-11 18:03:44 +01:00
move edge to face classifier to wasm
This commit is contained in:
parent
f94453cfc3
commit
e6c9eb4ca4
6 changed files with 36 additions and 42 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
|
@ -13,7 +13,7 @@
|
|||
"clipper-lib": "6.2.1",
|
||||
"earcut": "2.1.1",
|
||||
"immer": "^9.0.12",
|
||||
"jsketcher-occ-engine": "1.0.1-6b73c0b531c39813c700070f0dae62282ea1d358",
|
||||
"jsketcher-occ-engine": "1.0.1-2144340d03c052dc3c4bfab1c045ee28a6ba1528",
|
||||
"less": "^3.11.1",
|
||||
"libtess": "1.2.2",
|
||||
"lodash": "^4.17.15",
|
||||
|
|
@ -9151,9 +9151,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/jsketcher-occ-engine": {
|
||||
"version": "1.0.1-6b73c0b531c39813c700070f0dae62282ea1d358",
|
||||
"resolved": "https://registry.npmjs.org/jsketcher-occ-engine/-/jsketcher-occ-engine-1.0.1-6b73c0b531c39813c700070f0dae62282ea1d358.tgz",
|
||||
"integrity": "sha512-GTp6A08ARrnLUGCK16PWJ2/Oslaq6jq4d9Klzsyj3csrVSOP4Mjy7swtpdzpWNIVbASUZ+LnI2evrJNtbZEOyw=="
|
||||
"version": "1.0.1-2144340d03c052dc3c4bfab1c045ee28a6ba1528",
|
||||
"resolved": "https://registry.npmjs.org/jsketcher-occ-engine/-/jsketcher-occ-engine-1.0.1-2144340d03c052dc3c4bfab1c045ee28a6ba1528.tgz",
|
||||
"integrity": "sha512-pnC4SsSkEvrKdX6ikCw2+r8hF8gIVjLipvPXVrjll2QAAlTA8LoX0o68H4a16mljVF8MPnazlZ8f8uaCUZoP3A=="
|
||||
},
|
||||
"node_modules/json-parse-better-errors": {
|
||||
"version": "1.0.2",
|
||||
|
|
@ -23379,9 +23379,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"jsketcher-occ-engine": {
|
||||
"version": "1.0.1-6b73c0b531c39813c700070f0dae62282ea1d358",
|
||||
"resolved": "https://registry.npmjs.org/jsketcher-occ-engine/-/jsketcher-occ-engine-1.0.1-6b73c0b531c39813c700070f0dae62282ea1d358.tgz",
|
||||
"integrity": "sha512-GTp6A08ARrnLUGCK16PWJ2/Oslaq6jq4d9Klzsyj3csrVSOP4Mjy7swtpdzpWNIVbASUZ+LnI2evrJNtbZEOyw=="
|
||||
"version": "1.0.1-2144340d03c052dc3c4bfab1c045ee28a6ba1528",
|
||||
"resolved": "https://registry.npmjs.org/jsketcher-occ-engine/-/jsketcher-occ-engine-1.0.1-2144340d03c052dc3c4bfab1c045ee28a6ba1528.tgz",
|
||||
"integrity": "sha512-pnC4SsSkEvrKdX6ikCw2+r8hF8gIVjLipvPXVrjll2QAAlTA8LoX0o68H4a16mljVF8MPnazlZ8f8uaCUZoP3A=="
|
||||
},
|
||||
"json-parse-better-errors": {
|
||||
"version": "1.0.2",
|
||||
|
|
|
|||
|
|
@ -84,6 +84,6 @@
|
|||
"react-toastify": "^5.5.0",
|
||||
"sprintf": "0.1.5",
|
||||
"three": "^0.118.3",
|
||||
"jsketcher-occ-engine": "1.0.1-6b73c0b531c39813c700070f0dae62282ea1d358"
|
||||
"jsketcher-occ-engine": "1.0.1-2144340d03c052dc3c4bfab1c045ee28a6ba1528"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
web/app/cad/craft/e0/interact.d.ts
vendored
2
web/app/cad/craft/e0/interact.d.ts
vendored
|
|
@ -10,6 +10,8 @@ export function ClassifyPointToFace(facePtr: number, x: number, y: number, z: nu
|
|||
|
||||
export function ClassifyFaceToFace(face1Ptr: number, face2Ptr: number, tol: number): number;
|
||||
|
||||
export function ClassifyEdgeToFace(edgePtr: number, facePtr: number, tol: number): number;
|
||||
|
||||
export function IsEdgesOverlap(e1Ptr: number, e2Ptr: number, tol: number): boolean;
|
||||
|
||||
export function UpdateTessellation(shapePtr: number, deflection: number): number;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,10 @@ export function ClassifyFaceToFace(face1Ptr, face2Ptr, tol) {
|
|||
return Module._ClassifyFaceToFace(face1Ptr, face2Ptr, tol);
|
||||
}
|
||||
|
||||
export function ClassifyEdgeToFace(edgePtr, facePtr, tol){
|
||||
return Module._ClassifyEdgeToFace(edgePtr, facePtr, tol);
|
||||
}
|
||||
|
||||
export function IsEdgesOverlap(e1Ptr, e2Ptr, tol) {
|
||||
return Module._IsEdgesOverlap(e1Ptr, e2Ptr, tol);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
import {ClassifyFaceToFace, ClassifyPointToFace, IsEdgesOverlap, UpdateTessellation} from "cad/craft/e0/interact";
|
||||
import {
|
||||
ClassifyEdgeToFace,
|
||||
ClassifyFaceToFace,
|
||||
ClassifyPointToFace,
|
||||
IsEdgesOverlap,
|
||||
UpdateTessellation
|
||||
} from "cad/craft/e0/interact";
|
||||
import {Face} from "brep/topo/face";
|
||||
import {Edge} from "brep/topo/edge";
|
||||
import {Shell} from "brep/topo/shell";
|
||||
|
|
@ -7,7 +13,7 @@ export enum Classification {
|
|||
|
||||
UNRELATED,
|
||||
|
||||
SAME,
|
||||
EXACT,
|
||||
|
||||
PARTIAL
|
||||
|
||||
|
|
@ -47,8 +53,6 @@ export class OCCClassifier implements Classifier {
|
|||
const ptr = shell.data.externals.ptr;
|
||||
if (ptr) {
|
||||
UpdateTessellation(ptr, this.tessDeflection);
|
||||
} else {
|
||||
debugger;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,31 +69,6 @@ export class OCCClassifier implements Classifier {
|
|||
}
|
||||
|
||||
classifyEdgeToFace(edge: Edge, face: Face): Classification {
|
||||
|
||||
let wasMatch: boolean = false;
|
||||
let wasMissMatch: boolean = false;
|
||||
|
||||
edge.data.tessellation.forEach(pt => {
|
||||
const result = ClassifyPointToFace(face.data.externals.ptr, pt[0], pt[1], pt[2], 1) as OCCGeomClassifyResult;
|
||||
switch (result) {
|
||||
case OCCGeomClassifyResult.BOUNDS:
|
||||
case OCCGeomClassifyResult.INSIDE:
|
||||
wasMatch = true;
|
||||
break;
|
||||
case OCCGeomClassifyResult.UNRELATED:
|
||||
default:
|
||||
wasMissMatch = true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (wasMatch && !wasMissMatch) {
|
||||
return Classification.SAME;
|
||||
} else if (wasMatch && wasMissMatch) {
|
||||
return Classification.PARTIAL;
|
||||
} else {
|
||||
return Classification.UNRELATED;
|
||||
}
|
||||
|
||||
return ClassifyEdgeToFace(edge.data.externals.ptr, face.data.externals.ptr, this.tol);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,16 @@ export interface ProductionAnalyzer {
|
|||
assignIdentification(createdShell: Shell);
|
||||
}
|
||||
|
||||
export class NullProductionAnalyzer implements ProductionAnalyzer {
|
||||
|
||||
|
||||
|
||||
assignIdentification(createdShell: Shell) {
|
||||
}
|
||||
}
|
||||
|
||||
export const NULL_ANALYZER = new NullProductionAnalyzer();
|
||||
|
||||
export class FromSketchProductionAnalyzer implements ProductionAnalyzer {
|
||||
|
||||
profiles: FaceRef[];
|
||||
|
|
@ -103,7 +113,7 @@ export class FromSketchProductionAnalyzer implements ProductionAnalyzer {
|
|||
classifier.prepare(originFace.topoShape);
|
||||
let faceToFaceClassification = classifier.classifyFaceToFace(originFaceTopology, createdFace);
|
||||
|
||||
if (faceToFaceClassification === Classification.SAME) {
|
||||
if (faceToFaceClassification === Classification.EXACT) {
|
||||
base = createdFace;
|
||||
base.data.id = `F:BASE[${wireId}]`;
|
||||
base.data.productionInfo = {
|
||||
|
|
@ -372,14 +382,13 @@ export class FromMObjectProductionAnalyzer implements ProductionAnalyzer {
|
|||
const newEdges = new Map<string, Edge[]>();
|
||||
notIdentifiedEdges.forEach(edge => {
|
||||
|
||||
// let edgeCreators = new Map<Edge, MFace[]>();
|
||||
let edgeCreators = [];
|
||||
this.consumed.forEach(consumedShell => {
|
||||
consumedShell.traverse(consumedObj => {
|
||||
if (consumedObj instanceof MFace && consumedObj.brepFace) {
|
||||
if (classifier.classifyEdgeToFace(edge, consumedObj.brepFace) !== Classification.UNRELATED) {
|
||||
//We look for strict intersection otherwise any vertex touch will count
|
||||
if (classifier.classifyEdgeToFace(edge, consumedObj.brepFace) === Classification.EXACT) {
|
||||
edgeCreators.push(consumedObj);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue