src/OpenFOAM: Rationalised use of enumerations by using the C++11 scoped form
for triangle intersection.
This commit is contained in:
@ -910,14 +910,14 @@ void Foam::starMesh::createCoupleMatches()
|
||||
pointStart,
|
||||
masterProjDir,
|
||||
points_,
|
||||
intersection::FULL_RAY
|
||||
intersection::algorithm::fullRay
|
||||
).hit()
|
||||
&& newMasterFace.ray
|
||||
(
|
||||
pointEnd,
|
||||
masterProjDir,
|
||||
points_,
|
||||
intersection::FULL_RAY
|
||||
intersection::algorithm::fullRay
|
||||
).hit()
|
||||
)
|
||||
{
|
||||
@ -953,14 +953,14 @@ void Foam::starMesh::createCoupleMatches()
|
||||
pointStart,
|
||||
slaveProjDir,
|
||||
points_,
|
||||
intersection::FULL_RAY
|
||||
intersection::algorithm::fullRay
|
||||
).hit()
|
||||
&& newSlaveFace.ray
|
||||
(
|
||||
pointEnd,
|
||||
slaveProjDir,
|
||||
points_,
|
||||
intersection::FULL_RAY
|
||||
intersection::algorithm::fullRay
|
||||
).hit()
|
||||
)
|
||||
{
|
||||
@ -1324,7 +1324,7 @@ void Foam::starMesh::createCoupleMatches()
|
||||
points_[intersectedFace[intPointi]],
|
||||
pointProjectionNormal,
|
||||
points_,
|
||||
intersection::FULL_RAY
|
||||
intersection::algorithm::fullRay
|
||||
);
|
||||
|
||||
if (projHit.hit())
|
||||
|
||||
@ -111,7 +111,7 @@
|
||||
mergePatchPairs[pairI].second(),
|
||||
slidingInterface::INTEGRAL, // always integral
|
||||
false,
|
||||
intersection::VISIBLE
|
||||
intersection::algorithm::visible
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(treeDataCell, 0);
|
||||
defineTypeNameAndDebug(treeDataCell, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -253,7 +253,7 @@ bool Foam::treeDataCell::findIntersectOp::operator()
|
||||
|
||||
if ((cellBb.posBits(start) & cellBb.posBits(end)) != 0)
|
||||
{
|
||||
// start and end in same block outside of cellBb.
|
||||
// Start and end in same block outside of cellBb.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -263,7 +263,7 @@ bool Foam::treeDataCell::findIntersectOp::operator()
|
||||
|
||||
if ((cellBb.posBits(start) & cellBb.posBits(end)) != 0)
|
||||
{
|
||||
// start and end in same block outside of cellBb.
|
||||
// Start and end in same block outside of cellBb.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -290,7 +290,7 @@ bool Foam::treeDataCell::findIntersectOp::operator()
|
||||
start,
|
||||
dir,
|
||||
shape.mesh_.points(),
|
||||
intersection::HALF_RAY
|
||||
intersection::algorithm::halfRay
|
||||
);
|
||||
|
||||
if (inter.hit() && sqr(inter.distance()) <= minDistSqr)
|
||||
|
||||
@ -100,7 +100,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
|
||||
);
|
||||
|
||||
// Grab distance to target
|
||||
if (dir_ == intersection::CONTACT_SPHERE)
|
||||
if (dir_ == intersection::direction::contactSphere)
|
||||
{
|
||||
pointDistance[pointi] =
|
||||
hitFace.contactSphereDiameter
|
||||
@ -179,7 +179,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
|
||||
hitPoint = ph.missPoint();
|
||||
|
||||
// Grab distance to target
|
||||
if (dir_ == intersection::CONTACT_SPHERE)
|
||||
if (dir_ == intersection::direction::contactSphere)
|
||||
{
|
||||
pointDistance[pointi] =
|
||||
hitFace.contactSphereDiameter
|
||||
|
||||
@ -158,8 +158,8 @@ public:
|
||||
(
|
||||
const FromPatch& fromPatch,
|
||||
const ToPatch& toPatch,
|
||||
const intersection::algorithm alg = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
const intersection::algorithm alg = intersection::algorithm::fullRay,
|
||||
const intersection::direction dir = intersection::direction::vector
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -247,8 +247,10 @@ public:
|
||||
const point& p,
|
||||
const vector& n,
|
||||
const pointField&,
|
||||
const intersection::algorithm alg = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
const intersection::algorithm alg =
|
||||
intersection::algorithm::fullRay,
|
||||
const intersection::direction dir =
|
||||
intersection::direction::vector
|
||||
) const;
|
||||
|
||||
//- Fast intersection with a ray.
|
||||
|
||||
@ -158,8 +158,8 @@ public:
|
||||
const point& p,
|
||||
const vector& q,
|
||||
const pointField& points,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
const intersection::algorithm = intersection::algorithm::fullRay,
|
||||
const intersection::direction dir = intersection::direction::vector
|
||||
) const;
|
||||
|
||||
//- Fast intersection with a ray.
|
||||
|
||||
@ -399,8 +399,10 @@ public:
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction = intersection::VECTOR
|
||||
const intersection::algorithm =
|
||||
intersection::algorithm::fullRay,
|
||||
const intersection::direction =
|
||||
intersection::direction::vector
|
||||
) const;
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
@ -409,8 +411,10 @@ public:
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction = intersection::VECTOR
|
||||
const intersection::algorithm =
|
||||
intersection::algorithm::fullRay,
|
||||
const intersection::direction =
|
||||
intersection::direction::vector
|
||||
) const;
|
||||
|
||||
//- Return list of closed loops of boundary vertices.
|
||||
|
||||
@ -49,8 +49,6 @@ namespace Foam
|
||||
|
||||
class intersection
|
||||
{
|
||||
private:
|
||||
|
||||
// Static data
|
||||
|
||||
//- Relative tolerance for point in a plane.
|
||||
@ -61,17 +59,17 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
enum direction
|
||||
enum class direction
|
||||
{
|
||||
VECTOR,
|
||||
CONTACT_SPHERE
|
||||
vector,
|
||||
contactSphere
|
||||
};
|
||||
|
||||
enum algorithm
|
||||
enum class algorithm
|
||||
{
|
||||
FULL_RAY, // Intersecting with full ray
|
||||
HALF_RAY, // Intersecting with half ray
|
||||
VISIBLE // Intersecting with the visible side
|
||||
fullRay, // Intersecting with full ray
|
||||
halfRay, // Intersecting with half ray
|
||||
visible // Intersecting with the visible side
|
||||
};
|
||||
|
||||
// Static Member Functions
|
||||
@ -93,8 +91,7 @@ public:
|
||||
{
|
||||
if (t < -vSmall)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< abort(FatalError);
|
||||
FatalErrorInFunction << abort(FatalError);
|
||||
}
|
||||
|
||||
scalar oldTol = planarTol_;
|
||||
|
||||
@ -190,14 +190,14 @@ public:
|
||||
(
|
||||
const point& p,
|
||||
const vector& q,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
const intersection::algorithm = intersection::algorithm::fullRay,
|
||||
const intersection::direction dir = intersection::direction::vector
|
||||
) const;
|
||||
|
||||
//- Fast intersection with a ray.
|
||||
// For a hit, the pointHit.distance() is the line parameter t :
|
||||
// intersection=p+t*q. Only defined for VISIBLE, FULL_RAY or
|
||||
// HALF_RAY. tol increases the virtual size of the triangle
|
||||
// intersection=p+t*q. Only defined for algorithm::visible, algorithm::fullRay or
|
||||
// algorithm::halfRay. tol increases the virtual size of the triangle
|
||||
// by a relative factor.
|
||||
inline pointHit intersection
|
||||
(
|
||||
|
||||
@ -343,11 +343,11 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::ray
|
||||
|
||||
const vector q1 = q/Foam::mag(q);
|
||||
|
||||
if (dir == intersection::CONTACT_SPHERE)
|
||||
if (dir == intersection::direction::contactSphere)
|
||||
{
|
||||
n /= magArea;
|
||||
|
||||
return ray(p, q1 - n, alg, intersection::VECTOR);
|
||||
return ray(p, q1 - n, alg, intersection::direction::vector);
|
||||
}
|
||||
|
||||
// Intersection point with triangle plane
|
||||
@ -356,9 +356,14 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::ray
|
||||
// Is intersection point inside triangle
|
||||
bool hit;
|
||||
{
|
||||
// Reuse the fast ray intersection routine below in FULL_RAY
|
||||
// Reuse the fast ray intersection routine below in algorithm::fullRay
|
||||
// mode since the original intersection routine has rounding problems.
|
||||
pointHit fastInter = intersection(p, q1, intersection::FULL_RAY);
|
||||
pointHit fastInter = intersection
|
||||
(
|
||||
p,
|
||||
q1,
|
||||
intersection::algorithm::fullRay
|
||||
);
|
||||
hit = fastInter.hit();
|
||||
|
||||
if (hit)
|
||||
@ -388,10 +393,10 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::ray
|
||||
)*intersection::planarTol();
|
||||
|
||||
bool eligible =
|
||||
alg == intersection::FULL_RAY
|
||||
|| (alg == intersection::HALF_RAY && dist > -planarPointTol)
|
||||
alg == intersection::algorithm::fullRay
|
||||
|| (alg == intersection::algorithm::halfRay && dist > -planarPointTol)
|
||||
|| (
|
||||
alg == intersection::VISIBLE
|
||||
alg == intersection::algorithm::visible
|
||||
&& ((q1 & area()) < -vSmall)
|
||||
);
|
||||
|
||||
@ -433,16 +438,16 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::intersection
|
||||
const vector edge1 = b_ - a_;
|
||||
const vector edge2 = c_ - a_;
|
||||
|
||||
// begin calculating determinant - also used to calculate U parameter
|
||||
// Begin calculating determinant - also used to calculate U parameter
|
||||
const vector pVec = dir ^ edge2;
|
||||
|
||||
// if determinant is near zero, ray lies in plane of triangle
|
||||
// Ff determinant is near zero, ray lies in plane of triangle
|
||||
const scalar det = edge1 & pVec;
|
||||
|
||||
// Initialise to miss
|
||||
pointHit intersection(false, Zero, great, false);
|
||||
|
||||
if (alg == intersection::VISIBLE)
|
||||
if (alg == intersection::algorithm::visible)
|
||||
{
|
||||
// Culling branch
|
||||
if (det < rootVSmall)
|
||||
@ -451,7 +456,11 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::intersection
|
||||
return intersection;
|
||||
}
|
||||
}
|
||||
else if (alg == intersection::HALF_RAY || alg == intersection::FULL_RAY)
|
||||
else if
|
||||
(
|
||||
alg == intersection::algorithm::halfRay
|
||||
|| alg == intersection::algorithm::fullRay
|
||||
)
|
||||
{
|
||||
// Non-culling branch
|
||||
if (det > -rootVSmall && det < rootVSmall)
|
||||
@ -463,10 +472,10 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::intersection
|
||||
|
||||
const scalar inv_det = 1.0 / det;
|
||||
|
||||
/* calculate distance from a_ to ray origin */
|
||||
// Calculate distance from a_ to ray origin
|
||||
const vector tVec = orig-a_;
|
||||
|
||||
/* calculate U parameter and test bounds */
|
||||
// Calculate U parameter and test bounds
|
||||
const scalar u = (tVec & pVec)*inv_det;
|
||||
|
||||
if (u < -tol || u > 1.0+tol)
|
||||
@ -475,10 +484,10 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::intersection
|
||||
return intersection;
|
||||
}
|
||||
|
||||
/* prepare to test V parameter */
|
||||
// Prepare to test V parameter
|
||||
const vector qVec = tVec ^ edge1;
|
||||
|
||||
/* calculate V parameter and test bounds */
|
||||
// Calculate V parameter and test bounds
|
||||
const scalar v = (dir & qVec) * inv_det;
|
||||
|
||||
if (v < -tol || u + v > 1.0+tol)
|
||||
@ -487,10 +496,10 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::intersection
|
||||
return intersection;
|
||||
}
|
||||
|
||||
/* calculate t, scale parameters, ray intersects triangle */
|
||||
// Calculate t, scale parameters, ray intersects triangle
|
||||
const scalar t = (edge2 & qVec) * inv_det;
|
||||
|
||||
if (alg == intersection::HALF_RAY && t < -tol)
|
||||
if (alg == intersection::algorithm::halfRay && t < -tol)
|
||||
{
|
||||
// Wrong side of orig. Return miss
|
||||
return intersection;
|
||||
@ -693,7 +702,7 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::nearestPoint
|
||||
(
|
||||
ln.start(),
|
||||
q,
|
||||
intersection::FULL_RAY
|
||||
intersection::algorithm::fullRay
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -325,7 +325,7 @@ public:
|
||||
const word& slavePatchName,
|
||||
const typeOfMatch tom,
|
||||
const bool coupleDecouple = false,
|
||||
const intersection::algorithm algo = intersection::VISIBLE
|
||||
const intersection::algorithm algo = intersection::algorithm::visible
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
|
||||
@ -1240,7 +1240,7 @@ const
|
||||
const face& f = srcPatch[srcFacei];
|
||||
|
||||
const pointHit ray =
|
||||
f.ray(tgtPoint, n, srcPoints, intersection::VISIBLE);
|
||||
f.ray(tgtPoint, n, srcPoints, intersection::algorithm::visible);
|
||||
|
||||
if (ray.hit())
|
||||
{
|
||||
@ -1291,7 +1291,7 @@ const
|
||||
const face& f = tgtPatch[tgtFacei];
|
||||
|
||||
const pointHit ray =
|
||||
f.ray(srcPoint, n, tgtPoints, intersection::VISIBLE);
|
||||
f.ray(srcPoint, n, tgtPoints, intersection::algorithm::visible);
|
||||
|
||||
if (ray.hit())
|
||||
{
|
||||
|
||||
@ -568,7 +568,7 @@ bool Foam::treeDataFace::findIntersectOp::operator()
|
||||
dir,
|
||||
shape.mesh_.faceCentres()[facei],
|
||||
shape.mesh_.points(),
|
||||
intersection::HALF_RAY
|
||||
intersection::algorithm::halfRay
|
||||
);
|
||||
|
||||
if (inter.hit() && inter.distance() <= 1)
|
||||
|
||||
@ -644,7 +644,7 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findIntersection
|
||||
points[f[0]],
|
||||
points[f[1]],
|
||||
points[f[2]]
|
||||
).intersection(start, dir, intersection::HALF_RAY, shape.planarTol_);
|
||||
).intersection(start, dir, intersection::algorithm::halfRay, shape.planarTol_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -656,7 +656,7 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findIntersection
|
||||
dir,
|
||||
faceCentres[index],
|
||||
points,
|
||||
intersection::HALF_RAY,
|
||||
intersection::algorithm::halfRay,
|
||||
shape.planarTol_
|
||||
);
|
||||
}
|
||||
|
||||
@ -1362,7 +1362,7 @@ Foam::pointIndexHit Foam::mappedPatchBase::facePoint
|
||||
(
|
||||
cc,
|
||||
d,
|
||||
intersection::HALF_RAY
|
||||
intersection::algorithm::halfRay
|
||||
);
|
||||
|
||||
if (hitInfo.hit() && hitInfo.distance() > 0)
|
||||
|
||||
Reference in New Issue
Block a user