From f8a118b2b0a3b332d63e2082c39ac64542ea565a Mon Sep 17 00:00:00 2001 From: Qiaozhi Lei Date: Mon, 21 Aug 2023 10:52:02 +0100 Subject: [PATCH 01/60] legacy vector min max should take const args --- src/OpenMesh/Core/Geometry/VectorT.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/VectorT.hh b/src/OpenMesh/Core/Geometry/VectorT.hh index eefb7b36..fa09e253 100644 --- a/src/OpenMesh/Core/Geometry/VectorT.hh +++ b/src/OpenMesh/Core/Geometry/VectorT.hh @@ -320,7 +320,7 @@ VectorT& minimize(VectorT& _v1, VectorT& /// \relates OpenMesh::VectorT /// non-member max template -VectorT max(VectorT& _v1, VectorT& _v2) { +VectorT max(const VectorT& _v1, const VectorT& _v2) { return VectorT(_v1).maximize(_v2); } @@ -328,7 +328,7 @@ VectorT max(VectorT& _v1, VectorT& _v2) { /// \relates OpenMesh::VectorT /// non-member min template -VectorT min(VectorT& _v1, VectorT& _v2) { +VectorT min(const VectorT& _v1, const VectorT& _v2) { return VectorT(_v1).minimize(_v2); } From b7b0027d4b43668d23f44ba6c827fc02935af125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 21 Aug 2023 14:12:54 +0200 Subject: [PATCH 02/60] legacy vector min max should take const args --- Doc/changelog.docu | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/changelog.docu b/Doc/changelog.docu index 9e7727ee..afd88541 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -16,6 +16,7 @@ Core
    +
  • legacy vector min max now take const args to avoid matching std implementations
  • Fixed several warnings
From 21b4bde190bb51e94f93340ec52bec5925cae24f Mon Sep 17 00:00:00 2001 From: Qiaozhi Lei Date: Tue, 22 Aug 2023 10:35:29 +0100 Subject: [PATCH 03/60] init normal with 3 scalars instead of 1 --- src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh b/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh index 646b30a4..86c945ed 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh @@ -429,7 +429,7 @@ typename PolyMeshT::Normal PolyMeshT:: calc_normal(EdgeHandle _eh) const { - Normal n(0); + Normal n(0, 0, 0); for (int i = 0; i < 2; ++i) { const auto heh = this->halfedge_handle(_eh, i); From ff8d78415bcf2f8a1f045d4334cf212dfac7772d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 14:01:59 +0200 Subject: [PATCH 04/60] Changesd cppcheck builder --- .gitlab-ci.yml | 4 +++- CI/ci-cppcheck.sh | 4 ++-- CI/gitlab-ci/linux.yml | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09dbbe73..0b2076af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,9 @@ cppcheck: stage: build script: "CI/ci-cppcheck.sh" image: gitlab.vci.rwth-aachen.de:4567/docker/docker/docker-openmesh-container - tags: [Docker] + tags: + - Linux + - stretch timeout: 3h artifacts: paths: diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index 66b19bad..c9da7c3c 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -1,4 +1,4 @@ -#!/bin/bash +!/bin/bash # Exit script on any error set -e @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=24 +MAX_COUNT=25 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} diff --git a/CI/gitlab-ci/linux.yml b/CI/gitlab-ci/linux.yml index 5499c5fa..3e04242f 100644 --- a/CI/gitlab-ci/linux.yml +++ b/CI/gitlab-ci/linux.yml @@ -6,7 +6,9 @@ cppcheck: stage: build script: "CI/ci-cppcheck.sh" image: gitlab.vci.rwth-aachen.de:4567/docker/docker/docker-openmesh-container - tags: [Docker] + tags: + - Linux + - stretch timeout: 3h artifacts: paths: From ae14da24d09423f176f705c8734dd7ef5de02035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:03:05 +0200 Subject: [PATCH 05/60] Raised warning count for cppcheck --- CI/ci-cppcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index c9da7c3c..5543a3f3 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -22,7 +22,7 @@ echo -e "${NC}" echo "Please Wait ..." # Run cppcheck and output into file -cppcheck --enable=all . -I src -i Doc/ -i src/Unittests --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log +cppcheck --enable=all . -I src -i Doc/ -i src/Unittests --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -UBMPOSTFIX -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log COUNT=$(wc -l < cppcheck.log ) @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=25 +MAX_COUNT=720 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} From 1f376e2cea64613190d698eb1092532bb419c2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:08:50 +0200 Subject: [PATCH 06/60] Some cppcheck fixes --- src/OpenMesh/Apps/Decimating/decimater.cc | 7 ++----- src/OpenMesh/Core/Utils/PropertyManager.hh | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/OpenMesh/Apps/Decimating/decimater.cc b/src/OpenMesh/Apps/Decimating/decimater.cc index 712d6b28..9d60c5be 100644 --- a/src/OpenMesh/Apps/Decimating/decimater.cc +++ b/src/OpenMesh/Apps/Decimating/decimater.cc @@ -489,15 +489,11 @@ int main(int argc, char* argv[]) std::clog << " Input file: " << ifname << std::endl; std::clog << " Output file: " << ofname << std::endl; std::clog << " #collapses: " << opt.n_collapses << std::endl; - } - //---------------------------------------- + //---------------------------------------- - - if (gverbose) - { std::clog << "Begin decimation" << std::endl; } @@ -512,6 +508,7 @@ int main(int argc, char* argv[]) } //---------------------------------------- + return 0; } diff --git a/src/OpenMesh/Core/Utils/PropertyManager.hh b/src/OpenMesh/Core/Utils/PropertyManager.hh index 93dac7b3..86d5fe3a 100644 --- a/src/OpenMesh/Core/Utils/PropertyManager.hh +++ b/src/OpenMesh/Core/Utils/PropertyManager.hh @@ -286,7 +286,7 @@ class PropertyManager { Storage::swap(rhs, *this); } - static bool propertyExists(PolyConnectivity &mesh, const char *propname) { + static bool propertyExists(const PolyConnectivity &mesh, const char *propname) { PROPTYPE dummy; return mesh.get_property_handle(dummy, propname); } From 1e450579c5babc29648aa48ee2249e3f2d9ea0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:20:27 +0200 Subject: [PATCH 07/60] Fixed warning due to signed unsigned comparison --- src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh b/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh index f723194a..eaa7f0b5 100644 --- a/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh +++ b/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh @@ -95,7 +95,7 @@ check(unsigned int _targets, std::ostream& _os) } } if (heh.is_valid()) { - if (heh.idx() < -1 || heh.idx() >= mesh_.n_halfedges()) { + if (heh.idx() < -1 || heh.idx() >= (int)mesh_.n_halfedges()) { _os << "MeshChecker: vertex " << vh << " has out-of-bounds outgoing HE: " << heh; ok = false; From d81afb036b4dfa0372482d8ae3007e27d4b845a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:20:53 +0200 Subject: [PATCH 08/60] Fixed some cppcheck warnings --- src/OpenMesh/Core/IO/SR_binary_spec.hh | 10 +++++----- src/OpenMesh/Tools/Decimater/ModEdgeLengthT_impl.hh | 4 ++-- src/OpenMesh/Tools/Decimater/ModHausdorffT_impl.hh | 4 ++-- src/OpenMesh/Tools/Decimater/ModQuadricT_impl.hh | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/OpenMesh/Core/IO/SR_binary_spec.hh b/src/OpenMesh/Core/IO/SR_binary_spec.hh index d220b398..265b35be 100644 --- a/src/OpenMesh/Core/IO/SR_binary_spec.hh +++ b/src/OpenMesh/Core/IO/SR_binary_spec.hh @@ -190,20 +190,20 @@ SIMPLE_BINARY(unsigned long); static size_t store( std::ostream& _os, const value_type& _val, \ bool _swap=false) { \ value_type tmp = _val; \ - size_t i, b = size_of(_val), N = value_type::size_; \ + size_t b = size_of(_val), N = value_type::size_; \ if (_swap) \ - for (i=0; i::set_error_tolerance_factor(double _factor) { // the smaller the factor, the smaller edge_length_ gets // thus creating a stricter constraint // division by error_tolerance_factor_ is for normalization - typename Mesh::Scalar edge_length = edge_length_ * static_cast(_factor / this->error_tolerance_factor_); - set_edge_length(edge_length); + typename Mesh::Scalar new_edge_length = edge_length_ * static_cast(_factor / this->error_tolerance_factor_); + set_edge_length(new_edge_length); this->error_tolerance_factor_ = _factor; } } diff --git a/src/OpenMesh/Tools/Decimater/ModHausdorffT_impl.hh b/src/OpenMesh/Tools/Decimater/ModHausdorffT_impl.hh index 5df959da..af310721 100644 --- a/src/OpenMesh/Tools/Decimater/ModHausdorffT_impl.hh +++ b/src/OpenMesh/Tools/Decimater/ModHausdorffT_impl.hh @@ -267,8 +267,8 @@ void ModHausdorffT::set_error_tolerance_factor(double _factor) { // the smaller the factor, the smaller tolerance gets // thus creating a stricter constraint // division by error_tolerance_factor_ is for normalization - Scalar tolerance = tolerance_ * Scalar(_factor / this->error_tolerance_factor_); - set_tolerance(tolerance); + Scalar new_tolerance = tolerance_ * Scalar(_factor / this->error_tolerance_factor_); + set_tolerance(new_tolerance); this->error_tolerance_factor_ = _factor; } } diff --git a/src/OpenMesh/Tools/Decimater/ModQuadricT_impl.hh b/src/OpenMesh/Tools/Decimater/ModQuadricT_impl.hh index cabbe7c5..718ca0a8 100644 --- a/src/OpenMesh/Tools/Decimater/ModQuadricT_impl.hh +++ b/src/OpenMesh/Tools/Decimater/ModQuadricT_impl.hh @@ -139,8 +139,8 @@ void ModQuadricT::set_error_tolerance_factor(double _factor) { // the smaller the factor, the smaller max_err_ gets // thus creating a stricter constraint // division by error_tolerance_factor_ is for normalization - double max_err = max_err_ * _factor / this->error_tolerance_factor_; - set_max_err(max_err); + double new_max_err = max_err_ * _factor / this->error_tolerance_factor_; + set_max_err(new_max_err); this->error_tolerance_factor_ = _factor; initialize(); From ef4230893e1abe32e06dbe08288b307e07db75d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:23:43 +0200 Subject: [PATCH 09/60] Fixed warning due to signed unsigned comparison --- src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh b/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh index eaa7f0b5..0b2673cd 100644 --- a/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh +++ b/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh @@ -148,7 +148,7 @@ check(unsigned int _targets, std::ostream& _os) typename Mesh::ConstHalfedgeIter h_it(mesh_.halfedges_begin()), h_end(mesh_.halfedges_end()); typename Mesh::HalfedgeHandle hh, hstart, hhh; - size_t count, n_halfedges = 2*mesh_.n_edges(); + size_t n_halfedges = 2*mesh_.n_edges(); for (const auto hh: mesh_.halfedges()) { @@ -193,7 +193,7 @@ check(unsigned int _targets, std::ostream& _os) // halfedges should form a cycle - count=0; hstart=hhh=hh; + size_t count=0; hstart=hhh=hh; do { hhh = mesh_.next_halfedge_handle(hhh); From 9b59627e27aac7f97c75f8bc212f7702986b92c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:33:28 +0200 Subject: [PATCH 10/60] Made some variables const --- .../Tools/Subdivider/Uniform/Composite/CompositeTraits.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Tools/Subdivider/Uniform/Composite/CompositeTraits.hh b/src/OpenMesh/Tools/Subdivider/Uniform/Composite/CompositeTraits.hh index 3444f424..30554355 100644 --- a/src/OpenMesh/Tools/Subdivider/Uniform/Composite/CompositeTraits.hh +++ b/src/OpenMesh/Tools/Subdivider/Uniform/Composite/CompositeTraits.hh @@ -106,10 +106,10 @@ struct CompositeTraits : public OpenMesh::DefaultTraits void set_green() {red_ = 0; } bool is_red() { return red_; } bool is_green() { return !red_; } - void set_red_halfedge_handle(HalfedgeHandle& _heh) + void set_red_halfedge_handle(const HalfedgeHandle& _heh) { red_halfedge_handle_ = _heh; } HalfedgeHandle& red_halfedge_handle() { return red_halfedge_handle_; } - void set_quality(Scalar& _q) { quality_ = _q; } + void set_quality(const Scalar& _q) { quality_ = _q; } Scalar& quality() { return quality_; } const Point& midpoint() const { return midpoint_; } void set_midpoint(const Point& _p) { midpoint_ = _p; } From 9dffc9cecb10f96c04720e6414b539f0aabea24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:33:53 +0200 Subject: [PATCH 11/60] Fixed cppcheck warning shadowing swap --- src/OpenMesh/Core/IO/writer/OMWriter.cc | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/OpenMesh/Core/IO/writer/OMWriter.cc b/src/OpenMesh/Core/IO/writer/OMWriter.cc index 911db28e..521714fc 100644 --- a/src/OpenMesh/Core/IO/writer/OMWriter.cc +++ b/src/OpenMesh/Core/IO/writer/OMWriter.cc @@ -183,7 +183,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, size_t bytes = 0; - const bool swap = + const bool swap_required = _writeOptions.check(Options::Swap) || (Endian::local() == Endian::MSB); unsigned int i, nV, nF; @@ -202,7 +202,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, header.n_faces_ = int(_be.n_faces()); header.n_edges_ = int(_be.n_edges()); - bytes += store( _os, header, swap ); + bytes += store( _os, header, swap_required ); // ---------------------------------------- write chunks @@ -234,13 +234,13 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.bits_ = OMFormat::bits(v[0]); } - bytes += store( _os, chunk_header, swap ); + bytes += store( _os, chunk_header, swap_required ); if (_be.is_point_double()) for (i=0, nV=header.n_vertices_; i(i))); auto face_id = _be.get_face_id(HalfedgeHandle(static_cast(i))); - bytes += store( _os, next_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap ); - bytes += store( _os, to_vertex_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap ); - bytes += store( _os, face_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap ); + bytes += store( _os, next_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap_required ); + bytes += store( _os, to_vertex_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap_required ); + bytes += store( _os, face_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap_required ); } } @@ -357,11 +357,11 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.dim_ = OMFormat::dim(t); chunk_header.bits_ = OMFormat::bits(t[0]); - bytes += store(_os, chunk_header, swap); + bytes += store(_os, chunk_header, swap_required); unsigned int nHE; for (i = 0, nHE = header.n_edges_*2; i < nHE; ++i) - bytes += vector_store(_os, _be.texcoord(HalfedgeHandle(i)), swap); + bytes += vector_store(_os, _be.texcoord(HalfedgeHandle(i)), swap_required); } //--------------------------------------------------------------- @@ -378,9 +378,9 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.dim_ = OMFormat::Chunk::Dim_1D; chunk_header.bits_ = OMFormat::needed_bits(_be.n_edges()*4); // *2 due to halfedge ids being stored, *2 due to signedness - bytes += store( _os, chunk_header, swap ); + bytes += store( _os, chunk_header, swap_required ); for (i=0, nV=header.n_vertices_; istore(_os, swap ); @@ -478,10 +478,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.dim_ = OMFormat::dim( c ); chunk_header.bits_ = OMFormat::bits( c[0] ); - bytes += store( _os, chunk_header, swap ); + bytes += store( _os, chunk_header, swap_required ); #if !NEW_STYLE for (i=0, nF=header.n_faces_; istore(_os, swap); } @@ -503,10 +503,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.bits_ = OMFormat::bits(s); // std::clog << chunk_header << std::endl; - bytes += store(_os, chunk_header, swap); + bytes += store(_os, chunk_header, swap_required); for (i = 0, nV = header.n_vertices_; i < nV; ++i) - bytes += store(_os, _be.status(VertexHandle(i)), swap); + bytes += store(_os, _be.status(VertexHandle(i)), swap_required); } // ---------- write edge status @@ -522,10 +522,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.bits_ = OMFormat::bits(s); // std::clog << chunk_header << std::endl; - bytes += store(_os, chunk_header, swap); + bytes += store(_os, chunk_header, swap_required); for (i = 0, nV = header.n_edges_; i < nV; ++i) - bytes += store(_os, _be.status(EdgeHandle(i)), swap); + bytes += store(_os, _be.status(EdgeHandle(i)), swap_required); } // ---------- write halfedge status @@ -541,10 +541,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.bits_ = OMFormat::bits(s); // std::clog << chunk_header << std::endl; - bytes += store(_os, chunk_header, swap); + bytes += store(_os, chunk_header, swap_required); for (i = 0, nV = header.n_edges_ * 2; i < nV; ++i) - bytes += store(_os, _be.status(HalfedgeHandle(i)), swap); + bytes += store(_os, _be.status(HalfedgeHandle(i)), swap_required); } // ---------- write face status @@ -560,17 +560,17 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, chunk_header.bits_ = OMFormat::bits(s); // std::clog << chunk_header << std::endl; - bytes += store(_os, chunk_header, swap); + bytes += store(_os, chunk_header, swap_required); for (i = 0, nV = header.n_faces_; i < nV; ++i) - bytes += store(_os, _be.status(FaceHandle(i)), swap); + bytes += store(_os, _be.status(FaceHandle(i)), swap_required); } // -------------------- write custom properties if (_writeOptions.check(Options::Custom)) { - const auto store_property = [this, &_os, swap, &bytes]( + const auto store_property = [this, &_os, swap_required, &bytes]( const BaseKernel::const_prop_iterator _it_begin, const BaseKernel::const_prop_iterator _it_end, const OMFormat::Chunk::Entity _ent) @@ -582,7 +582,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, { // skip dead and "private" properties (no name or name matches "?:*") continue; } - bytes += store_binary_custom_chunk(_os, **prop, _ent, swap); + bytes += store_binary_custom_chunk(_os, **prop, _ent, swap_required); } }; @@ -601,7 +601,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, memset(&chunk_header, 0, sizeof(chunk_header)); chunk_header.name_ = false; chunk_header.entity_ = OMFormat::Chunk::Entity_Sentinel; - bytes += store(_os, chunk_header, swap); + bytes += store(_os, chunk_header, swap_required); omlog() << "#bytes written: " << bytes << std::endl; From 225dba1490ea00672ecbf9535b716864df1a6d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 15:34:15 +0200 Subject: [PATCH 12/60] Fixed cppcheck warning shadowing swap --- .../VDPMSynthesizerViewerWidget.cc | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.cc b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.cc index 7e387704..2f70c8ab 100644 --- a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.cc +++ b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.cc @@ -407,7 +407,7 @@ open_vd_prog_mesh(const char* _filename) } // - bool swap = Endian::local() != Endian::LSB; + bool swap_required = Endian::local() != Endian::LSB; // read header ifs.read(fileformat, 10); fileformat[10] = '\0'; @@ -418,9 +418,9 @@ open_vd_prog_mesh(const char* _filename) exit(1); } - IO::restore(ifs, n_base_vertices_, swap); - IO::restore(ifs, n_base_faces_, swap); - IO::restore(ifs, n_details_, swap); + IO::restore(ifs, n_base_vertices_, swap_required); + IO::restore(ifs, n_base_faces_, swap_required); + IO::restore(ifs, n_details_, swap_required); mesh_.clear(); vfront_.clear(); @@ -431,12 +431,12 @@ open_vd_prog_mesh(const char* _filename) // load base mesh for (i=0; i Date: Tue, 22 Aug 2023 15:34:45 +0200 Subject: [PATCH 13/60] Correctly marked functions explicit or override --- .../VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.hh b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.hh index b003ac0d..088d3ad0 100644 --- a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.hh +++ b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/VDPMSynthesizerViewerWidget.hh @@ -106,7 +106,7 @@ public: public: - VDPMSynthesizerViewerWidget(QWidget* _parent=0, const char* _name=0); + explicit VDPMSynthesizerViewerWidget(QWidget* _parent=0, const char* _name=0); ~VDPMSynthesizerViewerWidget(); @@ -144,12 +144,12 @@ private: void update_viewing_parameters(); - virtual void keyPressEvent(QKeyEvent* _event); + virtual void keyPressEvent(QKeyEvent* _event) override; protected: /// inherited drawing method - virtual void draw_scene(const std::string& _draw_mode); + virtual void draw_scene(const std::string& _draw_mode) override; public: From f55975e6b5ee6d08eed31e2983e2523566573e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 16:40:21 +0200 Subject: [PATCH 14/60] Fixed uninitialized variable --- src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh b/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh index 67392a19..ace65af2 100644 --- a/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh +++ b/src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh @@ -96,6 +96,7 @@ public: /// default constructor explicit ProgViewerWidget(QWidget* _parent=0) : MeshViewerWidgetProgBase(_parent), + animateRefinement_(true), n_base_vertices_(0), n_base_faces_(0), n_detail_vertices_(0), From 41d6176c3ba17630fd65dd72f313b07f816c73fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 16:40:33 +0200 Subject: [PATCH 15/60] Fixed cppcheck warning --- src/OpenMesh/Core/Geometry/Vector11T.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index bb38813e..03a61ba2 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -170,8 +170,9 @@ class VectorT { } /// construct from an array - explicit VectorT(container&& _array) { - values_ = _array; + explicit VectorT(container&& _array) : + values_(_array) + { } /// copy & cast constructor (explicit) From 7ac3520d4c54dce0f216a573e2847ed7a34e2328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 16:41:37 +0200 Subject: [PATCH 16/60] Made constructor explicit --- src/OpenMesh/Apps/Subdivider/SubdivideWidget.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Apps/Subdivider/SubdivideWidget.hh b/src/OpenMesh/Apps/Subdivider/SubdivideWidget.hh index a22afb16..f337be77 100644 --- a/src/OpenMesh/Apps/Subdivider/SubdivideWidget.hh +++ b/src/OpenMesh/Apps/Subdivider/SubdivideWidget.hh @@ -88,7 +88,7 @@ public: public: /// constructor - SubdivideWidget(QWidget* _parent=0, const char* _name=0); + explicit SubdivideWidget(QWidget* _parent=0, const char* _name=0); /// destructor ~SubdivideWidget() {}; From e3bd67d6c9bf4c01bcc040f20ef5555f0db7d8e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 16:44:07 +0200 Subject: [PATCH 17/60] Removed unused variables --- src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh b/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh index 0b2673cd..8a32c648 100644 --- a/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh +++ b/src/OpenMesh/Tools/Utils/MeshCheckerT_impl.hh @@ -147,7 +147,7 @@ check(unsigned int _targets, std::ostream& _os) { typename Mesh::ConstHalfedgeIter h_it(mesh_.halfedges_begin()), h_end(mesh_.halfedges_end()); - typename Mesh::HalfedgeHandle hh, hstart, hhh; + typename Mesh::HalfedgeHandle hstart, hhh; size_t n_halfedges = 2*mesh_.n_edges(); for (const auto hh: mesh_.halfedges()) @@ -217,7 +217,6 @@ check(unsigned int _targets, std::ostream& _os) { typename Mesh::ConstFaceIter f_it(mesh_.faces_begin()), f_end(mesh_.faces_end()); - typename Mesh::FaceHandle fh; typename Mesh::ConstFaceHalfedgeIter fh_it; for(const auto fh: mesh_.faces()) { From 0182ada6ff64a5c101f505df01bcd6d53e4d8244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 16:47:00 +0200 Subject: [PATCH 18/60] Fixed all swap shadowing variables --- src/OpenMesh/Core/IO/reader/OFFReader.cc | 5 ++--- src/OpenMesh/Core/IO/reader/OMReader.cc | 18 +++++++++--------- src/OpenMesh/Core/IO/reader/PLYReader.cc | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/OFFReader.cc b/src/OpenMesh/Core/IO/reader/OFFReader.cc index 24a8a352..667b8590 100644 --- a/src/OpenMesh/Core/IO/reader/OFFReader.cc +++ b/src/OpenMesh/Core/IO/reader/OFFReader.cc @@ -140,8 +140,7 @@ _OFFReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt ) } // filter relevant options for reading - bool swap = _opt.check( Options::Swap ); - + bool swap_required = _opt.check( Options::Swap ); userOptions_ = _opt; @@ -159,7 +158,7 @@ _OFFReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt ) options_ += Options::ColorAlpha; return (options_.is_binary() ? - read_binary(_in, _bi, _opt, swap) : + read_binary(_in, _bi, _opt, swap_required) : read_ascii(_in, _bi, _opt)); } diff --git a/src/OpenMesh/Core/IO/reader/OMReader.cc b/src/OpenMesh/Core/IO/reader/OMReader.cc index aae27cdc..9de83dfa 100644 --- a/src/OpenMesh/Core/IO/reader/OMReader.cc +++ b/src/OpenMesh/Core/IO/reader/OMReader.cc @@ -166,12 +166,12 @@ bool _OMReader_::read_ascii(std::istream& /* _is */, BaseImporter& /* _bi */, Op bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt) const { - bool swap = _opt.check(Options::Swap) || (Endian::local() == Endian::MSB); + bool swap_required = _opt.check(Options::Swap) || (Endian::local() == Endian::MSB); // Initialize byte counter bytes_ = 0; - bytes_ += restore(_is, header_, swap); + bytes_ += restore(_is, header_, swap_required); if (header_.version_ > _OMWriter_::get_version()) @@ -183,7 +183,7 @@ bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt } while (!_is.eof()) { - bytes_ += restore(_is, chunk_header_, swap); + bytes_ += restore(_is, chunk_header_, swap_required); if (_is.eof()) break; @@ -191,30 +191,30 @@ bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt // Is this a named property restore the name if (chunk_header_.name_) { OMFormat::Chunk::PropertyName pn; - bytes_ += restore(_is, property_name_, swap); + bytes_ += restore(_is, property_name_, swap_required); } // Read in the property data. If it is an anonymous or unknown named // property, then skip data. switch (chunk_header_.entity_) { case OMFormat::Chunk::Entity_Vertex: - if (!read_binary_vertex_chunk(_is, _bi, _opt, swap)) + if (!read_binary_vertex_chunk(_is, _bi, _opt, swap_required)) return false; break; case OMFormat::Chunk::Entity_Face: - if (!read_binary_face_chunk(_is, _bi, _opt, swap)) + if (!read_binary_face_chunk(_is, _bi, _opt, swap_required)) return false; break; case OMFormat::Chunk::Entity_Edge: - if (!read_binary_edge_chunk(_is, _bi, _opt, swap)) + if (!read_binary_edge_chunk(_is, _bi, _opt, swap_required)) return false; break; case OMFormat::Chunk::Entity_Halfedge: - if (!read_binary_halfedge_chunk(_is, _bi, _opt, swap)) + if (!read_binary_halfedge_chunk(_is, _bi, _opt, swap_required)) return false; break; case OMFormat::Chunk::Entity_Mesh: - if (!read_binary_mesh_chunk(_is, _bi, _opt, swap)) + if (!read_binary_mesh_chunk(_is, _bi, _opt, swap_required)) return false; break; case OMFormat::Chunk::Entity_Sentinel: diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index 51e5ebcc..1a20af8c 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -142,7 +142,7 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) { } // filter relevant options for reading - bool swap = _opt.check(Options::Swap); + bool swap_required = _opt.check(Options::Swap); userOptions_ = _opt; @@ -178,7 +178,7 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) { // if ( options_.is_binary() && userOptions_.color_has_alpha() ) // options_ += Options::ColorAlpha; - return (options_.is_binary() ? read_binary(_in, _bi, swap, _opt) : read_ascii(_in, _bi, _opt)); + return (options_.is_binary() ? read_binary(_in, _bi, swap_required, _opt) : read_ascii(_in, _bi, _opt)); } From 335d5157aa92e7998976aa746f537aadd43ff1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 16:47:17 +0200 Subject: [PATCH 19/60] Lowerd max allowed warnings for cppcheck --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index 5543a3f3..8540c08a 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=720 +MAX_COUNT=525 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} From b0cdf58d1158c2441549d840fe299dc01f334351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Aug 2023 18:51:24 +0200 Subject: [PATCH 20/60] Lower max allowed warnings --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index 8540c08a..870706a0 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=525 +MAX_COUNT=471 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} From ae05c0b9469b1f8cba60408e55418c3d2755a62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:08:43 +0200 Subject: [PATCH 21/60] Fixed shadowed variables --- src/OpenMesh/Tools/VDPM/VHierarchy.cc | 12 ++++++------ src/OpenMesh/Tools/VDPM/VHierarchy.hh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/OpenMesh/Tools/VDPM/VHierarchy.cc b/src/OpenMesh/Tools/VDPM/VHierarchy.cc index 6e59b944..02a0a5cf 100644 --- a/src/OpenMesh/Tools/VDPM/VHierarchy.cc +++ b/src/OpenMesh/Tools/VDPM/VHierarchy.cc @@ -99,16 +99,16 @@ add_node(const VHierarchyNode &_node) void VHierarchy:: -make_children(VHierarchyNodeHandle &_parent_handle) +make_children(const VHierarchyNodeHandle &_parent_handle) { - VHierarchyNodeHandle lchild_handle = add_node(); - VHierarchyNodeHandle rchild_handle = add_node(); + VHierarchyNodeHandle new_lchild_handle = add_node(); + VHierarchyNodeHandle new_rchild_handle = add_node(); VHierarchyNode &parent = node(_parent_handle); - VHierarchyNode &lchild = node(lchild_handle); - VHierarchyNode &rchild = node(rchild_handle); + VHierarchyNode &lchild = node(new_lchild_handle); + VHierarchyNode &rchild = node(new_rchild_handle); - parent.set_children_handle(lchild_handle); + parent.set_children_handle(new_lchild_handle); lchild.set_parent_handle(_parent_handle); rchild.set_parent_handle(_parent_handle); diff --git a/src/OpenMesh/Tools/VDPM/VHierarchy.hh b/src/OpenMesh/Tools/VDPM/VHierarchy.hh index b512b2d7..1356a7ce 100644 --- a/src/OpenMesh/Tools/VDPM/VHierarchy.hh +++ b/src/OpenMesh/Tools/VDPM/VHierarchy.hh @@ -119,7 +119,7 @@ public: VHierarchyNodeHandle add_node(); VHierarchyNodeHandle add_node(const VHierarchyNode &_node); - void make_children(VHierarchyNodeHandle &_parent_handle); + void make_children(const VHierarchyNodeHandle &_parent_handle); bool is_ancestor(VHierarchyNodeIndex _ancestor_index, VHierarchyNodeIndex _descendent_index); From 6390bd2634a3191e3384564f7b6bb8da4db4dba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:09:16 +0200 Subject: [PATCH 22/60] Renamed some traits --- src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh | 4 ++-- src/OpenMesh/Apps/Smoothing/smooth.cc | 4 ++-- src/OpenMesh/Apps/mconvert/mconvert.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh b/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh index e51045b5..ac347af7 100644 --- a/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh +++ b/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh @@ -84,13 +84,13 @@ using namespace OpenMesh; -struct MyTraits : public DEFAULT_TRAITS +struct MyDecimaterViewerWidgetTraits : public DEFAULT_TRAITS { VertexAttributes ( Attributes::Normal ); FaceAttributes ( Attributes::Normal ); }; -typedef TRIMESH_KERNEL mesh_t; +typedef TRIMESH_KERNEL mesh_t; typedef MeshViewerWidgetT MeshViewerWidgetDecimaterBase; //== CLASS DEFINITION ========================================================= diff --git a/src/OpenMesh/Apps/Smoothing/smooth.cc b/src/OpenMesh/Apps/Smoothing/smooth.cc index ebebdbd3..ffb039df 100644 --- a/src/OpenMesh/Apps/Smoothing/smooth.cc +++ b/src/OpenMesh/Apps/Smoothing/smooth.cc @@ -54,7 +54,7 @@ using namespace OpenMesh; using namespace Smoother; -struct MyTraits : public OpenMesh::DefaultTraits +struct MySmoothingTraits : public OpenMesh::DefaultTraits { #if 1 typedef OpenMesh::Vec3f Point; @@ -65,7 +65,7 @@ struct MyTraits : public OpenMesh::DefaultTraits #endif }; -typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; +typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; //----------------------------------------------------------------------------- diff --git a/src/OpenMesh/Apps/mconvert/mconvert.cc b/src/OpenMesh/Apps/mconvert/mconvert.cc index 566275bd..bec6e9db 100644 --- a/src/OpenMesh/Apps/mconvert/mconvert.cc +++ b/src/OpenMesh/Apps/mconvert/mconvert.cc @@ -53,7 +53,7 @@ #include -struct MyTraits : public OpenMesh::DefaultTraits +struct MyMConvertTraits : public OpenMesh::DefaultTraits { VertexAttributes ( OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color | @@ -64,7 +64,7 @@ struct MyTraits : public OpenMesh::DefaultTraits }; -typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; +typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; void usage_and_exit(int xcode) { From a18b0d8c5afdf8e3c8192d5ef080501f676b0bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:09:44 +0200 Subject: [PATCH 23/60] Use more references for vectors --- src/OpenMesh/Tools/Utils/Gnuplot.cc | 8 ++++---- src/OpenMesh/Tools/Utils/Gnuplot.hh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OpenMesh/Tools/Utils/Gnuplot.cc b/src/OpenMesh/Tools/Utils/Gnuplot.cc index 88e91607..bf852619 100644 --- a/src/OpenMesh/Tools/Utils/Gnuplot.cc +++ b/src/OpenMesh/Tools/Utils/Gnuplot.cc @@ -126,7 +126,7 @@ Gnuplot::Gnuplot(const string &style) Gnuplot::Gnuplot(const string &title, const string &style, const string &labelx, const string &labely, - vector x, vector y) + const vector& x, const vector& y) { init(); @@ -157,7 +157,7 @@ Gnuplot::Gnuplot(const string &title, Gnuplot::Gnuplot(const string &title, const string &style, const string &labelx, const string &labely, - vector x) + const vector& x) { init(); @@ -349,7 +349,7 @@ void Gnuplot::plot_equation(const string &equation, const string &title) // ---------------------------------------------------------------------------- -void Gnuplot::plot_x(vector d, const string &title) +void Gnuplot::plot_x(const vector& d, const string &title) { ofstream tmp; ostringstream cmdstr; @@ -418,7 +418,7 @@ void Gnuplot::plot_x(vector d, const string &title) // ---------------------------------------------------------------------------- -void Gnuplot::plot_xy(vector x, vector y, const string &title) +void Gnuplot::plot_xy(const vector& x, const vector& y, const string &title) { ofstream tmp; ostringstream cmdstr; diff --git a/src/OpenMesh/Tools/Utils/Gnuplot.hh b/src/OpenMesh/Tools/Utils/Gnuplot.hh index faf2e50c..0f6599e4 100644 --- a/src/OpenMesh/Tools/Utils/Gnuplot.hh +++ b/src/OpenMesh/Tools/Utils/Gnuplot.hh @@ -120,14 +120,14 @@ public: const string & _style, const string & _xlabel, const string & _ylabel, - vector _x, vector _y); + const vector& _x, const vector& _y); /// Constructor calling plot_x(). Gnuplot(const string &_title, const string &_style, const string &_xlabel, const string &_ylabel, - vector _x); + const vector& _x); //@} ~Gnuplot(); @@ -146,10 +146,10 @@ public: //@{ /// Plot a single vector - void plot_x(vector _x, const string &_title); + void plot_x(const vector& _x, const string &_title); /// Plot x,y pairs - void plot_xy(vector _x, vector _y, const string &_title); + void plot_xy(const vector& _x, const vector& _y, const string &_title); /// Plot an equation of the form: y = ax + b /// You supply a and b From 785cdb2f913c240e70d1b15890ebc63e3a94534f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:10:03 +0200 Subject: [PATCH 24/60] Simplified loop --- src/OpenMesh/Core/Mesh/PolyConnectivity.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc index 223a5908..4114924f 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc @@ -494,11 +494,8 @@ void PolyConnectivity::delete_vertex(VertexHandle _vh, bool _delete_isolated_ver // delete collected faces - std::vector::iterator fh_it(face_handles.begin()), - fh_end(face_handles.end()); - - for (; fh_it!=fh_end; ++fh_it) - delete_face(*fh_it, _delete_isolated_vertices); + for (auto delete_fh_it : face_handles) + delete_face(delete_fh_it, _delete_isolated_vertices); status(_vh).set_deleted(true); } From 10c0d574695afd41a19524eddd7e06f510da2511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:20:55 +0200 Subject: [PATCH 25/60] Mark more variables as const --- src/OpenMesh/Core/Mesh/CirculatorsT.hh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/CirculatorsT.hh b/src/OpenMesh/Core/Mesh/CirculatorsT.hh index f13fd410..02e94686 100644 --- a/src/OpenMesh/Core/Mesh/CirculatorsT.hh +++ b/src/OpenMesh/Core/Mesh/CirculatorsT.hh @@ -68,18 +68,18 @@ namespace Iterators { template class GenericCirculator_CenterEntityFnsT { public: - static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter); - static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter); + static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter); + static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter); }; template class GenericCirculator_CenterEntityFnsT { public: - inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { heh = mesh->cw_rotated_halfedge_handle(heh); if (heh == start) ++lap_counter; } - inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { if (heh == start) --lap_counter; heh = mesh->ccw_rotated_halfedge_handle(heh); } @@ -88,11 +88,11 @@ class GenericCirculator_CenterEntityFnsT class GenericCirculator_CenterEntityFnsT { public: - inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { heh = mesh->next_halfedge_handle(heh); if (heh == start) ++lap_counter; } - inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { if (heh == start) --lap_counter; heh = mesh->prev_halfedge_handle(heh); } @@ -104,11 +104,11 @@ class GenericCirculator_CenterEntityFnsT template class GenericCirculator_CenterEntityFnsT { public: - inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { heh = mesh->ccw_rotated_halfedge_handle(heh); if (heh == start) ++lap_counter; } - inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { if (heh == start) --lap_counter; heh = mesh->cw_rotated_halfedge_handle(heh); } @@ -117,11 +117,11 @@ class GenericCirculator_CenterEntityFnsT class GenericCirculator_CenterEntityFnsT { public: - inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { heh = mesh->prev_halfedge_handle(heh); if (heh == start) ++lap_counter; } - inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { if (heh == start) --lap_counter; heh = mesh->next_halfedge_handle(heh); } From 652f14afc80b283b32eb3e955da6e270b8476af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:21:16 +0200 Subject: [PATCH 26/60] Explicit constructor for heap --- src/OpenMesh/Tools/Utils/HeapT.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Tools/Utils/HeapT.hh b/src/OpenMesh/Tools/Utils/HeapT.hh index 817464ea..78d1728d 100644 --- a/src/OpenMesh/Tools/Utils/HeapT.hh +++ b/src/OpenMesh/Tools/Utils/HeapT.hh @@ -146,8 +146,8 @@ public: HeapT() : HeapVector() {} #if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) - /// Construct with a given \c HeapIterface. - HeapT(HeapInterface _interface) + /// Construct with a given \c HeapIterface. + explicit HeapT(HeapInterface _interface) : HeapVector(), interface_(std::move(_interface)) {} #else From a1cddd860b36daf1885079ba151433ee8634be26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:28:01 +0200 Subject: [PATCH 27/60] More const refs --- src/OpenMesh/Core/Mesh/CirculatorsT.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/CirculatorsT.hh b/src/OpenMesh/Core/Mesh/CirculatorsT.hh index 02e94686..a4926e1d 100644 --- a/src/OpenMesh/Core/Mesh/CirculatorsT.hh +++ b/src/OpenMesh/Core/Mesh/CirculatorsT.hh @@ -442,16 +442,16 @@ class GenericCirculator_ValueHandleFnsT_DEPRECATED::increment(mesh, heh, start, lap_counter); } while (is_valid(heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh)); } - inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { do { GenericCirculator_CenterEntityFnsT::decrement(mesh, heh, start, lap_counter); } while (is_valid(heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh)); From 5096de5e190e836b936eaa5cb2084dd3562b0dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:28:18 +0200 Subject: [PATCH 28/60] Explicit constructor for ExtStatusSetT --- src/OpenMesh/Core/Mesh/ArrayKernel.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Mesh/ArrayKernel.hh b/src/OpenMesh/Core/Mesh/ArrayKernel.hh index 56398b70..b9c97fa1 100644 --- a/src/OpenMesh/Core/Mesh/ArrayKernel.hh +++ b/src/OpenMesh/Core/Mesh/ArrayKernel.hh @@ -738,7 +738,7 @@ public: typedef typename HandleContainer::const_iterator const_iterator; public: - ExtStatusSetT(ArrayKernel& _kernel, size_t _capacity_hint = 0) + explicit ExtStatusSetT(ArrayKernel& _kernel, size_t _capacity_hint = 0) : Base(_kernel) { handles_.reserve(_capacity_hint); } From df85af6ade0662dea2e8c7fb779bf926413d2938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:32:18 +0200 Subject: [PATCH 29/60] More const refs --- src/OpenMesh/Core/IO/OMFormat.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/IO/OMFormat.hh b/src/OpenMesh/Core/IO/OMFormat.hh index 7b508833..a1e43643 100644 --- a/src/OpenMesh/Core/IO/OMFormat.hh +++ b/src/OpenMesh/Core/IO/OMFormat.hh @@ -307,7 +307,7 @@ namespace OMFormat { /// Return the size of chunk data in bytes - inline size_t chunk_data_size( Header& _hdr, Chunk::Header& _chunk_hdr ) + inline size_t chunk_data_size( const Header& _hdr, const Chunk::Header& _chunk_hdr ) { size_t C; switch( _chunk_hdr.entity_ ) From 43e13b6e7d4756e90b952073b38d2693b983b060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:38:27 +0200 Subject: [PATCH 30/60] Removed unused private functions --- src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh | 4 ---- src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh | 2 +- src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh | 5 ----- src/OpenMesh/Tools/Decimater/ModProgMeshT.hh | 3 --- 4 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh b/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh index fbeb0266..d3407bf6 100644 --- a/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh +++ b/src/OpenMesh/Tools/Decimater/ModIndependentSetsT.hh @@ -86,10 +86,6 @@ class ModIndependentSetsT: public ModBaseT { Base::mesh().status(*vv_it).set_locked(true); } - private: - - /// hide this method - void set_binary(bool _b) { } }; //============================================================================= diff --git a/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh b/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh index f40be046..c6c0142b 100644 --- a/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh +++ b/src/OpenMesh/Tools/Decimater/ModNormalDeviationT.hh @@ -104,7 +104,7 @@ public: public: /// Constructor - ModNormalDeviationT(MeshT& _mesh, float _max_dev = 180.0) + explicit ModNormalDeviationT(MeshT& _mesh, float _max_dev = 180.0) : Base(_mesh, true), mesh_(Base::mesh()) { set_normal_deviation(_max_dev); diff --git a/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh b/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh index 47bb7549..7a1610f8 100644 --- a/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh +++ b/src/OpenMesh/Tools/Decimater/ModNormalFlippingT.hh @@ -181,11 +181,6 @@ public: min_cos_ = cos(max_deviation_); } -private: - - // hide this method - void set_binary(bool _b) {} - private: // maximum normal deviation diff --git a/src/OpenMesh/Tools/Decimater/ModProgMeshT.hh b/src/OpenMesh/Tools/Decimater/ModProgMeshT.hh index a8a10840..0906804f 100644 --- a/src/OpenMesh/Tools/Decimater/ModProgMeshT.hh +++ b/src/OpenMesh/Tools/Decimater/ModProgMeshT.hh @@ -171,9 +171,6 @@ public: // specific methods private: - // hide this method form user - void set_binary(bool _b) {} - InfoList pmi_; VPropHandleT idx_; }; From 45d158717a9038770f665519a57d3e220e678446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 09:45:49 +0200 Subject: [PATCH 31/60] More const refs --- src/OpenMesh/Core/IO/OMFormat.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/IO/OMFormat.hh b/src/OpenMesh/Core/IO/OMFormat.hh index a1e43643..bd14ad63 100644 --- a/src/OpenMesh/Core/IO/OMFormat.hh +++ b/src/OpenMesh/Core/IO/OMFormat.hh @@ -327,7 +327,7 @@ namespace OMFormat { return C * vector_size( _chunk_hdr ); } - inline size_t chunk_size( Header& _hdr, Chunk::Header& _chunk_hdr ) + inline size_t chunk_size( const Header& _hdr, const Chunk::Header& _chunk_hdr ) { return chunk_header_size() + chunk_data_size( _hdr, _chunk_hdr ); } From e7406f22fc13f276005dcfbaca7ce2956f5deef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:06:04 +0200 Subject: [PATCH 32/60] More explicit constructors --- src/OpenMesh/Tools/Decimater/ModAspectRatioT.hh | 2 +- src/OpenMesh/Tools/Decimater/ModEdgeLengthT.hh | 2 +- src/OpenMesh/Tools/Decimater/ModHausdorffT.hh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Tools/Decimater/ModAspectRatioT.hh b/src/OpenMesh/Tools/Decimater/ModAspectRatioT.hh index ac15b0a0..ddd3f71d 100644 --- a/src/OpenMesh/Tools/Decimater/ModAspectRatioT.hh +++ b/src/OpenMesh/Tools/Decimater/ModAspectRatioT.hh @@ -88,7 +88,7 @@ class ModAspectRatioT: public ModBaseT { typedef typename Mesh::Point Point; /// constructor - ModAspectRatioT(MeshT& _mesh, float _min_aspect = 5.0, bool _is_binary = + explicit ModAspectRatioT(MeshT& _mesh, float _min_aspect = 5.0, bool _is_binary = true) : Base(_mesh, _is_binary), mesh_(Base::mesh()), min_aspect_( 1.f / _min_aspect) { diff --git a/src/OpenMesh/Tools/Decimater/ModEdgeLengthT.hh b/src/OpenMesh/Tools/Decimater/ModEdgeLengthT.hh index e21b3223..cd21bfdb 100644 --- a/src/OpenMesh/Tools/Decimater/ModEdgeLengthT.hh +++ b/src/OpenMesh/Tools/Decimater/ModEdgeLengthT.hh @@ -79,7 +79,7 @@ class ModEdgeLengthT: public ModBaseT { ; /// Constructor - ModEdgeLengthT(MeshT& _mesh, float _edge_length = FLT_MAX, + explicit ModEdgeLengthT(MeshT& _mesh, float _edge_length = FLT_MAX, bool _is_binary = true); /// get edge_length diff --git a/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh b/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh index 12b046c5..4f16f623 100644 --- a/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh +++ b/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh @@ -87,7 +87,7 @@ class ModHausdorffT: public ModBaseT { typedef std::vector Points; /// Constructor - ModHausdorffT(MeshT& _mesh, Scalar _error_tolerance = FLT_MAX) : + explicit ModHausdorffT(MeshT& _mesh, Scalar _error_tolerance = FLT_MAX) : Base(_mesh, true), mesh_(Base::mesh()), tolerance_(_error_tolerance) { mesh_.add_property(points_); } From a94dc3dabec4d89020f8596fe7d9a7128af73c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:06:40 +0200 Subject: [PATCH 33/60] more const refs --- src/OpenMesh/Core/Mesh/CirculatorsT.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/CirculatorsT.hh b/src/OpenMesh/Core/Mesh/CirculatorsT.hh index a4926e1d..d937908b 100644 --- a/src/OpenMesh/Core/Mesh/CirculatorsT.hh +++ b/src/OpenMesh/Core/Mesh/CirculatorsT.hh @@ -171,10 +171,10 @@ class GenericCirculator_ValueHandleFnsT { } } - inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { GenericCirculator_CenterEntityFnsT::increment(mesh, heh, start, lap_counter); } - inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { GenericCirculator_CenterEntityFnsT::decrement(mesh, heh, start, lap_counter); } }; @@ -426,10 +426,10 @@ class GenericCirculator_ValueHandleFnsT_DEPRECATED { return ( heh.is_valid() && ((start != heh) || (lap_counter == 0 )) ); } inline static void init(const Mesh*, typename Mesh::HalfedgeHandle&, typename Mesh::HalfedgeHandle&, int&) {}; - inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { GenericCirculator_CenterEntityFnsT::increment(mesh, heh, start, lap_counter); } - inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) { GenericCirculator_CenterEntityFnsT::decrement(mesh, heh, start, lap_counter); } }; From 40cdb14b6aa700cb5f682c00a49e61aefa686d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:06:56 +0200 Subject: [PATCH 34/60] Removed unused private function --- src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc b/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc index 79f3b675..a6940f62 100644 --- a/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc +++ b/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc @@ -154,9 +154,6 @@ public: private: - /// hide this method - void set_binary(bool _b) {} - OpenMesh::VPropHandleT level_; level_t max_level_; // maximum level reached From 931368f0badba63e9e806b27a86bac72a056b5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:07:59 +0200 Subject: [PATCH 35/60] Skip unused define --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index 870706a0..ce31e3ba 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -22,7 +22,7 @@ echo -e "${NC}" echo "Please Wait ..." # Run cppcheck and output into file -cppcheck --enable=all . -I src -i Doc/ -i src/Unittests --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -UBMPOSTFIX -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log +cppcheck --enable=all . -I src -i Doc/ -i src/Unittests --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -UBMPOSTFIX -UMIPS_WARN_WA -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log COUNT=$(wc -l < cppcheck.log ) From 38e5a2313b2e1e6ef2a341a0fd3c707335600a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:16:01 +0200 Subject: [PATCH 36/60] Get rid of some old c style casts --- src/OpenMesh/Core/IO/BinaryHelper.cc | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/OpenMesh/Core/IO/BinaryHelper.cc b/src/OpenMesh/Core/IO/BinaryHelper.cc index d5386e98..c30d5452 100644 --- a/src/OpenMesh/Core/IO/BinaryHelper.cc +++ b/src/OpenMesh/Core/IO/BinaryHelper.cc @@ -74,7 +74,7 @@ namespace IO { short int read_short(FILE* _in, bool _swap) { union u1 { short int s; unsigned char c[2]; } sc; - fread((char*)sc.c, 1, 2, _in); + fread(reinterpret_cast(sc.c), 1, 2, _in); if (_swap) std::swap(sc.c[0], sc.c[1]); return sc.s; } @@ -86,7 +86,7 @@ short int read_short(FILE* _in, bool _swap) int read_int(FILE* _in, bool _swap) { union u2 { int i; unsigned char c[4]; } ic; - fread((char*)ic.c, 1, 4, _in); + fread(reinterpret_cast(ic.c), 1, 4, _in); if (_swap) { std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); @@ -101,7 +101,7 @@ int read_int(FILE* _in, bool _swap) float read_float(FILE* _in, bool _swap) { union u3 { float f; unsigned char c[4]; } fc; - fread((char*)fc.c, 1, 4, _in); + fread(reinterpret_cast(fc.c), 1, 4, _in); if (_swap) { std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); @@ -116,7 +116,7 @@ float read_float(FILE* _in, bool _swap) double read_double(FILE* _in, bool _swap) { union u4 { double d; unsigned char c[8]; } dc; - fread((char*)dc.c, 1, 8, _in); + fread(reinterpret_cast(dc.c), 1, 8, _in); if (_swap) { std::swap(dc.c[0], dc.c[7]); std::swap(dc.c[1], dc.c[6]); @@ -131,7 +131,7 @@ double read_double(FILE* _in, bool _swap) short int read_short(std::istream& _in, bool _swap) { union u1 { short int s; unsigned char c[2]; } sc; - _in.read((char*)sc.c, 2); + _in.read(reinterpret_cast(sc.c), 2); if (_swap) std::swap(sc.c[0], sc.c[1]); return sc.s; } @@ -143,7 +143,7 @@ short int read_short(std::istream& _in, bool _swap) int read_int(std::istream& _in, bool _swap) { union u2 { int i; unsigned char c[4]; } ic; - _in.read((char*)ic.c, 4); + _in.read(reinterpret_cast(ic.c), 4); if (_swap) { std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); @@ -158,7 +158,7 @@ int read_int(std::istream& _in, bool _swap) float read_float(std::istream& _in, bool _swap) { union u3 { float f; unsigned char c[4]; } fc; - _in.read((char*)fc.c, 4); + _in.read(reinterpret_cast(fc.c), 4); if (_swap) { std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); @@ -173,7 +173,7 @@ float read_float(std::istream& _in, bool _swap) double read_double(std::istream& _in, bool _swap) { union u4 { double d; unsigned char c[8]; } dc; - _in.read((char*)dc.c, 8); + _in.read(reinterpret_cast(dc.c), 8); if (_swap) { std::swap(dc.c[0], dc.c[7]); std::swap(dc.c[1], dc.c[6]); @@ -192,7 +192,7 @@ void write_short(short int _i, FILE* _out, bool _swap) union u1 { short int s; unsigned char c[2]; } sc; sc.s = _i; if (_swap) std::swap(sc.c[0], sc.c[1]); - fwrite((char*)sc.c, 1, 2, _out); + fwrite(reinterpret_cast(sc.c), 1, 2, _out); } @@ -207,7 +207,7 @@ void write_int(int _i, FILE* _out, bool _swap) std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); } - fwrite((char*)ic.c, 1, 4, _out); + fwrite(reinterpret_cast(ic.c), 1, 4, _out); } @@ -222,7 +222,7 @@ void write_float(float _f, FILE* _out, bool _swap) std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); } - fwrite((char*)fc.c, 1, 4, _out); + fwrite(reinterpret_cast(fc.c), 1, 4, _out); } @@ -239,7 +239,7 @@ void write_double(double _d, FILE* _out, bool _swap) std::swap(dc.c[2], dc.c[5]); std::swap(dc.c[3], dc.c[4]); } - fwrite((char*)dc.c, 1, 8, _out); + fwrite(reinterpret_cast(dc.c), 1, 8, _out); } @@ -251,7 +251,7 @@ void write_short(short int _i, std::ostream& _out, bool _swap) union u1 { short int s; unsigned char c[2]; } sc; sc.s = _i; if (_swap) std::swap(sc.c[0], sc.c[1]); - _out.write((char*)sc.c, 2); + _out.write(reinterpret_cast(sc.c), 2); } @@ -266,7 +266,7 @@ void write_int(int _i, std::ostream& _out, bool _swap) std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); } - _out.write((char*)ic.c, 4); + _out.write(reinterpret_cast(ic.c), 4); } @@ -281,7 +281,7 @@ void write_float(float _f, std::ostream& _out, bool _swap) std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); } - _out.write((char*)fc.c, 4); + _out.write(reinterpret_cast(fc.c), 4); } @@ -298,7 +298,7 @@ void write_double(double _d, std::ostream& _out, bool _swap) std::swap(dc.c[2], dc.c[5]); std::swap(dc.c[3], dc.c[4]); } - _out.write((char*)dc.c, 8); + _out.write(reinterpret_cast(dc.c), 8); } From be8d2380054ff5c5a0d1d0a3646309d2a7c4e954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:31:00 +0200 Subject: [PATCH 37/60] Removed c style cast --- src/OpenMesh/Core/IO/OMFormat.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/IO/OMFormat.hh b/src/OpenMesh/Core/IO/OMFormat.hh index bd14ad63..440872c1 100644 --- a/src/OpenMesh/Core/IO/OMFormat.hh +++ b/src/OpenMesh/Core/IO/OMFormat.hh @@ -141,8 +141,8 @@ namespace OMFormat { size_t restore( std::istream& _is, bool _swap ) { - if (_is.read( (char*)this, 4 ).eof()) - return 0; + if (_is.read( reinterpret_cast(this) , 4 ).eof()) + return 0; size_t bytes = 4; bytes += binary::restore( _is, n_vertices_, _swap ); From da7f28e99617627c093f17de91d3e026883adb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:31:56 +0200 Subject: [PATCH 38/60] Lowerd max allowed warnings for cppcheck --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index ce31e3ba..573431b8 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=471 +MAX_COUNT=300 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} From 5512673fc488f150ab84cb647908c45fd635d0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:33:29 +0200 Subject: [PATCH 39/60] Added missing # --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index 573431b8..949082a0 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -1,4 +1,4 @@ -!/bin/bash +#/bin/bash # Exit script on any error set -e From d53a9c99fc71fb343e8d695f55e2cdc7ba9a723c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:50:13 +0200 Subject: [PATCH 40/60] Use st algorithm --- src/OpenMesh/Core/IO/importer/ImporterT.hh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/OpenMesh/Core/IO/importer/ImporterT.hh b/src/OpenMesh/Core/IO/importer/ImporterT.hh index df38c961..008fc7dc 100644 --- a/src/OpenMesh/Core/IO/importer/ImporterT.hh +++ b/src/OpenMesh/Core/IO/importer/ImporterT.hh @@ -121,14 +121,12 @@ public: VHandles::const_iterator it, it2, end(_indices.end()); - // test for valid vertex indices - for (it=_indices.begin(); it!=end; ++it) - if (! mesh_.is_valid_handle(*it)) - { + // Test if all vertex handles are valid. If not, we throw an error. + if ( std::any_of(_indices.begin(),_indices.end(),[this](const VertexHandle& vh){ return !mesh_.is_valid_handle(vh); } ) ) + { omerr() << "ImporterT: Face contains invalid vertex index\n"; return fh; - } - + } // don't allow double vertices for (it=_indices.begin(); it!=end; ++it) From 56e967da7983056706f230087d2788ad1f86d3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:00:36 +0200 Subject: [PATCH 41/60] Fixed cppcheck warning --- .../Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc b/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc index a6940f62..2bccda5e 100644 --- a/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc +++ b/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc @@ -178,9 +178,18 @@ replace_extension( std::string& _s, const std::string& _e ) { std::string::size_type dot = _s.rfind("."); if (dot == std::string::npos) - { _s += "." + _e; } + { + // The name does not include a dot and therefore no extension. Adding both. + _s += "." + _e; + } else - { _s = _s.substr(0,dot+1)+_e; } + { + // get everything of the name including the dot but remove the extension. + const std::string name = _s.substr(0,dot+1); + + // Add the new extenion + _s = name + _e; + } return _s; } From 08b829980250da6e2d8440a7c6c309bd5568aa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:04:39 +0200 Subject: [PATCH 42/60] Reduced scope of variable --- src/OpenMesh/Core/IO/reader/PLYReader.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index 1a20af8c..6cf882c3 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -1384,8 +1384,7 @@ bool _PLYReader_::can_u_read(std::istream& _is) const { elements_.push_back(element); } else if (keyword == "property") { - std::string tmp1; - std::string tmp2; + std::string tmp1; // Read first keyword, as it might be a list _is >> tmp1; @@ -1448,6 +1447,9 @@ bool _PLYReader_::can_u_read(std::istream& _is) const { elements_.back().properties_.push_back(property); } else { + + std::string tmp2; + // as this is not a list property, read second value of property _is >> tmp2; From b4cb6bb057a51bec0ac4639ddbd87058baeef217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:14:09 +0200 Subject: [PATCH 43/60] Removed unused variable --- src/OpenMesh/Core/IO/writer/VTKWriter.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/OpenMesh/Core/IO/writer/VTKWriter.cc b/src/OpenMesh/Core/IO/writer/VTKWriter.cc index 9015222b..5c5d417a 100644 --- a/src/OpenMesh/Core/IO/writer/VTKWriter.cc +++ b/src/OpenMesh/Core/IO/writer/VTKWriter.cc @@ -40,8 +40,6 @@ bool _VTKWriter_::write(const std::string& _filename, BaseExporter& _be, const O bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const { - VertexHandle vh; - // check exporter features if (!check(_be, _writeOptions)) { return false; From 94987c9c564bad94dba161aa822e32fe447c8cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:15:20 +0200 Subject: [PATCH 44/60] Removed unused variable --- src/OpenMesh/Core/Mesh/PolyConnectivity.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc index 4114924f..9734d254 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc @@ -174,7 +174,7 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size // search a free gap // free gap will be between boundary_prev and boundary_next outer_prev = opposite_halfedge_handle(inner_next); - outer_next = opposite_halfedge_handle(inner_prev); + //outer_next = opposite_halfedge_handle(inner_prev); boundary_prev = outer_prev; do boundary_prev = From fb5119303711e21a0bac90fa1a0b0c71070b3921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:21:37 +0200 Subject: [PATCH 45/60] Lowerd max allowed warnings for cppcheck --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index 949082a0..ff4e0f7b 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=300 +MAX_COUNT=267 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} From f78dda1de7578066265a5e9f40057c1d08b6ef11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:26:59 +0200 Subject: [PATCH 46/60] Renamed some traits --- src/OpenMesh/Examples/Tutorial04/smooth.cc | 4 ++-- src/OpenMesh/Examples/Tutorial06/attributes.cc | 4 ++-- src/OpenMesh/Examples/Tutorial07/smooth.cc | 4 ++-- src/OpenMesh/Examples/Tutorial08/delete_geometry.cc | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OpenMesh/Examples/Tutorial04/smooth.cc b/src/OpenMesh/Examples/Tutorial04/smooth.cc index 3bb7f5aa..201eca7f 100644 --- a/src/OpenMesh/Examples/Tutorial04/smooth.cc +++ b/src/OpenMesh/Examples/Tutorial04/smooth.cc @@ -11,14 +11,14 @@ #ifndef DOXY_IGNORE_THIS -struct MyTraits : public OpenMesh::DefaultTraits +struct MySmootherExampleTraits : public OpenMesh::DefaultTraits { HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge); }; #endif -typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; +typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; // ---------------------------------------------------------------------------- diff --git a/src/OpenMesh/Examples/Tutorial06/attributes.cc b/src/OpenMesh/Examples/Tutorial06/attributes.cc index 8d446f72..bf8fe111 100644 --- a/src/OpenMesh/Examples/Tutorial06/attributes.cc +++ b/src/OpenMesh/Examples/Tutorial06/attributes.cc @@ -9,7 +9,7 @@ #ifndef DOXY_IGNORE_THIS // Define my personal traits -struct MyTraits : OpenMesh::DefaultTraits +struct MyAttributesExampleTraits : OpenMesh::DefaultTraits { // Let Point and Normal be a vector of doubles typedef OpenMesh::Vec3d Point; @@ -29,7 +29,7 @@ struct MyTraits : OpenMesh::DefaultTraits #endif // Define my mesh with the new traits! -typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; +typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; // ------------------------------------------------------------------ main ---- diff --git a/src/OpenMesh/Examples/Tutorial07/smooth.cc b/src/OpenMesh/Examples/Tutorial07/smooth.cc index 1710c489..d5cf6ff8 100644 --- a/src/OpenMesh/Examples/Tutorial07/smooth.cc +++ b/src/OpenMesh/Examples/Tutorial07/smooth.cc @@ -5,7 +5,7 @@ #include #include -struct MyTraits : public OpenMesh::DefaultTraits +struct MyMeshSmootherExampleTraits : public OpenMesh::DefaultTraits { // store barycenter of neighbors in this member VertexTraits @@ -21,7 +21,7 @@ struct MyTraits : public OpenMesh::DefaultTraits }; }; -typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; +typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; typedef OpenMesh::TriMesh_ArrayKernelT<> MyMesh2; // --------------------------------------------------------------------------- diff --git a/src/OpenMesh/Examples/Tutorial08/delete_geometry.cc b/src/OpenMesh/Examples/Tutorial08/delete_geometry.cc index 5614bf31..b8daffbc 100644 --- a/src/OpenMesh/Examples/Tutorial08/delete_geometry.cc +++ b/src/OpenMesh/Examples/Tutorial08/delete_geometry.cc @@ -49,7 +49,7 @@ // ---------------------------------------------------------------------------- -struct MyTraits : public OpenMesh::DefaultTraits +struct MyDeleteGeometryExampleTraits : public OpenMesh::DefaultTraits { VertexAttributes(OpenMesh::Attributes::Status); FaceAttributes(OpenMesh::Attributes::Status); @@ -57,7 +57,7 @@ struct MyTraits : public OpenMesh::DefaultTraits }; -typedef OpenMesh::PolyMesh_ArrayKernelT MyMesh; +typedef OpenMesh::PolyMesh_ArrayKernelT MyMesh; // ---------------------------------------------------------------------------- From 46a445cdaa7a070824a11d395d421f5a60cde472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:42:24 +0200 Subject: [PATCH 47/60] Removed ugly define --- src/OpenMesh/Core/IO/SR_binary.hh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/OpenMesh/Core/IO/SR_binary.hh b/src/OpenMesh/Core/IO/SR_binary.hh index 887a24ed..a64ae089 100644 --- a/src/OpenMesh/Core/IO/SR_binary.hh +++ b/src/OpenMesh/Core/IO/SR_binary.hh @@ -80,11 +80,6 @@ namespace IO { //----------------------------------------------------------------------------- // struct binary, helper for storing/restoring -#define X \ - std::ostringstream msg; \ - msg << "Type not supported: " << typeid(value_type).name(); \ - throw std::logic_error(msg.str()) - /// \struct binary SR_binary.hh /// /// The struct defines how to store and restore the type T. @@ -119,7 +114,11 @@ template < typename T, typename = void > struct binary const value_type& /* _v */, bool /* _swap */ = false , bool /* store_size */ = true ) // for vectors - { X; return 0; } + { + std::ostringstream msg; + msg << "Type not supported: " << typeid(value_type).name(); + throw std::logic_error(msg.str()); + } /// Restore a value of T and return the number of bytes read static @@ -127,7 +126,11 @@ template < typename T, typename = void > struct binary value_type& /* _v */, bool /* _swap */ = false , bool /* store_size */ = true ) // for vectors - { X; return 0; } + { + std::ostringstream msg; + msg << "Type not supported: " << typeid(value_type).name(); + throw std::logic_error(msg.str()); + } }; #undef X From 52a8f24634e6fdb80cd0e0fd9892751e1b651ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 12:23:16 +0200 Subject: [PATCH 48/60] More consts --- src/OpenMesh/Core/IO/writer/STLWriter.cc | 8 ++++---- src/OpenMesh/Core/IO/writer/STLWriter.hh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OpenMesh/Core/IO/writer/STLWriter.cc b/src/OpenMesh/Core/IO/writer/STLWriter.cc index a9f86b7e..29fa185b 100644 --- a/src/OpenMesh/Core/IO/writer/STLWriter.cc +++ b/src/OpenMesh/Core/IO/writer/STLWriter.cc @@ -139,7 +139,7 @@ write(std::ostream& _os, BaseExporter& _be, const Options& _writeOptions, std::s bool _STLWriter_:: -write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */) const +write_stla(const std::string& _filename, const BaseExporter& _be, Options /* _opt */) const { omlog() << "[STLWriter] : write ascii file\n"; @@ -204,7 +204,7 @@ write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */) bool _STLWriter_:: -write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const +write_stla(std::ostream& _out, const BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const { omlog() << "[STLWriter] : write ascii file\n"; @@ -256,7 +256,7 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea bool _STLWriter_:: -write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */) const +write_stlb(const std::string& _filename, const BaseExporter& _be, Options /* _opt */) const { omlog() << "[STLWriter] : write binary file\n"; @@ -336,7 +336,7 @@ write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */) bool _STLWriter_:: -write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const +write_stlb(std::ostream& _out, const BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const { omlog() << "[STLWriter] : write binary file\n"; diff --git a/src/OpenMesh/Core/IO/writer/STLWriter.hh b/src/OpenMesh/Core/IO/writer/STLWriter.hh index 3c258299..2deaa7ec 100644 --- a/src/OpenMesh/Core/IO/writer/STLWriter.hh +++ b/src/OpenMesh/Core/IO/writer/STLWriter.hh @@ -98,10 +98,10 @@ public: size_t binary_size(BaseExporter&, const Options&) const override; private: - bool write_stla(const std::string&, BaseExporter&, Options) const; - bool write_stla(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const; - bool write_stlb(const std::string&, BaseExporter&, Options) const; - bool write_stlb(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const; + bool write_stla(const std::string&, const BaseExporter&, Options) const; + bool write_stla(std::ostream&, const BaseExporter&, Options, std::streamsize _precision = 6) const; + bool write_stlb(const std::string&, const BaseExporter&, Options) const; + bool write_stlb(std::ostream&, const BaseExporter&, Options, std::streamsize _precision = 6) const; }; From 08e656ec817e9e41abb1e658ab1e61f70c8eb61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 12:23:35 +0200 Subject: [PATCH 49/60] More consts --- src/OpenMesh/Core/IO/reader/OMReader.cc | 10 +++++----- src/OpenMesh/Core/IO/reader/OMReader.hh | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/OMReader.cc b/src/OpenMesh/Core/IO/reader/OMReader.cc index 9de83dfa..5ed81c58 100644 --- a/src/OpenMesh/Core/IO/reader/OMReader.cc +++ b/src/OpenMesh/Core/IO/reader/OMReader.cc @@ -291,7 +291,7 @@ bool _OMReader_::supports(const OMFormat::uint8 /* version */) const //----------------------------------------------------------------------------- -bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const +bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi, const Options &_opt, bool _swap) const { using OMFormat::Chunk; @@ -447,7 +447,7 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi, //----------------------------------------------------------------------------- -bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const +bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, const Options &_opt, bool _swap) const { using OMFormat::Chunk; @@ -589,7 +589,7 @@ bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Op //----------------------------------------------------------------------------- -bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const +bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, const Options &_opt, bool _swap) const { using OMFormat::Chunk; @@ -641,7 +641,7 @@ bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Op //----------------------------------------------------------------------------- -bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi, Options & _opt, bool _swap) const +bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi, const Options & _opt, bool _swap) const { using OMFormat::Chunk; @@ -749,7 +749,7 @@ bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi //----------------------------------------------------------------------------- -bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, Options& _opt , bool _swap) const +bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, const Options& _opt , bool _swap) const { using OMFormat::Chunk; diff --git a/src/OpenMesh/Core/IO/reader/OMReader.hh b/src/OpenMesh/Core/IO/reader/OMReader.hh index 97d364a6..ed042f68 100644 --- a/src/OpenMesh/Core/IO/reader/OMReader.hh +++ b/src/OpenMesh/Core/IO/reader/OMReader.hh @@ -126,27 +126,27 @@ private: bool read_binary_vertex_chunk( std::istream &_is, BaseImporter &_bi, - Options &_opt, + const Options &_opt, bool _swap) const; bool read_binary_face_chunk( std::istream &_is, BaseImporter &_bi, - Options &_opt, + const Options &_opt, bool _swap) const; bool read_binary_edge_chunk( std::istream &_is, BaseImporter &_bi, - Options &_opt, + const Options &_opt, bool _swap) const; bool read_binary_halfedge_chunk( std::istream &_is, BaseImporter &_bi, - Options &_opt, + const Options &_opt, bool _swap) const; bool read_binary_mesh_chunk( std::istream &_is, BaseImporter &_bi, - Options &_opt, + const Options &_opt, bool _swap) const; size_t restore_binary_custom_data(std::istream& _is, From 3b27aaf2db2ed685612e3b7c2065203d068ddd98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 13:36:53 +0200 Subject: [PATCH 50/60] const arrays --- src/OpenMesh/Examples/Tutorial10/fill_props.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/OpenMesh/Examples/Tutorial10/fill_props.hh b/src/OpenMesh/Examples/Tutorial10/fill_props.hh index 75bed334..a4fc11b8 100644 --- a/src/OpenMesh/Examples/Tutorial10/fill_props.hh +++ b/src/OpenMesh/Examples/Tutorial10/fill_props.hh @@ -9,7 +9,7 @@ template bool fill_props( Mesh& _m, OpenMesh::VPropHandleT _ph, bool _check=false) { - static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f }; + const static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f }; for(typename Mesh::VertexIter it=_m.vertices_begin(); it != _m.vertices_end(); ++it) @@ -69,10 +69,10 @@ template bool fill_props( Mesh& _m, OpenMesh::HPropHandleT _ph, bool _check=false) { - static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f }; - static float b[9] = { 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f }; - static float c[9] = { 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f }; - static float d[9] = { 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f, 3.3f }; + const static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f }; + const static float b[9] = { 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f }; + const static float c[9] = { 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f }; + const static float d[9] = { 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f, 3.3f }; // static double values[9] = { 0.1, 0.02, 0.003, 0.0004, 0.00005, 0.000006, // 0.0000007, 0.00000008, 0.000000009 }; From 281d691ea7cef600f9f2b584cd7b158f1ea1d553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 13:37:08 +0200 Subject: [PATCH 51/60] More consts --- src/OpenMesh/Core/IO/writer/PLYWriter.cc | 2 +- src/OpenMesh/Core/IO/writer/PLYWriter.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.cc b/src/OpenMesh/Core/IO/writer/PLYWriter.cc index 52b86075..63984b45 100644 --- a/src/OpenMesh/Core/IO/writer/PLYWriter.cc +++ b/src/OpenMesh/Core/IO/writer/PLYWriter.cc @@ -252,7 +252,7 @@ void _PLYWriter_::write_customProp(std::ostream& _out, const CustomProperty& _pr -void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const { +void _PLYWriter_::write_header(std::ostream& _out, const BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const { //writing header _out << "ply" << '\n'; diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.hh b/src/OpenMesh/Core/IO/writer/PLYWriter.hh index 67cc310c..c081162e 100644 --- a/src/OpenMesh/Core/IO/writer/PLYWriter.hh +++ b/src/OpenMesh/Core/IO/writer/PLYWriter.hh @@ -153,7 +153,7 @@ protected: bool write_ascii(std::ostream& _out, BaseExporter&, Options) const; bool write_binary(std::ostream& _out, BaseExporter&, Options) const; /// write header into the stream _out. Returns custom properties (vertex and face) which are written into the header - void write_header(std::ostream& _out, BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const; + void write_header(std::ostream& _out, const BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const; }; From 55555a0979c18e3776a1853e7f621622e414e4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 13:42:26 +0200 Subject: [PATCH 52/60] Some fixes to avoid virtual function calls in timer --- src/OpenMesh/Tools/Utils/Timer.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Tools/Utils/Timer.cc b/src/OpenMesh/Tools/Utils/Timer.cc index e686fb78..37b85b05 100644 --- a/src/OpenMesh/Tools/Utils/Timer.cc +++ b/src/OpenMesh/Tools/Utils/Timer.cc @@ -111,7 +111,9 @@ TimerImplWin32::TimerImplWin32(void) { if (QueryPerformanceFrequency(&freq_)==FALSE) throw std::runtime_error("Performance counter of of stock!"); - reset(); + + memset(&count_,0,sizeof(count_)); + memset(&start_,0,sizeof(count_)); } void TimerImplWin32::reset(void) @@ -231,7 +233,7 @@ static const unsigned long clockticks = CLOCKS_PER_SEC; class TimerImplStd : public TimerImpl { public: - TimerImplStd() : freq_(clockticks),count_(0),start_(0) { reset(); } + TimerImplStd() : freq_(clockticks),count_(0),start_(0) { } ~TimerImplStd() { ; } virtual void reset(void) override { count_ = 0; } From e381661d5615b2011411e7974496f9b4f04a41fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 13:42:37 +0200 Subject: [PATCH 53/60] Fixed compilation --- src/OpenMesh/Core/IO/writer/PLYWriter.cc | 2 +- src/OpenMesh/Core/IO/writer/PLYWriter.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.cc b/src/OpenMesh/Core/IO/writer/PLYWriter.cc index 63984b45..52b86075 100644 --- a/src/OpenMesh/Core/IO/writer/PLYWriter.cc +++ b/src/OpenMesh/Core/IO/writer/PLYWriter.cc @@ -252,7 +252,7 @@ void _PLYWriter_::write_customProp(std::ostream& _out, const CustomProperty& _pr -void _PLYWriter_::write_header(std::ostream& _out, const BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const { +void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const { //writing header _out << "ply" << '\n'; diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.hh b/src/OpenMesh/Core/IO/writer/PLYWriter.hh index c081162e..67cc310c 100644 --- a/src/OpenMesh/Core/IO/writer/PLYWriter.hh +++ b/src/OpenMesh/Core/IO/writer/PLYWriter.hh @@ -153,7 +153,7 @@ protected: bool write_ascii(std::ostream& _out, BaseExporter&, Options) const; bool write_binary(std::ostream& _out, BaseExporter&, Options) const; /// write header into the stream _out. Returns custom properties (vertex and face) which are written into the header - void write_header(std::ostream& _out, const BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const; + void write_header(std::ostream& _out, BaseExporter& _be, Options& _opt, std::vector& _ovProps, std::vector& _ofProps) const; }; From b11c631ab0889f5caa9df451e07a74933194ef06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 13:43:40 +0200 Subject: [PATCH 54/60] Lowerd max allowed warnings for cppcheck --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index ff4e0f7b..df8814c7 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=267 +MAX_COUNT=201 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} From 21eff4fb5e0a188d0874f155e041d3f4fd729dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 14:03:48 +0200 Subject: [PATCH 55/60] Avoid call of pure virtual function --- src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh b/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh index cbf6420f..81d5917d 100644 --- a/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh +++ b/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh @@ -167,7 +167,7 @@ protected: /// \name Overload theses methods //@{ /// Prepare mesh, e.g. add properties - virtual bool prepare( MeshType& _m ) = 0; + virtual bool prepare( MeshType& /*_m*/ ) { return true; }; /// Subdivide mesh \c _m \c _n times virtual bool subdivide( MeshType& _m, size_t _n, const bool _update_points = true) = 0; From 29a5a5f61e4ab7c26e2c783afb58540ece26b74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 14:08:58 +0200 Subject: [PATCH 56/60] Fixed cppcheck warning --- src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc b/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc index 12c3f1fc..65b2288a 100644 --- a/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc +++ b/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc @@ -229,7 +229,10 @@ replace_extension( std::string& _s, const std::string& _e ) if (dot == std::string::npos) { _s += "." + _e; } else - { _s = _s.substr(0,dot+1)+_e; } + { + const std::string temp_name = _s.substr(0,dot+1); + _s = temp_name + _e; + } return _s; } From 9bd67261a6d8fe0f184adc07b3fad7a52bc45f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 14:12:11 +0200 Subject: [PATCH 57/60] Revert the subdivider change --- src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh b/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh index 81d5917d..cbf6420f 100644 --- a/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh +++ b/src/OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh @@ -167,7 +167,7 @@ protected: /// \name Overload theses methods //@{ /// Prepare mesh, e.g. add properties - virtual bool prepare( MeshType& /*_m*/ ) { return true; }; + virtual bool prepare( MeshType& _m ) = 0; /// Subdivide mesh \c _m \c _n times virtual bool subdivide( MeshType& _m, size_t _n, const bool _update_points = true) = 0; From 1d9164c11c491be922f83209d51a3bf54446792c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 14:35:16 +0200 Subject: [PATCH 58/60] Silence warning --- src/OpenMesh/Examples/Tutorial10/int2roman.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/OpenMesh/Examples/Tutorial10/int2roman.cc b/src/OpenMesh/Examples/Tutorial10/int2roman.cc index b0cb5a19..89e03478 100644 --- a/src/OpenMesh/Examples/Tutorial10/int2roman.cc +++ b/src/OpenMesh/Examples/Tutorial10/int2roman.cc @@ -27,12 +27,10 @@ std::string int2roman( size_t decimal, size_t length ) size_t power; // power of ten size_t index; // Indexes thru values to subtract - std::string roman; + std::string roman('\0'); roman.reserve(length); - roman[ 0 ] = '\0'; - for ( power = 0; power < nrows; power++ ) for ( index = 0; index < ncols; index++ ) while ( decimal >= table_arabs[ power ][ index ] ) From bb2ab36a4519049dd242c54cf28bc1917e3f976e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 14:41:13 +0200 Subject: [PATCH 59/60] Lowerd max allowed warnings for cppcheck --- CI/ci-cppcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index df8814c7..e9952cd0 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -22,7 +22,7 @@ echo -e "${NC}" echo "Please Wait ..." # Run cppcheck and output into file -cppcheck --enable=all . -I src -i Doc/ -i src/Unittests --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -UBMPOSTFIX -UMIPS_WARN_WA -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log +cppcheck --enable=all . -I src -i Doc/ -i src/Unittests --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -UBMPOSTFIX -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log COUNT=$(wc -l < cppcheck.log ) @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=201 +MAX_COUNT=168 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING} From 97100258ada32d47434ad8cf01ef000ffa91efee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 14:24:20 +0000 Subject: [PATCH 60/60] Update file ci-cppcheck.sh --- CI/ci-cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh index e9952cd0..666efa28 100755 --- a/CI/ci-cppcheck.sh +++ b/CI/ci-cppcheck.sh @@ -32,7 +32,7 @@ echo "CPPCHECK Summary" echo "==============================================================================" echo -e "${NC}" -MAX_COUNT=168 +MAX_COUNT=171 if [ $COUNT -gt $MAX_COUNT ]; then echo -e ${WARNING}