From 1ac7090d918580b64ec7a9fd6de9e4ec87bc111f Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Sun, 29 Jan 2017 23:16:54 -0800 Subject: [PATCH] BREP boolean point on edge corner case(when cutting sketch) --- web/app/brep/operations/boolean.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/web/app/brep/operations/boolean.js b/web/app/brep/operations/boolean.js index e7c968ee..7afc5afb 100644 --- a/web/app/brep/operations/boolean.js +++ b/web/app/brep/operations/boolean.js @@ -65,6 +65,7 @@ export function BooleanAlgorithm( shell1, shell2, type ) { facesData = facesData.filter(fd => fd.merged !== true); for (let faceData of facesData) { + fixOppositeEdges(faceData); fixCoincidentEdges(faceData, type === TYPE.UNION) } @@ -307,6 +308,27 @@ function areEdgesOpposite(e1, e2) { } +function fixOppositeEdges(faceData) { + //corner case there a point on edge ____V____ + for (let i = 0; i < faceData.newEdges.length; ++i) { + const e1 = faceData.newEdges[i]; + if (e1 == null) continue; + for (let j = 0; j < faceData.newEdges.length; ++j) { + if (i == j) continue; + const e2 = faceData.newEdges[j]; + if (e2 == null) continue; + if (areEdgesOpposite(e1, e2)) { + deleteEdge(e1.edge); + deleteEdge(e2.edge); + faceData.newEdges[i] = null; + faceData.newEdges[j] = null; + break; + } + } + } + faceData.newEdges = faceData.newEdges.filter(e => e != null); +} + function fixCoincidentEdges(faceData, union) { const newEdges = []; @@ -495,7 +517,7 @@ function initSolveData(shell, facesData) { face.data[MY] = solveData; for (let he of face.edges) { EdgeSolveData.clear(he); - solveData.vertexToEdge.set(he.vertexA, [he]); + addToListInMap(solveData.vertexToEdge, he.vertexA, he); } } }