From 669b1b789e34db7538cc0d7a62c33b04da6ad7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 29 May 2019 08:32:28 +0200 Subject: [PATCH] cppcheck --- src/OpenMesh/Apps/Decimating/decimater.cc | 10 +++++----- src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh | 2 +- src/OpenMesh/Core/Geometry/LoopSchemeMaskT.hh | 12 ++++++------ src/OpenMesh/Core/Geometry/QuadricT.hh | 2 +- src/OpenMesh/Core/IO/writer/BaseWriter.hh | 12 +++++++----- src/OpenMesh/Core/IO/writer/OBJWriter.cc | 16 ++++++++-------- src/OpenMesh/Core/IO/writer/VTKWriter.cc | 4 ++-- src/OpenMesh/Core/System/mostream.hh | 2 +- src/OpenMesh/Core/Utils/Property.hh | 2 +- src/OpenMesh/Tools/Decimater/BaseDecimaterT.hh | 2 +- src/OpenMesh/Tools/Decimater/DecimaterT.hh | 2 +- .../Tools/Decimater/ModIndependentSetsT.hh | 2 +- .../Tools/Decimater/ModNormalDeviationT.hh | 4 ++-- .../Tools/Decimater/ModNormalFlippingT.hh | 6 +++--- src/OpenMesh/Tools/Decimater/ModRoundnessT.hh | 2 +- src/OpenMesh/Tools/Utils/HeapT.hh | 4 ++-- 16 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/OpenMesh/Apps/Decimating/decimater.cc b/src/OpenMesh/Apps/Decimating/decimater.cc index 0e1818be..313c33f8 100644 --- a/src/OpenMesh/Apps/Decimating/decimater.cc +++ b/src/OpenMesh/Apps/Decimating/decimater.cc @@ -216,7 +216,7 @@ decimate(const std::string &_ifname, using namespace std; Mesh mesh; - OpenMesh::IO::Options opt; + OpenMesh::IO::Options readopt; OpenMesh::Utils::Timer timer; // ---------------------------------------- read source mesh @@ -227,7 +227,7 @@ decimate(const std::string &_ifname, if (gverbose) clog << _ifname << endl; - if ( !(rc = OpenMesh::IO::read_mesh(mesh, _ifname, opt)) ) + if ( !(rc = OpenMesh::IO::read_mesh(mesh, _ifname, readopt)) ) { cerr << " ERROR: read failed!" << endl; return rc; @@ -238,7 +238,7 @@ decimate(const std::string &_ifname, { // ---- 0 - For module NormalFlipping one needs face normals - if ( !opt.check( OpenMesh::IO::Options::FaceNormal ) ) + if ( !readopt.check( OpenMesh::IO::Options::FaceNormal ) ) { if ( !mesh.has_face_normals() ) mesh.request_face_normals(); @@ -420,11 +420,11 @@ decimate(const std::string &_ifname, ofname.insert(++pos, n ); } - OpenMesh::IO::Options opt; + OpenMesh::IO::Options writeopt; //opt += OpenMesh::IO::Options::Binary; - if ( !OpenMesh::IO::write_mesh(mesh, ofname, opt ) ) + if ( !OpenMesh::IO::write_mesh(mesh, ofname, writeopt ) ) { std::cerr << " Cannot write decimated mesh to file '" << ofname << "'\n"; diff --git a/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh b/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh index dfd22070..4dbd182e 100644 --- a/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh +++ b/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh @@ -137,7 +137,7 @@ private: /// coarsen mesh down to _n vertices void coarsen(unsigned int _n); - virtual void keyPressEvent(QKeyEvent* _event); + virtual void keyPressEvent(QKeyEvent* _event) override; // mesh data bool animateRefinement_; diff --git a/src/OpenMesh/Core/Geometry/LoopSchemeMaskT.hh b/src/OpenMesh/Core/Geometry/LoopSchemeMaskT.hh index adf5c5f5..9ae62691 100644 --- a/src/OpenMesh/Core/Geometry/LoopSchemeMaskT.hh +++ b/src/OpenMesh/Core/Geometry/LoopSchemeMaskT.hh @@ -89,17 +89,17 @@ protected: inline static Scalar compute_limit_weight(uint _valence) { - double proj_weight = compute_proj_weight(_valence); - proj_weight = proj_weight/(proj_weight + _valence);//normalize the proj_weight - double weight = (3.0/8.0)/(1.0 - proj_weight + (3.0/8.0)); + double proj_weight_value = compute_proj_weight(_valence); + proj_weight_value = proj_weight_value/(proj_weight_value + _valence);//normalize the proj_weight + double weight = (3.0/8.0)/(1.0 - proj_weight_value + (3.0/8.0)); return (Scalar)weight; } inline static Scalar compute_step_weight(uint _valence) { - double proj_weight = compute_proj_weight(_valence); - proj_weight = proj_weight/(proj_weight + _valence);//normalize the proj_weight - double weight = proj_weight - (3.0/8.0); + double proj_weight_value = compute_proj_weight(_valence); + proj_weight_value = proj_weight_value/(proj_weight_value + _valence);//normalize the proj_weight + double weight = proj_weight_value - (3.0/8.0); return (Scalar)weight; } diff --git a/src/OpenMesh/Core/Geometry/QuadricT.hh b/src/OpenMesh/Core/Geometry/QuadricT.hh index 3376f32f..1c6c9fa5 100644 --- a/src/OpenMesh/Core/Geometry/QuadricT.hh +++ b/src/OpenMesh/Core/Geometry/QuadricT.hh @@ -112,7 +112,7 @@ public: {} template - QuadricT(const _Point& _pt) + explicit QuadricT(const _Point& _pt) { set_distance_to_point(_pt); } diff --git a/src/OpenMesh/Core/IO/writer/BaseWriter.hh b/src/OpenMesh/Core/IO/writer/BaseWriter.hh index 49b97b7e..fb1c1962 100644 --- a/src/OpenMesh/Core/IO/writer/BaseWriter.hh +++ b/src/OpenMesh/Core/IO/writer/BaseWriter.hh @@ -133,11 +133,13 @@ protected: bool check(BaseExporter& _be, Options _opt) const { - return (_opt.check(Options::VertexNormal ) <= _be.has_vertex_normals()) - && (_opt.check(Options::VertexTexCoord)<= _be.has_vertex_texcoords()) - && (_opt.check(Options::VertexColor) <= _be.has_vertex_colors()) - && (_opt.check(Options::FaceNormal) <= _be.has_face_normals()) - && (_opt.check(Options::FaceColor) <= _be.has_face_colors()); + // Check for all Options. When we want to write them (_opt.check() ) , they have to be available ( has_ ) + // Converts to not A (write them) or B (available) + return ( !_opt.check(Options::VertexNormal ) || _be.has_vertex_normals()) + && ( !_opt.check(Options::VertexTexCoord)|| _be.has_vertex_texcoords()) + && ( !_opt.check(Options::VertexColor) || _be.has_vertex_colors()) + && ( !_opt.check(Options::FaceNormal) || _be.has_face_normals()) + && ( !_opt.check(Options::FaceColor) || _be.has_face_colors()); } }; diff --git a/src/OpenMesh/Core/IO/writer/OBJWriter.cc b/src/OpenMesh/Core/IO/writer/OBJWriter.cc index 019aea89..eb2bcf99 100644 --- a/src/OpenMesh/Core/IO/writer/OBJWriter.cc +++ b/src/OpenMesh/Core/IO/writer/OBJWriter.cc @@ -100,24 +100,24 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream { #if defined(WIN32) - std::string::size_type dot = _filename.find_last_of("\\/"); + std::string::size_type dotposition = _filename.find_last_of("\\/"); #else - std::string::size_type dot = _filename.rfind("/"); + std::string::size_type dotposition = _filename.rfind("/"); #endif - if (dot == std::string::npos){ + if (dotposition == std::string::npos){ path_ = "./"; objName_ = _filename; }else{ - path_ = _filename.substr(0,dot+1); - objName_ = _filename.substr(dot+1); + path_ = _filename.substr(0,dotposition+1); + objName_ = _filename.substr(dotposition+1); } //remove the file extension - dot = objName_.find_last_of("."); + dotposition = objName_.find_last_of("."); - if(dot != std::string::npos) - objName_ = objName_.substr(0,dot); + if(dotposition != std::string::npos) + objName_ = objName_.substr(0,dotposition); } bool result = write(out, _be, _opt, _precision); diff --git a/src/OpenMesh/Core/IO/writer/VTKWriter.cc b/src/OpenMesh/Core/IO/writer/VTKWriter.cc index a178ce5f..fb718dc7 100644 --- a/src/OpenMesh/Core/IO/writer/VTKWriter.cc +++ b/src/OpenMesh/Core/IO/writer/VTKWriter.cc @@ -40,7 +40,7 @@ bool _VTKWriter_::write(const std::string& _filename, BaseExporter& _be, Options bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _precision) const { - Vec3f v, n; + Vec3f n; Vec2f t; VertexHandle vh; OpenMesh::Vec3f c; @@ -78,7 +78,7 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std _out << "POINTS " << _be.n_vertices() << " float\n"; size_t nv = _be.n_vertices(); for (size_t i = 0; i < nv; ++i) { - Vec3f v = _be.point(VertexHandle(int(i))); + const Vec3f v = _be.point(VertexHandle(int(i))); _out << v[0] << ' ' << v[1] << ' ' << v[2] << '\n'; } diff --git a/src/OpenMesh/Core/System/mostream.hh b/src/OpenMesh/Core/System/mostream.hh index 79956485..5463750d 100644 --- a/src/OpenMesh/Core/System/mostream.hh +++ b/src/OpenMesh/Core/System/mostream.hh @@ -92,7 +92,7 @@ class multiplex_target : public basic_multiplex_target { public: explicit multiplex_target(T& _t) : target_(_t) {} - virtual void operator<<(const std::string& _s) { target_ << _s; } + virtual void operator<<(const std::string& _s) override { target_ << _s; } private: T& target_; }; diff --git a/src/OpenMesh/Core/Utils/Property.hh b/src/OpenMesh/Core/Utils/Property.hh index 3fe88b3f..cda3f9bf 100644 --- a/src/OpenMesh/Core/Utils/Property.hh +++ b/src/OpenMesh/Core/Utils/Property.hh @@ -99,7 +99,7 @@ public: public: /// Default constructor - PropertyT(const std::string& _name = "") + explicit PropertyT(const std::string& _name = "") : BaseProperty(_name) {} diff --git a/src/OpenMesh/Tools/Decimater/BaseDecimaterT.hh b/src/OpenMesh/Tools/Decimater/BaseDecimaterT.hh index 97c2d064..0d2cf864 100644 --- a/src/OpenMesh/Tools/Decimater/BaseDecimaterT.hh +++ b/src/OpenMesh/Tools/Decimater/BaseDecimaterT.hh @@ -94,7 +94,7 @@ public: //-------------------------------------------------------- public types typedef typename ModuleList::iterator ModuleListIterator; public: //------------------------------------------------------ public methods - BaseDecimaterT(Mesh& _mesh); + explicit BaseDecimaterT(Mesh& _mesh); virtual ~BaseDecimaterT(); /** Initialize decimater and decimating modules. diff --git a/src/OpenMesh/Tools/Decimater/DecimaterT.hh b/src/OpenMesh/Tools/Decimater/DecimaterT.hh index ceddd554..6fe852cd 100644 --- a/src/OpenMesh/Tools/Decimater/DecimaterT.hh +++ b/src/OpenMesh/Tools/Decimater/DecimaterT.hh @@ -89,7 +89,7 @@ public: //-------------------------------------------------------- public types public: //------------------------------------------------------ public methods /// Constructor - DecimaterT( Mesh& _mesh ); + explicit DecimaterT( Mesh& _mesh ); /// Destructor ~DecimaterT(); diff --git a/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh b/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh index 88d62b8b..c7c4895c 100644 --- a/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh +++ b/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh @@ -72,7 +72,7 @@ class ModIndependentSetsT: public ModBaseT { ; /// Constructor - ModIndependentSetsT(MeshT &_mesh) : + explicit ModIndependentSetsT(MeshT &_mesh) : Base(_mesh, true) { } diff --git a/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh b/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh index 191c0c2a..1c11a93c 100644 --- a/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh +++ b/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh @@ -208,9 +208,9 @@ public: // the smaller the factor, the smaller normal_deviation_ gets // thus creating a stricter constraint // division by error_tolerance_factor_ is for normalization - Scalar normal_deviation = normal_deviation_ * static_cast( 180.0 / M_PI * _factor / this->error_tolerance_factor_); + Scalar normal_deviation_value = normal_deviation_ * static_cast( 180.0 / M_PI * _factor / this->error_tolerance_factor_); - set_normal_deviation(normal_deviation); + set_normal_deviation(normal_deviation_value); this->error_tolerance_factor_ = _factor; } } diff --git a/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh b/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh index b58fb568..9833e182 100644 --- a/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh +++ b/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh @@ -86,7 +86,7 @@ public: public: /// Constructor - ModNormalFlippingT( MeshT &_mesh) : Base(_mesh, true) + explicit ModNormalFlippingT( MeshT &_mesh) : Base(_mesh, true) { set_max_normal_deviation( 90.0f ); const bool mesh_has_normals = _mesh.has_face_normals(); @@ -159,8 +159,8 @@ public: // the smaller the factor, the smaller max_deviation_ gets // thus creating a stricter constraint // division by error_tolerance_factor_ is for normalization - double max_normal_deviation = (max_deviation_ * 180.0/M_PI) * _factor / this->error_tolerance_factor_; - set_max_normal_deviation(max_normal_deviation); + double max_normal_deviation_value = (max_deviation_ * 180.0/M_PI) * _factor / this->error_tolerance_factor_; + set_max_normal_deviation(max_normal_deviation_value); this->error_tolerance_factor_ = _factor; } } diff --git a/src/OpenMesh/Tools/Decimater/ModRoundnessT.hh b/src/OpenMesh/Tools/Decimater/ModRoundnessT.hh index 32fde82a..5b3c1485 100644 --- a/src/OpenMesh/Tools/Decimater/ModRoundnessT.hh +++ b/src/OpenMesh/Tools/Decimater/ModRoundnessT.hh @@ -97,7 +97,7 @@ class ModRoundnessT : public ModBaseT public: /// Constructor - ModRoundnessT( MeshT &_dec ) : + explicit ModRoundnessT( MeshT &_dec ) : Base(_dec, false), min_r_(-1.0) { } diff --git a/src/OpenMesh/Tools/Utils/HeapT.hh b/src/OpenMesh/Tools/Utils/HeapT.hh index 079c639e..7f1b3a8e 100644 --- a/src/OpenMesh/Tools/Utils/HeapT.hh +++ b/src/OpenMesh/Tools/Utils/HeapT.hh @@ -258,9 +258,9 @@ public: bool check() { bool ok(true); - unsigned int i, j; - for (i=0; i