From 797cec9fc898d3cad86dbeeba3979f543f88bc59 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Wed, 8 Jul 2015 08:39:42 +0200 Subject: [PATCH] [MGTL] Prevent creating temporary object in grid.getNearestPoint(). --- MeshGeoToolsLib/GeoMapper.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 3f7914d61ca..e381b7464aa 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -217,9 +217,10 @@ void GeoMapper::advancedMapOnMesh(const MeshLib::Mesh* mesh, const std::string & std::vector<double> dist(nMeshNodes); // distance between geo points and mesh nodes in (x,y)-plane for (std::size_t i=0; i<nMeshNodes; ++i) { - const double zero_coords[3] = {(* mesh->getNode(i))[0], (* mesh->getNode(i))[1], 0.0}; + auto const zero_coords = GeoLib::Point((*mesh->getNode(i))[0], + (*mesh->getNode(i))[1], 0.0, mesh->getNode(i)->getID()); GeoLib::Point* pnt = grid.getNearestPoint(zero_coords); - dist[i] = MathLib::sqrDist(pnt->getCoords(), zero_coords); + dist[i] = MathLib::sqrDist(*pnt, zero_coords); closest_geo_point[i] = (dist[i]<=max_segment_length) ? getIndexInPntVec(pnt, new_points) : -1; } -- GitLab