diff --git a/Applications/FileIO/GocadIO/GocadSGridReader.cpp b/Applications/FileIO/GocadIO/GocadSGridReader.cpp index 5f8b7dd1384785c82bc07948d60fa63c2fef3300..91e70bad385b7563556bd16b6554e6181b9ddf8b 100644 --- a/Applications/FileIO/GocadIO/GocadSGridReader.cpp +++ b/Applications/FileIO/GocadIO/GocadSGridReader.cpp @@ -820,10 +820,8 @@ void GocadSGridReader::addFaceSetQuad( default: ERR("Could not create face for node with id %d.", id); } - for (auto quad_node : quad_nodes) - { - face_set_nodes.push_back(quad_node); - } + std::copy(begin(quad_nodes), end(quad_nodes), + back_inserter(face_set_nodes)); face_set_elements.push_back(new MeshLib::Quad(quad_nodes)); } diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 23809f0e63bf0d2cd46934a53ae87742c571daf3..9902bb96533c2e47ddce878bef611223754cec01 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -120,13 +120,14 @@ void GEOObjects::addStationVec(std::unique_ptr<std::vector<Point*>> stations, const std::vector<GeoLib::Point*>* GEOObjects::getStationVec( const std::string& name) const { - for (auto point : _pnt_vecs) + auto const it = std::find_if( + begin(_pnt_vecs), end(_pnt_vecs), [&name](PointVec const* const p) { + return p->getName() == name && + p->getType() == PointVec::PointType::STATION; + }); + if (it != end(_pnt_vecs)) { - if (point->getName() == name && - point->getType() == PointVec::PointType::STATION) - { - return point->getVector(); - } + return (*it)->getVector(); } DBUG("GEOObjects::getStationVec() - No entry found with name '%s'.", name.c_str()); @@ -283,11 +284,8 @@ bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces, // the copy is needed because addSurfaceVec is passing it to SurfaceVec // ctor, which needs write access to the surface vector. - auto sfc = std::make_unique<std::vector<GeoLib::Surface*>>(); - for (auto surface : surfaces) - { - sfc->push_back(surface); - } + auto sfc = std::make_unique<std::vector<GeoLib::Surface*>>(begin(surfaces), + end(surfaces)); addSurfaceVec(std::move(sfc), name); return false; } diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 21ebfc6da48969869f5bbd8185d227ff5bd39287..f8bd85cdfefc6ffde6ce95db2faf7b3ab961ffe0 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -285,10 +285,8 @@ static std::vector<MathLib::Point3d> computeElementSegmentIntersections( true}; std::vector<MathLib::Point3d> const intersections( GeoLib::lineSegmentIntersect2d(segment, elem_segment)); - for (auto const& p : intersections) - { - element_intersections.push_back(std::move(p)); - } + element_intersections.insert(end(element_intersections), + begin(intersections), end(intersections)); } return element_intersections; } diff --git a/MeshLib/ElementStatus.cpp b/MeshLib/ElementStatus.cpp index 29bdff5e67e7b4c40ed63d2ac465add2a413a3b7..effdd6a0eedb883a9ab59ea164895bb3a81fd817 100644 --- a/MeshLib/ElementStatus.cpp +++ b/MeshLib/ElementStatus.cpp @@ -26,10 +26,9 @@ ElementStatus::ElementStatus(Mesh const* const mesh, bool hasAnyInactive) _hasAnyInactive(hasAnyInactive) { const std::vector<MeshLib::Node*>& nodes(_mesh->getNodes()); - for (auto node : nodes) - { - _active_nodes.push_back(node->getNumberOfElements()); - } + std::transform( + begin(nodes), end(nodes), back_inserter(_active_nodes), + [](Node const* const n) { return n->getNumberOfElements(); }); } ElementStatus::ElementStatus(Mesh const* const mesh, diff --git a/MeshLib/MeshSearch/ElementSearch.cpp b/MeshLib/MeshSearch/ElementSearch.cpp index 2fb71a0697452e8a76ab5f6d7d315dd07b20f357..94627e1be43c47e99edcd31e61d3f6d871e14faf 100644 --- a/MeshLib/MeshSearch/ElementSearch.cpp +++ b/MeshLib/MeshSearch/ElementSearch.cpp @@ -80,9 +80,10 @@ std::size_t ElementSearch::searchByNodeIDs(const std::vector<std::size_t> &nodes std::vector<std::size_t> connected_elements; for (std::size_t node_id : nodes) { - for (auto* e : _mesh.getNode(node_id)->getElements()) { - connected_elements.push_back(e->getID()); - } + auto const& elements = _mesh.getNode(node_id)->getElements(); + std::transform(begin(elements), end(elements), + back_inserter(connected_elements), + [](Element const* const e) { return e->getID(); }); } BaseLib::makeVectorUnique(connected_elements);