mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: indexedOctree : intersection might be outside current box for triangle straddling two boxes.
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -1623,58 +1623,76 @@ void Foam::indexedOctree<Type>::traverseNode
|
|||||||
{
|
{
|
||||||
const labelList& indices = contents_[getContent(index)];
|
const labelList& indices = contents_[getContent(index)];
|
||||||
|
|
||||||
if (findAny)
|
if (indices.size())
|
||||||
{
|
{
|
||||||
// Find any intersection
|
if (findAny)
|
||||||
|
|
||||||
forAll(indices, elemI)
|
|
||||||
{
|
{
|
||||||
label shapeI = indices[elemI];
|
// Find any intersection
|
||||||
|
|
||||||
point pt;
|
forAll(indices, elemI)
|
||||||
bool hit = shapes_.intersects(shapeI, start, end, pt);
|
|
||||||
|
|
||||||
if (hit)
|
|
||||||
{
|
{
|
||||||
// Hit so pt is nearer than nearestPoint.
|
label shapeI = indices[elemI];
|
||||||
// Update hit info
|
|
||||||
hitInfo.setHit();
|
point pt;
|
||||||
hitInfo.setIndex(shapeI);
|
bool hit = shapes_.intersects(shapeI, start, end, pt);
|
||||||
hitInfo.setPoint(pt);
|
|
||||||
|
// Note that intersection of shape might actually be
|
||||||
|
// in a neighbouring box. For findAny this is not important.
|
||||||
|
if (hit)
|
||||||
|
{
|
||||||
|
// Hit so pt is nearer than nearestPoint.
|
||||||
|
// Update hit info
|
||||||
|
hitInfo.setHit();
|
||||||
|
hitInfo.setIndex(shapeI);
|
||||||
|
hitInfo.setPoint(pt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Find nearest intersection
|
||||||
|
|
||||||
|
const treeBoundBox octantBb(subBbox(nodeI, octant));
|
||||||
|
|
||||||
|
point nearestPoint(end);
|
||||||
|
|
||||||
|
forAll(indices, elemI)
|
||||||
|
{
|
||||||
|
label shapeI = indices[elemI];
|
||||||
|
|
||||||
|
point pt;
|
||||||
|
bool hit = shapes_.intersects
|
||||||
|
(
|
||||||
|
shapeI,
|
||||||
|
start,
|
||||||
|
nearestPoint,
|
||||||
|
pt
|
||||||
|
);
|
||||||
|
|
||||||
|
// Note that intersection of shape might actually be
|
||||||
|
// in a neighbouring box. Since we need to maintain strict
|
||||||
|
// (findAny=false) ordering skip such an intersection. It
|
||||||
|
// will be found when we are doing the next box.
|
||||||
|
|
||||||
|
if (hit && octantBb.contains(pt))
|
||||||
|
{
|
||||||
|
// Hit so pt is nearer than nearestPoint.
|
||||||
|
nearestPoint = pt;
|
||||||
|
// Update hit info
|
||||||
|
hitInfo.setHit();
|
||||||
|
hitInfo.setIndex(shapeI);
|
||||||
|
hitInfo.setPoint(pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitInfo.hit())
|
||||||
|
{
|
||||||
|
// Found intersected shape.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Find nearest intersection.
|
|
||||||
|
|
||||||
point nearestPoint(end);
|
|
||||||
|
|
||||||
forAll(indices, elemI)
|
|
||||||
{
|
|
||||||
label shapeI = indices[elemI];
|
|
||||||
|
|
||||||
point pt;
|
|
||||||
bool hit = shapes_.intersects(shapeI, start, nearestPoint, pt);
|
|
||||||
|
|
||||||
if (hit)
|
|
||||||
{
|
|
||||||
// Hit so pt is nearer than nearestPoint.
|
|
||||||
nearestPoint = pt;
|
|
||||||
// Update hit info
|
|
||||||
hitInfo.setHit();
|
|
||||||
hitInfo.setIndex(shapeI);
|
|
||||||
hitInfo.setPoint(pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hitInfo.hit())
|
|
||||||
{
|
|
||||||
// Found intersected shape.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing intersected in this node
|
// Nothing intersected in this node
|
||||||
|
|||||||
Reference in New Issue
Block a user