diff --git a/MeshGeoToolsLib/BoundaryElementsSearcher.cpp b/MeshGeoToolsLib/BoundaryElementsSearcher.cpp index 58d7f133bd84710a613da3bbed8cd65eaf8708dc..8ab6ea1e5b60ff9fc9e8cfd3a4e49d92f06ed5d2 100644 --- a/MeshGeoToolsLib/BoundaryElementsSearcher.cpp +++ b/MeshGeoToolsLib/BoundaryElementsSearcher.cpp @@ -82,33 +82,40 @@ BoundaryElementsSearcher::getBoundaryElementsAtPoint(GeoLib::Point const& point) return _boundary_elements_at_point.back()->getBoundaryElements(); } -std::vector<MeshLib::Element*> const& BoundaryElementsSearcher::getBoundaryElementsAlongPolyline(GeoLib::Polyline const& ply) +std::vector<MeshLib::Element*> const& +BoundaryElementsSearcher::getBoundaryElementsAlongPolyline( + GeoLib::Polyline const& polyline) { - std::vector<BoundaryElementsAlongPolyline*>::const_iterator it(_boundary_elements_along_polylines.begin()); - for (; it != _boundary_elements_along_polylines.end(); ++it) { - if (&(*it)->getPolyline() == &ply) { - // we calculated mesh nodes for this polyline already - return (*it)->getBoundaryElements(); + // look for already saved polylines and return if found. + for (auto const& boundary_elements : _boundary_elements_along_polylines) + { + if (&boundary_elements->getPolyline() == &polyline) + { + return boundary_elements->getBoundaryElements(); } } + // create new boundary elements at points. _boundary_elements_along_polylines.push_back( - new BoundaryElementsAlongPolyline(_mesh, _mshNodeSearcher, ply)); + new BoundaryElementsAlongPolyline(_mesh, _mshNodeSearcher, polyline)); return _boundary_elements_along_polylines.back()->getBoundaryElements(); } -std::vector<MeshLib::Element*> const& BoundaryElementsSearcher::getBoundaryElementsOnSurface(GeoLib::Surface const& sfc) +std::vector<MeshLib::Element*> const& +BoundaryElementsSearcher::getBoundaryElementsOnSurface( + GeoLib::Surface const& surface) { - std::vector<BoundaryElementsOnSurface*>::const_iterator it(_boundary_elements_along_surfaces.begin()); - for (; it != _boundary_elements_along_surfaces.end(); ++it) { - if (&(*it)->getSurface() == &sfc) { - // we calculated mesh nodes for this surface already - return (*it)->getBoundaryElements(); + // look for already saved surfaces and return if found. + for (auto const& boundary_elements : _boundary_elements_along_surfaces) + { + if (&boundary_elements->getSurface() == &surface) + { + return boundary_elements->getBoundaryElements(); } } _boundary_elements_along_surfaces.push_back( - new BoundaryElementsOnSurface(_mesh, _mshNodeSearcher, sfc)); + new BoundaryElementsOnSurface(_mesh, _mshNodeSearcher, surface)); return _boundary_elements_along_surfaces.back()->getBoundaryElements(); }