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:
parent
9bc3036e8a
commit
6a6fc52ef9
@ -110,12 +110,20 @@ bool RigSurfaceResampler::findClosestPointXY( const cvf::Vec3d& tar
|
||||
// Find closest vertices
|
||||
double shortestDistanceSquared = std::numeric_limits<double>::max();
|
||||
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
|
||||
// moving point to same height as target point above
|
||||
cvf::Vec3d p( v.x(), v.y(), targetPoint.z() );
|
||||
double distanceSquared = p.pointDistanceSquared( targetPoint );
|
||||
p.x() = v.x();
|
||||
p.y() = v.y();
|
||||
p.z() = targetPoint.z();
|
||||
|
||||
distanceSquared = p.pointDistanceSquared( targetPoint );
|
||||
if ( distanceSquared < shortestDistanceSquared )
|
||||
{
|
||||
shortestDistanceSquared = distanceSquared;
|
||||
|
Loading…
Reference in New Issue
Block a user