mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: vector mag(), magSqr() methods - complementary to dist(), distSqr()
ENH: use direct access to pointHit as point(), use dist(), distSqr() - if the pointHit has already been checked for hit(), can/should simply use point() noexcept access subsequently to avoid redundant checks. Using vector distSqr() methods provides a minor optimization (no itermediate temporary), but can also make for clearer code. ENH: copy construct pointIndexHit with different index - symmetric with constructing from a pointHit with an index STYLE: prefer pointHit point() instead of rawPoint()
This commit is contained in:
committed by
Andrew Heather
parent
5ec435aca3
commit
27c2cdc040
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -258,7 +258,7 @@ public:
|
||||
{
|
||||
nearestDistSqr = distSqr;
|
||||
minIndex = index;
|
||||
nearestPoint = nearHit.rawPoint();
|
||||
nearestPoint = nearHit.point();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -420,8 +420,8 @@ int main(int argc, char *argv[])
|
||||
!nearestHit.hit()
|
||||
||
|
||||
(
|
||||
magSqr(currentHit.hitPoint() - samplePt)
|
||||
< magSqr(nearestHit.hitPoint() - samplePt)
|
||||
currentHit.point().distSqr(samplePt)
|
||||
< nearestHit.point().distSqr(samplePt)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -431,8 +431,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
scalar dist2 = magSqr(nearestHit.rawPoint() - samplePt);
|
||||
|
||||
if (nearestHit.hit())
|
||||
{
|
||||
// bool rejectEdge =
|
||||
@ -444,7 +442,9 @@ int main(int argc, char *argv[])
|
||||
// 30
|
||||
// );
|
||||
|
||||
if (dist2 > Foam::sqr(dist))
|
||||
scalar distSqr = nearestHit.point().distSqr(samplePt);
|
||||
|
||||
if (distSqr > Foam::sqr(dist))
|
||||
{
|
||||
nearestHit.setMiss();
|
||||
}
|
||||
@ -491,11 +491,11 @@ int main(int argc, char *argv[])
|
||||
if
|
||||
(
|
||||
(
|
||||
magSqr(pt - hitSurf.localPoints()[e.start()])
|
||||
pt.distSqr(hitSurf.localPoints()[e.start()])
|
||||
< matchTolerance
|
||||
)
|
||||
|| (
|
||||
magSqr(pt - hitSurf.localPoints()[e.end()])
|
||||
pt.distSqr(hitSurf.localPoints()[e.end()])
|
||||
< matchTolerance
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user