From 16f52152cdd9b9e8d80893c5a0a59e8444cbebd6 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 10 Oct 2021 12:41:42 +0200 Subject: [PATCH] [GL] clang-format. --- GeoLib/AnalyticalGeometry.cpp | 81 ++++++++++--------- GeoLib/DuplicateGeometry.cpp | 6 +- GeoLib/GEOObjects.cpp | 12 +-- .../IO/XmlIO/Boost/BoostXmlGmlInterface.cpp | 6 +- GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp | 6 +- GeoLib/PointVec.cpp | 2 +- GeoLib/Polygon.cpp | 14 ++-- GeoLib/Polyline.cpp | 7 +- GeoLib/SurfaceGrid.cpp | 5 +- 9 files changed, 73 insertions(+), 66 deletions(-) diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index 011835cc159..ecb614bc36b 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -181,8 +181,9 @@ bool lineSegmentIntersect(GeoLib::LineSegment const& s0, return true; } - auto isLineSegmentIntersectingAB = [&v](Eigen::Vector3d const& ap, - std::size_t i) { + auto isLineSegmentIntersectingAB = + [&v](Eigen::Vector3d const& ap, std::size_t i) + { // check if p is located at v=(a,b): (ap = t*v, t in [0,1]) return 0.0 <= ap[i] / v[i] && ap[i] / v[i] <= 1.0; }; @@ -411,8 +412,9 @@ std::unique_ptr<GeoLib::Point> triangleLineIntersection( void computeAndInsertAllIntersectionPoints(GeoLib::PointVec& pnt_vec, std::vector<GeoLib::Polyline*>& plys) { - auto computeSegmentIntersections = [&pnt_vec](GeoLib::Polyline& poly0, - GeoLib::Polyline& poly1) { + auto computeSegmentIntersections = + [&pnt_vec](GeoLib::Polyline& poly0, GeoLib::Polyline& poly1) + { for (auto seg0_it(poly0.begin()); seg0_it != poly0.end(); ++seg0_it) { for (auto seg1_it(poly1.begin()); seg1_it != poly1.end(); ++seg1_it) @@ -504,7 +506,8 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d( // Since orient_ab and orient_abd vanish, a, b, c, d are on the same // line and for this reason it is enough to check the x-component. - auto isPointOnSegment = [](double q, double p0, double p1) { + auto isPointOnSegment = [](double q, double p0, double p1) + { double const t((q - p0) / (p1 - p0)); return 0 <= t && t <= 1; }; @@ -580,7 +583,8 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d( // the function checks if the point c is onto the line segment (a,b) auto isCollinearPointOntoLineSegment = [](MathLib::Point3d const& a, MathLib::Point3d const& b, - MathLib::Point3d const& c) { + MathLib::Point3d const& c) + { if (b[0] - a[0] != 0) { double const t = (c[0] - a[0]) / (b[0] - a[0]); @@ -655,39 +659,40 @@ void sortSegments(MathLib::Point3d const& seg_beg_pnt, auto findNextSegment = [&eps](MathLib::Point3d const& seg_beg_pnt, std::vector<GeoLib::LineSegment>& sub_segments, - std::vector<GeoLib::LineSegment>::iterator& sub_seg_it) { - if (sub_seg_it == sub_segments.end()) - { - return; - } - // find appropriate segment for the given segment begin point - auto act_beg_seg_it = std::find_if( - sub_seg_it, sub_segments.end(), - [&seg_beg_pnt, &eps](GeoLib::LineSegment const& seg) { - return MathLib::sqrDist(seg_beg_pnt, seg.getBeginPoint()) < - eps || - MathLib::sqrDist(seg_beg_pnt, seg.getEndPoint()) < - eps; - }); - if (act_beg_seg_it == sub_segments.end()) - { - return; - } - // if necessary correct orientation of segment, i.e. swap beg and - // end - if (MathLib::sqrDist(seg_beg_pnt, act_beg_seg_it->getEndPoint()) < - MathLib::sqrDist(seg_beg_pnt, act_beg_seg_it->getBeginPoint())) - { - std::swap(act_beg_seg_it->getBeginPoint(), - act_beg_seg_it->getEndPoint()); - } - assert(sub_seg_it != sub_segments.end()); - // exchange segments within the container - if (sub_seg_it != act_beg_seg_it) + std::vector<GeoLib::LineSegment>::iterator& sub_seg_it) + { + if (sub_seg_it == sub_segments.end()) + { + return; + } + // find appropriate segment for the given segment begin point + auto act_beg_seg_it = std::find_if( + sub_seg_it, sub_segments.end(), + [&seg_beg_pnt, &eps](GeoLib::LineSegment const& seg) { - std::swap(*sub_seg_it, *act_beg_seg_it); - } - }; + return MathLib::sqrDist(seg_beg_pnt, seg.getBeginPoint()) < + eps || + MathLib::sqrDist(seg_beg_pnt, seg.getEndPoint()) < eps; + }); + if (act_beg_seg_it == sub_segments.end()) + { + return; + } + // if necessary correct orientation of segment, i.e. swap beg and + // end + if (MathLib::sqrDist(seg_beg_pnt, act_beg_seg_it->getEndPoint()) < + MathLib::sqrDist(seg_beg_pnt, act_beg_seg_it->getBeginPoint())) + { + std::swap(act_beg_seg_it->getBeginPoint(), + act_beg_seg_it->getEndPoint()); + } + assert(sub_seg_it != sub_segments.end()); + // exchange segments within the container + if (sub_seg_it != act_beg_seg_it) + { + std::swap(*sub_seg_it, *act_beg_seg_it); + } + }; // find start segment auto seg_it = sub_segments.begin(); diff --git a/GeoLib/DuplicateGeometry.cpp b/GeoLib/DuplicateGeometry.cpp index 45d40cb609e..3e51e0df415 100644 --- a/GeoLib/DuplicateGeometry.cpp +++ b/GeoLib/DuplicateGeometry.cpp @@ -42,9 +42,9 @@ void DuplicateGeometry::duplicate(std::string const& input_name) auto new_pnts = std::make_unique<std::vector<GeoLib::Point*>>(); new_pnts->reserve(pnts->size()); - std::transform( - pnts->cbegin(), pnts->cend(), std::back_inserter(*new_pnts), - [](GeoLib::Point* point) { return new GeoLib::Point(*point); }); + std::transform(pnts->cbegin(), pnts->cend(), std::back_inserter(*new_pnts), + [](GeoLib::Point* point) + { return new GeoLib::Point(*point); }); auto pnt_name_id_map = std::make_unique<std::map<std::string, std::size_t>>( _geo_objects.getPointVecObj(input_name)->getNameIDMapBegin(), _geo_objects.getPointVecObj(input_name)->getNameIDMapEnd()); diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 0465821bcc9..2b74d49b598 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -131,11 +131,13 @@ void GEOObjects::addStationVec(std::unique_ptr<std::vector<Point*>> stations, const std::vector<GeoLib::Point*>* GEOObjects::getStationVec( const std::string& name) const { - 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; - }); + 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)) { return (*it)->getVector(); diff --git a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp index e85a2a7f2dc..b672fbe198a 100644 --- a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp @@ -172,7 +172,8 @@ void BoostXmlGmlInterface::readPolylines( ply_names, *p_name, polylines.size() - 1, "The polyline name is not unique."); - auto accessOrError = [this, &p_name](auto pt_idx) { + auto accessOrError = [this, &p_name](auto pt_idx) + { auto search = _idx_map.find(pt_idx); if (search == _idx_map.end()) { @@ -244,7 +245,8 @@ void BoostXmlGmlInterface::readSurfaces( //! \ogs_file_attr{gml__surfaces__surface__element__p3} element.getConfigAttribute<std::size_t>("p3"); - auto accessOrError = [this, &s_name](std::size_t pt_idx) { + auto accessOrError = [this, &s_name](std::size_t pt_idx) + { auto search = _idx_map.find(pt_idx); if (search == _idx_map.end()) { diff --git a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp index 9b1fb214e5e..2e3b4e26b30 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp @@ -238,7 +238,8 @@ void XmlGmlInterface::readPolylines( } QDomElement point = polyline.firstChildElement(); - auto accessOrError = [this, &polyline](auto pt_idx) { + auto accessOrError = [this, &polyline](auto pt_idx) + { auto search = _idx_map.find(pt_idx); if (search == _idx_map.end()) { @@ -284,7 +285,8 @@ void XmlGmlInterface::readSurfaces( surface.attribute("name").toStdString(), surfaces->size() - 1)); } - auto accessOrError = [this, &surface](auto pt_idx) { + auto accessOrError = [this, &surface](auto pt_idx) + { auto search = _idx_map.find(pt_idx); if (search == _idx_map.end()) { diff --git a/GeoLib/PointVec.cpp b/GeoLib/PointVec.cpp index 2580e03cb86..6ae00fa0dfb 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -256,7 +256,7 @@ void PointVec::resetInternalDataStructures() { auto const& min(_aabb.getMinPoint()); auto const& max(_aabb.getMaxPoint()); - double const rel_eps(_rel_eps / (max-min).norm()); + double const rel_eps(_rel_eps / (max - min).norm()); _aabb = GeoLib::AABB(_data_vec->begin(), _data_vec->end()); diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index f87d194e06f..40e1ab41fcf 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -174,9 +174,8 @@ bool Polygon::containsSegment(GeoLib::LineSegment const& segment) const // Sorting the intersection with respect to the distance to the point a. // This induces a partition of the line segment into sub segments. std::sort(s.begin(), s.end(), - [&a](GeoLib::Point const& p0, GeoLib::Point const& p1) { - return MathLib::sqrDist(a, p0) < MathLib::sqrDist(a, p1); - }); + [&a](GeoLib::Point const& p0, GeoLib::Point const& p1) + { return MathLib::sqrDist(a, p0) < MathLib::sqrDist(a, p1); }); // remove sub segments with almost zero length for (std::size_t k(0); k < s.size() - 1;) @@ -215,9 +214,9 @@ bool Polygon::containsSegment(GeoLib::LineSegment const& segment) const bool Polygon::isPolylineInPolygon(const Polyline& ply) const { - return std::all_of(ply.begin(), ply.end(), [this](auto const& segment) { - return containsSegment(segment); - }); + return std::all_of(ply.begin(), ply.end(), + [this](auto const& segment) + { return containsSegment(segment); }); } bool Polygon::isPartOfPolylineInPolygon(const Polyline& ply) const @@ -232,7 +231,8 @@ bool Polygon::isPartOfPolylineInPolygon(const Polyline& ply) const } } - auto polygon_segment_intersects_line = [&](auto const& polygon_seg) { + auto polygon_segment_intersects_line = [&](auto const& polygon_seg) + { GeoLib::Point s; return std::any_of(ply.begin(), ply.end(), [&polygon_seg, &s](auto const& polyline_seg) { diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index 4158093b4e6..d8b7795fb15 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -24,13 +24,10 @@ namespace GeoLib { -Polyline::Polyline(const std::vector<Point*>& pnt_vec) : _ply_pnts(pnt_vec) -{ -} +Polyline::Polyline(const std::vector<Point*>& pnt_vec) : _ply_pnts(pnt_vec) {} Polyline::Polyline(const Polyline& ply) - : _ply_pnts(ply._ply_pnts), - _ply_pnt_ids(ply._ply_pnt_ids) + : _ply_pnts(ply._ply_pnts), _ply_pnt_ids(ply._ply_pnt_ids) { } diff --git a/GeoLib/SurfaceGrid.cpp b/GeoLib/SurfaceGrid.cpp index a2677bfb123..1b98bef4641 100644 --- a/GeoLib/SurfaceGrid.cpp +++ b/GeoLib/SurfaceGrid.cpp @@ -259,9 +259,8 @@ bool SurfaceGrid::isPointInSurface(MathLib::Point3d const& pnt, std::vector<Triangle const*> const& triangles( _triangles_in_grid_box[grid_cell_idx]); auto const it = std::find_if(triangles.begin(), triangles.end(), - [eps, pnt](auto const* triangle) { - return triangle->containsPoint(pnt, eps); - }); + [eps, pnt](auto const* triangle) + { return triangle->containsPoint(pnt, eps); }); return it != triangles.end(); } -- GitLab