mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Janitor : Performance improvements identified by profiling
This commit is contained in:
@@ -110,12 +110,20 @@ bool RigSurfaceResampler::findClosestPointXY( const cvf::Vec3d& tar
|
|||||||
// Find closest vertices
|
// Find closest vertices
|
||||||
double shortestDistanceSquared = std::numeric_limits<double>::max();
|
double shortestDistanceSquared = std::numeric_limits<double>::max();
|
||||||
double closestZ = std::numeric_limits<double>::infinity();
|
double closestZ = std::numeric_limits<double>::infinity();
|
||||||
for ( auto v : vertices )
|
cvf::Vec3d p;
|
||||||
|
double distanceSquared = 0.0;
|
||||||
|
for ( const auto& v : vertices )
|
||||||
{
|
{
|
||||||
|
if ( std::fabs( targetPoint.x() - v.x() ) > maxDistance ) continue;
|
||||||
|
if ( std::fabs( targetPoint.y() - v.y() ) > maxDistance ) continue;
|
||||||
|
|
||||||
// Ignore height (z) component when finding closest by
|
// Ignore height (z) component when finding closest by
|
||||||
// moving point to same height as target point above
|
// moving point to same height as target point above
|
||||||
cvf::Vec3d p( v.x(), v.y(), targetPoint.z() );
|
p.x() = v.x();
|
||||||
double distanceSquared = p.pointDistanceSquared( targetPoint );
|
p.y() = v.y();
|
||||||
|
p.z() = targetPoint.z();
|
||||||
|
|
||||||
|
distanceSquared = p.pointDistanceSquared( targetPoint );
|
||||||
if ( distanceSquared < shortestDistanceSquared )
|
if ( distanceSquared < shortestDistanceSquared )
|
||||||
{
|
{
|
||||||
shortestDistanceSquared = distanceSquared;
|
shortestDistanceSquared = distanceSquared;
|
||||||
|
|||||||
Reference in New Issue
Block a user