Commit 3e22fb9d authored by laurence's avatar laurence
Browse files

ENH: Check whether an intersection is unique when using findAll. This

check is required because the new octree method for finding all intersections
with a surface will return two face intersection hits for a line that
passes through the edge shared by two faces. The test is geometric.
parent 33221dc8
......@@ -28,6 +28,83 @@ License
#include "PatchTools.H"
#include "volumeType.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::triSurfaceSearch::checkUniqueHit
(
const pointIndexHit& currHit,
const DynamicList<pointIndexHit, 1, 1>& hits,
const vector& lineVec
) const
{
// Classify the hit
label nearType = -1;
label nearLabel = -1;
const labelledTri& f = surface()[currHit.index()];
f.nearestPointClassify
(
currHit.hitPoint(),
surface().points(),
nearType,
nearLabel
);
if (nearType == 1)
{
// near point
}
else if (nearType == 2)
{
// near edge
// check if the other face of the edge is already hit
const labelList& fEdges = surface().faceEdges()[currHit.index()];
const label edgeI = fEdges[nearLabel];
const labelList& edgeFaces = surface().edgeFaces()[edgeI];
forAll(edgeFaces, fI)
{
const label edgeFaceI = edgeFaces[fI];
if (edgeFaceI != currHit.index())
{
forAll(hits, hI)
{
const pointIndexHit& hit = hits[hI];
if (hit.index() == edgeFaceI)
{
// Check normals
const vector currHitNormal =
surface().faceNormals()[currHit.index()];
const vector existingHitNormal =
surface().faceNormals()[edgeFaceI];
const label signCurrHit =
pos(currHitNormal & lineVec);
const label signExistingHit =
pos(existingHitNormal & lineVec);
if (signCurrHit == signExistingHit)
{
return false;
}
}
}
}
}
}
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
......@@ -306,7 +383,21 @@ void Foam::triSurfaceSearch::findLineAll
if (inter.hit())
{
hits.append(inter);
vector lineVec = end[pointI] - start[pointI];
lineVec /= mag(lineVec) + VSMALL;
if
(
checkUniqueHit
(
inter,
hits,
lineVec
)
)
{
hits.append(inter);
}
shapeMask.append(inter.index());
}
......
......@@ -50,7 +50,7 @@ namespace Foam
class triSurface;
/*---------------------------------------------------------------------------*\
Class triSurfaceSearch Declaration
Class triSurfaceSearch Declaration
\*---------------------------------------------------------------------------*/
class triSurfaceSearch
......@@ -72,6 +72,15 @@ class triSurfaceSearch
// Private Member Functions
//- Check whether the current hit on the surface which lies on lineVec
// is unique.
bool checkUniqueHit
(
const pointIndexHit& currHit,
const DynamicList<pointIndexHit, 1, 1>& hits,
const vector& lineVec
) const;
//- Disallow default bitwise copy construct
triSurfaceSearch(const triSurfaceSearch&);
......
Markdown is supported
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