have single intersection only

This commit is contained in:
mattijs
2008-08-08 11:02:05 +01:00
parent 38870e3256
commit b6c8c1dca1

View File

@ -436,7 +436,13 @@ void Foam::searchableBox::findLineAll
// Work array
DynamicList<pointIndexHit, 1, 1> hits;
// Tolerances
//XXX
// Tolerances:
// To find all intersections we add a small vector to the last intersection
// This is chosen such that
// - it is significant (SMALL is smallest representative relative tolerance;
// we need something bigger since we're doing calculations)
// - if the start-end vector is zero we still progress
const vectorField dirVec(end-start);
const scalarField magSqrDirVec(magSqr(dirVec));
const vectorField smallVec
@ -446,36 +452,46 @@ void Foam::searchableBox::findLineAll
);
forAll(start, pointI)
{
// See if any intersection between pt and end
pointIndexHit inter = findLine(start[pointI], end[pointI]);
if (inter.hit())
{
hits.clear();
hits.append(inter);
// Current starting point of ray.
point pt = start[pointI];
point pt = inter.hitPoint() + smallVec[pointI];
while (true)
while (((pt-start[pointI])&dirVec[pointI]) <= magSqrDirVec[pointI])
{
// See if any intersection between pt and end
pointIndexHit inter = findLine(pt, end[pointI]);
if (!inter.hit())
// Check for not hit or hit same face as before (can happen
// if vector along surface of face)
if
(
!inter.hit()
|| (inter.index() == hits[hits.size()-1].index())
)
{
break;
}
hits.append(inter);
pt = inter.hitPoint() + smallVec[pointI];
if (((pt-start[pointI])&dirVec[pointI]) > magSqrDirVec[pointI])
{
// Adding smallVec has taken us beyond end
break;
}
}
hits.shrink();
info[pointI].transfer(hits);
hits.clear();
}
else
{
info[pointI].clear();
}
}
}