Skip to content
Snippets Groups Projects
Commit dc488579 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 c2d3bab0
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,83 @@ License ...@@ -28,6 +28,83 @@ License
#include "PatchTools.H" #include "PatchTools.H"
#include "volumeType.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::triSurfaceSearch::triSurfaceSearch(const triSurface& surface) Foam::triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
...@@ -306,7 +383,21 @@ void Foam::triSurfaceSearch::findLineAll ...@@ -306,7 +383,21 @@ void Foam::triSurfaceSearch::findLineAll
if (inter.hit()) 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()); shapeMask.append(inter.index());
} }
......
...@@ -50,7 +50,7 @@ namespace Foam ...@@ -50,7 +50,7 @@ namespace Foam
class triSurface; class triSurface;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class triSurfaceSearch Declaration Class triSurfaceSearch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class triSurfaceSearch class triSurfaceSearch
...@@ -72,6 +72,15 @@ class triSurfaceSearch ...@@ -72,6 +72,15 @@ class triSurfaceSearch
// Private Member Functions // 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 //- Disallow default bitwise copy construct
triSurfaceSearch(const triSurfaceSearch&); triSurfaceSearch(const triSurfaceSearch&);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment