mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
triangle intersection return value
This commit is contained in:
@ -166,8 +166,8 @@ public:
|
|||||||
const intersection::direction dir = intersection::VECTOR
|
const intersection::direction dir = intersection::VECTOR
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Fast intersection with a ray. Distance is normal distance
|
//- Fast intersection with a ray. Distance is normalised distance
|
||||||
// to the intersection.
|
// to the intersection (normalised with the vector magnitude).
|
||||||
// For a hit, the distance is signed. Positive number
|
// For a hit, the distance is signed. Positive number
|
||||||
// represents the point in front of triangle. In case of miss
|
// represents the point in front of triangle. In case of miss
|
||||||
// pointHit position is undefined.
|
// pointHit position is undefined.
|
||||||
|
|||||||
@ -73,7 +73,7 @@ Foam::scalar Foam::ExactParticle<ParticleType>::trackToFace
|
|||||||
const labelList& cFaces = mesh.cells()[this->celli_];
|
const labelList& cFaces = mesh.cells()[this->celli_];
|
||||||
|
|
||||||
point intersection(vector::zero);
|
point intersection(vector::zero);
|
||||||
scalar distanceSqr = VGREAT;
|
scalar trackFraction = VGREAT;
|
||||||
label hitFacei = -1;
|
label hitFacei = -1;
|
||||||
|
|
||||||
const vector vec = endPosition-this->position_;
|
const vector vec = endPosition-this->position_;
|
||||||
@ -93,16 +93,11 @@ Foam::scalar Foam::ExactParticle<ParticleType>::trackToFace
|
|||||||
intersection::HALF_RAY
|
intersection::HALF_RAY
|
||||||
);
|
);
|
||||||
|
|
||||||
if (inter.hit())
|
if (inter.hit() && inter.distance() < trackFraction)
|
||||||
{
|
{
|
||||||
scalar s = magSqr(inter.hitPoint()-this->position_);
|
trackFraction = inter.distance();
|
||||||
|
hitFacei = facei;
|
||||||
if (s < distanceSqr)
|
intersection = inter.hitPoint();
|
||||||
{
|
|
||||||
distanceSqr = s;
|
|
||||||
hitFacei = facei;
|
|
||||||
intersection = inter.hitPoint();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,12 +113,10 @@ Foam::scalar Foam::ExactParticle<ParticleType>::trackToFace
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
scalar trackFraction = Foam::sqrt(distanceSqr/magSqr(vec));
|
|
||||||
|
|
||||||
if (trackFraction >= (1.0-SMALL))
|
if (trackFraction >= (1.0-SMALL))
|
||||||
{
|
{
|
||||||
// Nearest intersection beyond endPosition so we hit endPosition.
|
// Nearest intersection beyond endPosition so we hit endPosition.
|
||||||
|
trackFraction = 1.0;
|
||||||
this->position_ = endPosition;
|
this->position_ = endPosition;
|
||||||
this->facei_ = -1;
|
this->facei_ = -1;
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|||||||
@ -528,7 +528,7 @@ bool Foam::treeDataFace::intersects
|
|||||||
intersection::HALF_RAY
|
intersection::HALF_RAY
|
||||||
);
|
);
|
||||||
|
|
||||||
if (inter.hit() && magSqr(inter.hitPoint()-start) <= magSqr(dir))
|
if (inter.hit() && inter.distance() <= 1)
|
||||||
{
|
{
|
||||||
// Note: no extra test on whether intersection is in front of us
|
// Note: no extra test on whether intersection is in front of us
|
||||||
// since using half_ray
|
// since using half_ray
|
||||||
|
|||||||
@ -456,7 +456,7 @@ bool Foam::treeDataTriSurface::intersects
|
|||||||
indexedOctree<treeDataTriSurface>::perturbTol()
|
indexedOctree<treeDataTriSurface>::perturbTol()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (inter.hit() && magSqr(inter.hitPoint()-start) <= magSqr(dir))
|
if (inter.hit() && inter.distance() <= 1)
|
||||||
{
|
{
|
||||||
// Note: no extra test on whether intersection is in front of us
|
// Note: no extra test on whether intersection is in front of us
|
||||||
// since using half_ray.
|
// since using half_ray.
|
||||||
|
|||||||
Reference in New Issue
Block a user