From e6c9eb4ca49050929197ecd63232da5abe18b76d Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Wed, 8 Jun 2022 00:17:21 -0700 Subject: [PATCH] move edge to face classifier to wasm --- package-lock.json | 14 +++---- package.json | 2 +- web/app/cad/craft/e0/interact.d.ts | 2 + web/app/cad/craft/e0/interact.js | 4 ++ web/app/cad/craft/production/classifier.ts | 39 +++++-------------- .../craft/production/productionAnalyzer.ts | 17 ++++++-- 6 files changed, 36 insertions(+), 42 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9a36b4ff..0837737d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 72f434a9..31e7608f 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/web/app/cad/craft/e0/interact.d.ts b/web/app/cad/craft/e0/interact.d.ts index 5955539d..b171f065 100644 --- a/web/app/cad/craft/e0/interact.d.ts +++ b/web/app/cad/craft/e0/interact.d.ts @@ -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; diff --git a/web/app/cad/craft/e0/interact.js b/web/app/cad/craft/e0/interact.js index 5a9c1b72..4606dba4 100644 --- a/web/app/cad/craft/e0/interact.js +++ b/web/app/cad/craft/e0/interact.js @@ -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); } diff --git a/web/app/cad/craft/production/classifier.ts b/web/app/cad/craft/production/classifier.ts index 18bfcbd0..9feb9e27 100644 --- a/web/app/cad/craft/production/classifier.ts +++ b/web/app/cad/craft/production/classifier.ts @@ -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); } } diff --git a/web/app/cad/craft/production/productionAnalyzer.ts b/web/app/cad/craft/production/productionAnalyzer.ts index efdd5b4d..15f90b63 100644 --- a/web/app/cad/craft/production/productionAnalyzer.ts +++ b/web/app/cad/craft/production/productionAnalyzer.ts @@ -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(); notIdentifiedEdges.forEach(edge => { - // let edgeCreators = new Map(); 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); - } } });