From d95325ae58881801e11c8fee9c0b8d4bcf3d346c Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 11 Nov 2021 19:28:55 +0100 Subject: [PATCH] simplify --- .clang-tidy | 1 + Base/Axis/Bin.cpp | 10 ++++------ Base/Axis/VariableBinAxis.cpp | 2 +- Base/Util/FileSystemUtils.cpp | 4 ++-- GUI/ba3d/mesh/sphere.cpp | 6 ++++-- GUI/ba3d/model/geometry.cpp | 12 ++++++++---- GUI/ba3d/model/model.cpp | 12 ++++++------ 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 5e58d895777..3932fd58cde 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -47,6 +47,7 @@ Checks: '*, -fuchsia-statically-constructed-objects, -google-build-using-namespace, -google-default-arguments, +-google-readability-casting, -google-readability-todo, -google-runtime-int, -hicpp-vararg, diff --git a/Base/Axis/Bin.cpp b/Base/Axis/Bin.cpp index 234c68719f8..8a5c5b7653e 100644 --- a/Base/Axis/Bin.cpp +++ b/Base/Axis/Bin.cpp @@ -29,16 +29,14 @@ bool BinContains(const Bin1D& bin, double value) //! creation on Bin1DKVector from alpha and phi bins Bin1DKVector::Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin) - : m_q_lower(), m_q_upper() + : m_q_lower(vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower)) + , m_q_upper(vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper)) { - m_q_lower = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower); - m_q_upper = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper); } //! creation on Bin1DCVector from alpha and phi bins Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin) - : m_q_lower(), m_q_upper() + : m_q_lower(vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower).complex()) + , m_q_upper(vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper).complex()) { - m_q_lower = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower).complex(); - m_q_upper = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper).complex(); } diff --git a/Base/Axis/VariableBinAxis.cpp b/Base/Axis/VariableBinAxis.cpp index a0fc15e1f32..9b913d4200d 100644 --- a/Base/Axis/VariableBinAxis.cpp +++ b/Base/Axis/VariableBinAxis.cpp @@ -133,7 +133,7 @@ bool VariableBinAxis::equals(const IAxis& other) const { if (!IAxis::equals(other)) return false; - if (const VariableBinAxis* p_other_cast = dynamic_cast<const VariableBinAxis*>(&other)) { + if (const auto* p_other_cast = dynamic_cast<const VariableBinAxis*>(&other)) { if (size() != p_other_cast->size()) return false; for (size_t i = 0; i < m_bin_boundaries.size(); ++i) { diff --git a/Base/Util/FileSystemUtils.cpp b/Base/Util/FileSystemUtils.cpp index 1523109ec2e..d491ecbd610 100644 --- a/Base/Util/FileSystemUtils.cpp +++ b/Base/Util/FileSystemUtils.cpp @@ -71,9 +71,9 @@ std::vector<std::string> BaseUtils::Filesystem::filesInDirectory(const std::stri std::string BaseUtils::Filesystem::jointPath(const std::string& path1, const std::string& path2) { - ASSERT(path2 != ""); + ASSERT(!path2.empty()); - if (path1 == "") + if (path1.empty()) return fs::path(path2).string(); return (fs::path(path1) / fs::path(path2)).string(); diff --git a/GUI/ba3d/mesh/sphere.cpp b/GUI/ba3d/mesh/sphere.cpp index 80baf5f932c..0f834413a87 100644 --- a/GUI/ba3d/mesh/sphere.cpp +++ b/GUI/ba3d/mesh/sphere.cpp @@ -30,7 +30,8 @@ Geometry::Mesh Geometry::meshSphere(float cut, float baseShift, float removedTop // 'rings' are the # of horizontal cross-sections ranging from bottom to top of the sphere // 'slices' are the # of vertices in a given ring - int rings, slices = SLICES; + int rings; + int slices = SLICES; float minPh, maxPh, phRge; if (cut > 0) // South pole absent @@ -55,7 +56,8 @@ Geometry::Mesh Geometry::meshSphere(float cut, float baseShift, float removedTop ASSERT(2 <= rings && 2 <= slices); // meshes of vertices and normals, without poles, _[ring][slice] - QVector<Vertices> vs_(rings), ns_(rings); + QVector<Vertices> vs_(rings); + QVector<Vertices> ns_(rings); for (auto& ring : vs_) ring.resize(slices); for (auto& ring : ns_) diff --git a/GUI/ba3d/model/geometry.cpp b/GUI/ba3d/model/geometry.cpp index ca27d9c6e53..f53fe68d5d4 100644 --- a/GUI/ba3d/model/geometry.cpp +++ b/GUI/ba3d/model/geometry.cpp @@ -60,7 +60,7 @@ void Geometry::Vertices::addStrip(const Vertices& vs, const Indices& is) void Geometry::Vertices::addFan(const Vertices& vs, const Indices& is) { ASSERT(is.size() >= 3); // at least one triangle - auto& ctr = vs.at(is.at(0)); + const auto& ctr = vs.at(is.at(0)); for (unsigned i = 0; i + 2 < is.size(); ++i) addTriangle(ctr, vs.at(is.at(1 + i)), vs.at(is.at(2 + i))); } @@ -117,8 +117,12 @@ Geometry::Mesh Geometry::makeMesh(const Vertices& vs, Vertices const* ns) Mesh mesh(nv); for (int i = 0; i < nv; i += 3) { - const Vector3D &v0 = vs.at(0 + i), v1 = vs.at(1 + i), v2 = vs.at(2 + i); - const Vector3D *n0, *n1, *n2; + const Vector3D& v0 = vs.at(0 + i); + const Vector3D& v1 = vs.at(1 + i); + const Vector3D& v2 = vs.at(2 + i); + const Vector3D* n0; + const Vector3D* n1; + const Vector3D* n2; Vector3D nm; if (ns) { @@ -152,7 +156,7 @@ GeometryHandle GeometryStore::getGeometry(GeometricID::Key key) if (auto g = it->second.lock()) return g; } - GeometryHandle g = GeometryHandle(new Geometry(key)); + GeometryHandle g(new Geometry(key)); m_geometries[key] = GeometryRef(g); return g; } diff --git a/GUI/ba3d/model/model.cpp b/GUI/ba3d/model/model.cpp index 61c869e3442..6448ff1d12a 100644 --- a/GUI/ba3d/model/model.cpp +++ b/GUI/ba3d/model/model.cpp @@ -22,12 +22,12 @@ Model::Model() : defCamPos(Vector3D::_1, Vector3D::_0, Vector3D::_z) {} Model::~Model() { - for (auto o : objects) { + for (auto* o : objects) { o->model = nullptr; delete o; } - for (auto o : objectsBlend) { + for (auto* o : objectsBlend) { o->model = nullptr; delete o; } @@ -145,9 +145,9 @@ void Model::rem(Object* o) void Model::releaseGeometries() { - for (auto o : objects) + for (auto* o : objects) o->releaseGeometry(); - for (auto o : objectsBlend) + for (auto* o : objectsBlend) o->releaseGeometry(); } @@ -158,13 +158,13 @@ bool Model::modelIsEmpty() void Model::draw(Canvas& canvas) const { - for (auto o : objects) + for (auto* o : objects) o->draw(canvas); } void Model::drawBlend(Canvas& canvas) const { - for (auto o : objectsBlend) + for (auto* o : objectsBlend) o->draw(canvas); } -- GitLab