diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C index 90b37e8d9f..c8167fb22d 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C @@ -700,11 +700,12 @@ Foam::label Foam::edgeIntersections::removeDegenerates } -void Foam::edgeIntersections::replace +void Foam::edgeIntersections::merge ( const edgeIntersections& subInfo, const labelList& edgeMap, - const labelList& faceMap + const labelList& faceMap, + const bool merge ) { forAll(subInfo, subI) @@ -716,19 +717,63 @@ void Foam::edgeIntersections::replace List& intersections = operator[](edgeI); labelList& intersectionTypes = classification_[edgeI]; - intersections.setSize(subHits.size()); - intersectionTypes.setSize(subHits.size()); + // Count unique hits. Assume edge can hit face only once + label sz = 0; + if (merge) + { + sz = intersections.size(); + } + + label nNew = 0; + forAll(subHits, i) + { + const pointIndexHit& subHit = subHits[i]; + + bool foundFace = false; + for (label interI = 0; interI < sz; interI++) + { + if (intersections[interI].index() == faceMap[subHit.index()]) + { + foundFace = true; + break; + } + } + if (!foundFace) + { + nNew++; + } + } + + + intersections.setSize(sz+nNew); + intersectionTypes.setSize(sz+nNew); + nNew = sz; forAll(subHits, i) { const pointIndexHit& subHit = subHits[i]; - intersections[i] = pointIndexHit - ( - subHit.hit(), - subHit.rawPoint(), - faceMap[subHit.index()] - ); - intersectionTypes[i] = subClass[i]; + + bool foundFace = false; + for (label interI = 0; interI < sz; interI++) + { + if (intersections[interI].index() == faceMap[subHit.index()]) + { + foundFace = true; + break; + } + } + + if (!foundFace) + { + intersections[nNew] = pointIndexHit + ( + subHit.hit(), + subHit.rawPoint(), + faceMap[subHit.index()] + ); + intersectionTypes[nNew] = subClass[i]; + nNew++; + } } } } diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.H b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.H index a2e088fdd8..4a283b822c 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.H +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.H @@ -198,13 +198,15 @@ public: pointField& points1 ); - //- Replace edge intersection for a subset (given as edge map and - // face map - for face indices stored in pointIndexHit.index()) - void replace + //- Merge (or override) edge intersection for a subset + // (given as edge map and face map - for face indices stored in + // pointIndexHit.index()) + void merge ( const edgeIntersections&, const labelList& edgeMap, - const labelList& faceMap + const labelList& faceMap, + const bool merge = true ); };