Skip to content

Commit

Permalink
Merge branch 'ClangFormat' into 'master'
Browse files Browse the repository at this point in the history
Clang-format

See merge request ogs/ogs!4792
  • Loading branch information
endJunction committed Nov 10, 2023
2 parents 2213cc7 + e727c45 commit 94d1231
Show file tree
Hide file tree
Showing 132 changed files with 680 additions and 610 deletions.
4 changes: 2 additions & 2 deletions BaseLib/StringTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ std::string randomString(std::size_t const length)
0, sizeof(charset) - 2);

std::string s(length, 0);
std::generate_n(
begin(s), length, [&]() { return charset[distribution(generator)]; });
std::generate_n(begin(s), length,
[&]() { return charset[distribution(generator)]; });

return s;
}
Expand Down
35 changes: 18 additions & 17 deletions GeoLib/AnalyticalGeometry-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ std::pair<Eigen::Vector3d, double> getNewellPlane(InputIterator pnts_begin,
{
Eigen::Vector3d plane_normal({0, 0, 0});
Eigen::Vector3d centroid({0, 0, 0});
for (auto i=std::prev(pnts_end), j=pnts_begin; j!=pnts_end; i = j, ++j) {
for (auto i = std::prev(pnts_end), j = pnts_begin; j != pnts_end;
i = j, ++j)
{
auto const& pt_i = *(*i);
auto const& pt_j = *(*j);
plane_normal[0] += (pt_i[1] - pt_j[1])
* (pt_i[2] + pt_j[2]); // projection on yz
plane_normal[1] += (pt_i[2] - pt_j[2])
* (pt_i[0] + pt_j[0]); // projection on xz
plane_normal[2] += (pt_i[0] - pt_j[0])
* (pt_i[1] + pt_j[1]); // projection on xy
plane_normal[0] +=
(pt_i[1] - pt_j[1]) * (pt_i[2] + pt_j[2]); // projection on yz
plane_normal[1] +=
(pt_i[2] - pt_j[2]) * (pt_i[0] + pt_j[0]); // projection on xz
plane_normal[2] +=
(pt_i[0] - pt_j[0]) * (pt_i[1] + pt_j[1]); // projection on xy

centroid += pt_j.asEigenVector3d();
}
Expand Down Expand Up @@ -54,13 +56,14 @@ std::pair<Eigen::Vector3d, double> getNewellPlane(
Eigen::Vector3d plane_normal({0, 0, 0});
Eigen::Vector3d centroid({0, 0, 0});
std::size_t n_pnts(pnts.size());
for (std::size_t i = n_pnts - 1, j = 0; j < n_pnts; i = j, j++) {
plane_normal[0] += (pnts[i][1] - pnts[j][1])
* (pnts[i][2] + pnts[j][2]); // projection on yz
plane_normal[1] += (pnts[i][2] - pnts[j][2])
* (pnts[i][0] + pnts[j][0]); // projection on xz
plane_normal[2] += (pnts[i][0] - pnts[j][0])
* (pnts[i][1] + pnts[j][1]); // projection on xy
for (std::size_t i = n_pnts - 1, j = 0; j < n_pnts; i = j, j++)
{
plane_normal[0] += (pnts[i][1] - pnts[j][1]) *
(pnts[i][2] + pnts[j][2]); // projection on yz
plane_normal[1] += (pnts[i][2] - pnts[j][2]) *
(pnts[i][0] + pnts[j][0]); // projection on xz
plane_normal[2] += (pnts[i][0] - pnts[j][0]) *
(pnts[i][1] + pnts[j][1]); // projection on xy

centroid += pnts[j].asEigenVector3d();
}
Expand All @@ -70,7 +73,6 @@ std::pair<Eigen::Vector3d, double> getNewellPlane(
return std::make_pair(plane_normal, d);
}


template <typename InputIterator>
void rotatePoints(Eigen::Matrix3d const& rot_mat, InputIterator pnts_begin,
InputIterator pnts_end)
Expand Down Expand Up @@ -111,5 +113,4 @@ void rotatePoints(Eigen::Matrix3d const& rot_mat, std::vector<P*> const& pnts)
rotatePoints(rot_mat, pnts.begin(), pnts.end());
}

} // end namespace GeoLib

} // end namespace GeoLib
27 changes: 15 additions & 12 deletions GeoLib/AnalyticalGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,27 @@ bool lineSegmentIntersect(LineSegment const& s0, LineSegment const& s1,
/// containing one point if the line segments intersect in a single point, a
/// vector containing two points describing the line segment the original line
/// segments are interfering.
std::vector<MathLib::Point3d> lineSegmentIntersect2d(
LineSegment const& ab, LineSegment const& cd);
std::vector<MathLib::Point3d> lineSegmentIntersect2d(LineSegment const& ab,
LineSegment const& cd);

/**
* Calculates the intersection points of a line PQ and a triangle ABC.
* This method requires ABC to be counterclockwise and PQ to point downward.
* \return Intersection point or nullptr if there is no intersection.
*/
std::unique_ptr<Point> triangleLineIntersection(
MathLib::Point3d const& a, MathLib::Point3d const& b,
MathLib::Point3d const& c, MathLib::Point3d const& p,
MathLib::Point3d const& q);
std::unique_ptr<Point> triangleLineIntersection(MathLib::Point3d const& a,
MathLib::Point3d const& b,
MathLib::Point3d const& c,
MathLib::Point3d const& p,
MathLib::Point3d const& q);

/**
* Method first computes the intersection points of line segments of Polyline objects
* (@see computeIntersectionPoints()) and pushes each intersection point in the PointVec
* pnt_vec. For each intersection an id is returned. This id is used to split the two
* intersecting straight line segments in four straight line segments.
* Method first computes the intersection points of line segments of Polyline
* objects
* (@see computeIntersectionPoints()) and pushes each intersection point in the
* PointVec pnt_vec. For each intersection an id is returned. This id is used
* to split the two intersecting straight line segments in four straight line
* segments.
*/
void computeAndInsertAllIntersectionPoints(PointVec& pnt_vec,
std::vector<Polyline*>& plys);
Expand All @@ -239,8 +242,8 @@ rotatePolygonPointsToXY(GeoLib::Polygon const& polygon_in);
/// connectable. In order to obtain a unique result the segments are sorted such
/// that the begin point of the first segment is \c seg_beg_pnt.
void sortSegments(MathLib::Point3d const& seg_beg_pnt,
std::vector<LineSegment>& sub_segments);
std::vector<LineSegment>& sub_segments);

} // end namespace GeoLib
} // end namespace GeoLib

#include "AnalyticalGeometry-impl.h"
6 changes: 3 additions & 3 deletions GeoLib/DuplicateGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class Surface;
*/
class DuplicateGeometry final
{

public:
/**
* Creates a copy of a geometry within GEOObjects
* \param geo_objects The container for geometries
* \param input_name The geometry to be copied
* \param output_name The name of the copy (note: this might be modified by GEOObjects)
* \param output_name The name of the copy (note: this might be modified by
* GEOObjects)
*/
DuplicateGeometry(GeoLib::GEOObjects& geo_objects,
std::string const& input_name,
Expand Down Expand Up @@ -62,6 +62,6 @@ class DuplicateGeometry final
std::string _output_name;
GeoLib::GEOObjects& _geo_objects;

}; // class
}; // class

} // namespace GeoLib
Loading

0 comments on commit 94d1231

Please sign in to comment.