Commit e195f10b authored by mattijs's avatar mattijs Committed by Andrew Heather
Browse files

ENH: edgeIntersections: added merging

parent 3980b63a
......@@ -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<pointIndexHit>& 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];
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)
{
nNew++;
}
}
intersections.setSize(sz+nNew);
intersectionTypes.setSize(sz+nNew);
nNew = sz;
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)
{
intersections[nNew] = pointIndexHit
(
subHit.hit(),
subHit.rawPoint(),
faceMap[subHit.index()]
);
intersectionTypes[nNew] = subClass[i];
nNew++;
}
}
}
}
......
......@@ -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
);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment