ENH: edgeIntersections: added merging

This commit is contained in:
mattijs
2014-10-22 12:18:38 +01:00
committed by Andrew Heather
parent 3980b63a31
commit e195f10b11
2 changed files with 62 additions and 15 deletions

View File

@ -700,11 +700,12 @@ Foam::label Foam::edgeIntersections::removeDegenerates
} }
void Foam::edgeIntersections::replace void Foam::edgeIntersections::merge
( (
const edgeIntersections& subInfo, const edgeIntersections& subInfo,
const labelList& edgeMap, const labelList& edgeMap,
const labelList& faceMap const labelList& faceMap,
const bool merge
) )
{ {
forAll(subInfo, subI) forAll(subInfo, subI)
@ -716,19 +717,63 @@ void Foam::edgeIntersections::replace
List<pointIndexHit>& intersections = operator[](edgeI); List<pointIndexHit>& intersections = operator[](edgeI);
labelList& intersectionTypes = classification_[edgeI]; labelList& intersectionTypes = classification_[edgeI];
intersections.setSize(subHits.size()); // Count unique hits. Assume edge can hit face only once
intersectionTypes.setSize(subHits.size()); 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) forAll(subHits, i)
{ {
const pointIndexHit& subHit = subHits[i]; const pointIndexHit& subHit = subHits[i];
intersections[i] = pointIndexHit
( bool foundFace = false;
subHit.hit(), for (label interI = 0; interI < sz; interI++)
subHit.rawPoint(), {
faceMap[subHit.index()] if (intersections[interI].index() == faceMap[subHit.index()])
); {
intersectionTypes[i] = subClass[i]; foundFace = true;
break;
}
}
if (!foundFace)
{
intersections[nNew] = pointIndexHit
(
subHit.hit(),
subHit.rawPoint(),
faceMap[subHit.index()]
);
intersectionTypes[nNew] = subClass[i];
nNew++;
}
} }
} }
} }

View File

@ -198,13 +198,15 @@ public:
pointField& points1 pointField& points1
); );
//- Replace edge intersection for a subset (given as edge map and //- Merge (or override) edge intersection for a subset
// face map - for face indices stored in pointIndexHit.index()) // (given as edge map and face map - for face indices stored in
void replace // pointIndexHit.index())
void merge
( (
const edgeIntersections&, const edgeIntersections&,
const labelList& edgeMap, const labelList& edgeMap,
const labelList& faceMap const labelList& faceMap,
const bool merge = true
); );
}; };