Commit a45f4a3d by Jan Möbius

Merge branch 'fix_cppchecks' into 'master'

Fix cppchecks

See merge request !18
parents b5039f0f 35a61f0a
Pipeline #4343 passed with stage
in 3 minutes 27 seconds
......@@ -8,26 +8,11 @@ clang-c++11:
tags:
- Linux
gcc-c++98:
script: "CI/ci-linux.sh gcc C++98"
tags:
- Linux
clang-c++98:
script: "CI/ci-linux.sh clang C++98"
tags:
- Linux
macos-c++11:
script: "CI/ci-mac.sh C++11"
tags:
- Apple
macos-c++98:
script: "CI/ci-mac.sh C++98"
tags:
- Apple
cppcheck:
script: "CI/ci-cppcheck.sh"
tags:
......
......@@ -18,7 +18,7 @@ echo -e "${NC}"
echo "Please Wait ..."
# Run cppcheck and output into file
cppcheck --enable=all . -I src -i Doc/ --force --suppress=unusedFunction --suppress=missingIncludeSystem --quiet -Umin -Umax -UBMPOSTFIX -DOPENVOLUMEMESHDLLEXPORT="" &> cppcheck.log
cppcheck --enable=all . -I src -i Doc/ --force --suppress=missingIncludeSystem --quiet -Umin -Umax -UBMPOSTFIX -DOPENVOLUMEMESHDLLEXPORT="" &> cppcheck.log
echo -e "${OUTPUT}"
echo "=============================================================================="
......@@ -38,7 +38,7 @@ echo "CPPCHECK Summary"
echo "=============================================================================="
echo -e "${NC}"
if [ $COUNT -gt 0 ]; then
if [ $COUNT -gt 5 ]; then
echo -e ${WARNING}
echo "Total CPPCHECK error Count is $COUNT, which is too High! CPPCHECK Run failed";
echo -e "${NC}"
......
......@@ -42,6 +42,7 @@ else(GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES AND GTEST_MAIN_LIBRARIES)
else(GTEST_PREFIX)
find_path(_GTEST_INCLUDE_DIR "gtest/gtest.h"
PATHS
~/sw/gtest-1.8.0/include
~/sw/gtest-1.7.0/include
~/sw/gtest/include
/ACG/acgdev/gcc-4.7-x86_64/gtest/include
......@@ -52,6 +53,7 @@ else(GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES AND GTEST_MAIN_LIBRARIES)
NO_DEFAULT_PATH )
find_library(_GTEST_LIBRARY gtest
PATHS
~/sw/gtest-1.8.0/lib
~/sw/gtest-1.7.0/lib
~/sw/gtest/lib
/ACG/acgdev/gcc-4.7-x86_64/gtest/lib
......@@ -62,6 +64,7 @@ else(GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES AND GTEST_MAIN_LIBRARIES)
NO_DEFAULT_PATH )
find_library(_GTEST_MAIN_LIBRARY gtest_main
PATHS
~/sw/gtest-1.8.0/lib
~/sw/gtest-1.7.0/lib
~/sw/gtest/lib
/ACG/acgdev/gcc-4.7-x86_64/gtest/lib
......
......@@ -27,7 +27,7 @@ void print() {
template <typename Iterator>
class netgen_grammar : public qi::grammar<Iterator/*, qi::space_type*/> {
public:
netgen_grammar(MeshGenerator& _generator) :
explicit netgen_grammar(MeshGenerator& _generator) :
netgen_grammar::base_type(content),
generator_(_generator) {
......
......@@ -22,7 +22,7 @@ namespace spirit = boost::spirit;
template <typename Iterator>
class tetmesh_grammar : public qi::grammar<Iterator, qi::space_type> {
public:
tetmesh_grammar(MeshGenerator& _generator) :
explicit tetmesh_grammar(MeshGenerator& _generator) :
tetmesh_grammar::base_type(content),
generator_(_generator) {
......
......@@ -39,7 +39,7 @@ public:
typedef OpenVolumeMesh::Geometry::Vec3d Vec3d;
MeshGenerator(PolyhedralMesh& _mesh) : v_component_(0), mesh_(_mesh), progress_() {}
explicit MeshGenerator(PolyhedralMesh& _mesh) : v_component_(0), mesh_(_mesh), progress_() {}
MeshGenerator(const MeshGenerator& _cpy) :
v_component_(_cpy.v_component_),
vertex_(0.0, 0.0, 0.0),
......
......@@ -55,7 +55,7 @@ template <class GeomKernelT>
class NormalAttrib {
public:
NormalAttrib(GeomKernelT& _kernel);
explicit NormalAttrib(GeomKernelT& _kernel);
virtual ~NormalAttrib();
/** \brief A simple heuristic to estimate the vertex normals
......
......@@ -337,7 +337,7 @@ void StatusAttrib::garbage_collection(std_API_Container_VHandlePointer &vh_to_up
bool validEdge = false;
for(; voh_it.valid(); ++voh_it) {
if(!e_status_[kernel_.edge_handle(voh_it->idx())].deleted()) {
if(!e_status_[kernel_.edge_handle(*voh_it)].deleted()) {
validEdge = true;
break;
}
......
......@@ -90,7 +90,7 @@ std::ostream& operator<<(std::ostream& _os, const OpenVolumeMeshEdge& _edge);
class OpenVolumeMeshFace {
friend class TopologyKernel;
public:
OpenVolumeMeshFace(const std::vector<HalfEdgeHandle>& _halfedges) :
explicit OpenVolumeMeshFace(const std::vector<HalfEdgeHandle>& _halfedges) :
halfedges_(_halfedges) {
}
......@@ -119,7 +119,7 @@ std::ostream& operator<<(std::ostream& _os, const OpenVolumeMeshFace& _face);
class OpenVolumeMeshCell {
friend class TopologyKernel;
public:
OpenVolumeMeshCell(const std::vector<HalfFaceHandle>& _halffaces) :
explicit OpenVolumeMeshCell(const std::vector<HalfFaceHandle>& _halffaces) :
halffaces_(_halffaces) {
}
......
......@@ -55,7 +55,7 @@ class BaseProperty {
public:
friend class ResourceManager;
BaseProperty(ResourceManager& _resMan) : resMan_(_resMan), lock_(false) {}
explicit BaseProperty(ResourceManager& _resMan) : resMan_(_resMan), lock_(false) {}
BaseProperty(const BaseProperty& _cpy) : resMan_(_cpy.resMan_), lock_(_cpy.lock_) {}
......
......@@ -69,7 +69,7 @@ public:
BaseIterator(const TopologyKernel* _mesh, const OH& _ch) :
valid_(true), cur_handle_(_ch), mesh_(_mesh) {}
BaseIterator(const TopologyKernel* _mesh) :
explicit BaseIterator(const TopologyKernel* _mesh) :
valid_(true), mesh_(_mesh) {}
// STL compliance (needs to have default constructor)
......@@ -1159,7 +1159,7 @@ public:
typedef BaseIterator<FaceHandle> BaseIter;
BoundaryFaceIter(const TopologyKernel* _mesh);
explicit BoundaryFaceIter(const TopologyKernel* _mesh);
// Post increment/decrement operator
BoundaryFaceIter operator++(int) {
......
......@@ -71,7 +71,7 @@ public:
public:
OpenVolumeMeshBaseProperty(const std::string& _name = "<unknown>") :
explicit OpenVolumeMeshBaseProperty(const std::string& _name = "<unknown>") :
name_(_name), persistent_(false), handle_(-1) {
}
......
......@@ -95,19 +95,19 @@ private:
// Default entity handles
class VertexHandle : public OpenVolumeMeshHandle { public: VertexHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class EdgeHandle : public OpenVolumeMeshHandle { public: EdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class FaceHandle : public OpenVolumeMeshHandle { public: FaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class CellHandle : public OpenVolumeMeshHandle { public: CellHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfEdgeHandle : public OpenVolumeMeshHandle { public: HalfEdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfFaceHandle : public OpenVolumeMeshHandle { public: HalfFaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class VertexHandle : public OpenVolumeMeshHandle { public: explicit VertexHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class EdgeHandle : public OpenVolumeMeshHandle { public: explicit EdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class FaceHandle : public OpenVolumeMeshHandle { public: explicit FaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class CellHandle : public OpenVolumeMeshHandle { public: explicit CellHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfEdgeHandle : public OpenVolumeMeshHandle { public: explicit HalfEdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfFaceHandle : public OpenVolumeMeshHandle { public: explicit HalfFaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
// Helper class that is used to decrease all handles
// exceeding a certain threshold
class VHandleCorrection {
public:
VHandleCorrection(VertexHandle _thld) : thld_(_thld) {}
explicit VHandleCorrection(VertexHandle _thld) : thld_(_thld) {}
void correctValue(VertexHandle& _h) {
if(_h > thld_) _h.idx(_h.idx() - 1);
}
......@@ -116,7 +116,7 @@ private:
};
class HEHandleCorrection {
public:
HEHandleCorrection(HalfEdgeHandle _thld) : thld_(_thld) {}
explicit HEHandleCorrection(HalfEdgeHandle _thld) : thld_(_thld) {}
void correctVecValue(std::vector<HalfEdgeHandle>& _vec) {
#if defined(__clang_major__) && (__clang_major__ >= 5)
for(std::vector<HalfEdgeHandle>::iterator it = _vec.begin(), end = _vec.end(); it != end; ++it) {
......@@ -134,7 +134,7 @@ private:
};
class HFHandleCorrection {
public:
HFHandleCorrection(HalfFaceHandle _thld) : thld_(_thld) {}
explicit HFHandleCorrection(HalfFaceHandle _thld) : thld_(_thld) {}
void correctVecValue(std::vector<HalfFaceHandle>& _vec) {
#if defined(__clang_major__) && (__clang_major__ >= 5)
for(std::vector<HalfFaceHandle>::iterator it = _vec.begin(), end = _vec.end(); it != end; ++it) {
......@@ -152,7 +152,7 @@ private:
};
class CHandleCorrection {
public:
CHandleCorrection(CellHandle _thld) : thld_(_thld) {}
explicit CHandleCorrection(CellHandle _thld) : thld_(_thld) {}
void correctValue(CellHandle& _h) {
if(_h > thld_) _h.idx(_h.idx() - 1);
}
......
......@@ -48,13 +48,13 @@
namespace OpenVolumeMesh {
// Defines for property handles
class VertexPropHandle : public OpenVolumeMeshHandle { public: VertexPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class EdgePropHandle : public OpenVolumeMeshHandle { public: EdgePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfEdgePropHandle : public OpenVolumeMeshHandle { public: HalfEdgePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class FacePropHandle : public OpenVolumeMeshHandle { public: FacePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfFacePropHandle : public OpenVolumeMeshHandle { public: HalfFacePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class CellPropHandle : public OpenVolumeMeshHandle { public: CellPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class MeshPropHandle : public OpenVolumeMeshHandle { public: MeshPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class VertexPropHandle : public OpenVolumeMeshHandle { public: explicit VertexPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class EdgePropHandle : public OpenVolumeMeshHandle { public: explicit EdgePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfEdgePropHandle : public OpenVolumeMeshHandle { public: explicit HalfEdgePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class FacePropHandle : public OpenVolumeMeshHandle { public: explicit FacePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfFacePropHandle : public OpenVolumeMeshHandle { public: explicit HalfFacePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class CellPropHandle : public OpenVolumeMeshHandle { public: explicit CellPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class MeshPropHandle : public OpenVolumeMeshHandle { public: explicit MeshPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
} // Namespace OpenVolumeMesh
......
......@@ -1454,16 +1454,16 @@ void TopologyKernel::swap_cells(CellHandle _h1, CellHandle _h2)
for (unsigned int i = 0; i < hfhs1.size(); ++i)
{
HalfFaceHandle hfh = hfhs1[i];
if (incident_cell_per_hf_[hfh.idx()] == id1)
incident_cell_per_hf_[hfh.idx()] = id2;
if (incident_cell_per_hf_[hfh.idx()] == _h1)
incident_cell_per_hf_[hfh.idx()] = _h2;
}
std::vector<HalfFaceHandle> hfhs2 = c2.halffaces();
for (unsigned int i = 0; i < hfhs2.size(); ++i)
{
HalfFaceHandle hfh = hfhs2[i];
if (incident_cell_per_hf_[hfh.idx()] == id2)
incident_cell_per_hf_[hfh.idx()] = id1;
if (incident_cell_per_hf_[hfh.idx()] == _h2)
incident_cell_per_hf_[hfh.idx()] = _h1;
}
// swap vector entries
......
......@@ -542,7 +542,7 @@ protected:
class EdgeCorrector {
public:
EdgeCorrector(const std::vector<int>& _newIndices) :
explicit EdgeCorrector(const std::vector<int>& _newIndices) :
newIndices_(_newIndices) {}
void operator()(Edge& _edge) {
......@@ -555,7 +555,7 @@ protected:
class FaceCorrector {
public:
FaceCorrector(const std::vector<int>& _newIndices) :
explicit FaceCorrector(const std::vector<int>& _newIndices) :
newIndices_(_newIndices) {}
void operator()(Face& _face) {
......@@ -565,7 +565,7 @@ protected:
EdgeHandle eh = edge_handle(*he_it);
unsigned char opp = (he_it->idx() - halfedge_handle(eh, 0).idx());
*he_it = halfedge_handle(newIndices_[eh.idx()], opp);
*he_it = halfedge_handle(EdgeHandle(newIndices_[eh.idx()]), opp);
}
_face.set_halfedges(hes);
}
......@@ -575,7 +575,7 @@ protected:
class CellCorrector {
public:
CellCorrector(const std::vector<int>& _newIndices) :
explicit CellCorrector(const std::vector<int>& _newIndices) :
newIndices_(_newIndices) {}
void operator()(Cell& _cell) {
......@@ -585,7 +585,7 @@ protected:
FaceHandle fh = face_handle(*hf_it);
unsigned char opp = (hf_it->idx() - halfface_handle(fh, 0).idx());
*hf_it = halfface_handle(newIndices_[fh.idx()], opp);
*hf_it = halfface_handle(FaceHandle(newIndices_[fh.idx()]), opp);
}
_cell.set_halffaces(hfs);
}
......
......@@ -493,45 +493,45 @@ TEST_F(PolyhedralMeshBase, VolumeMeshConnectivity) {
// Add invalid cell
std::vector<HalfFaceHandle> hfaces;
hfaces.push_back(1); hfaces.push_back(5);
hfaces.push_back(7); hfaces.push_back(9);
hfaces.push_back(10); hfaces.push_back(21);
hfaces.push_back(HalfFaceHandle(1)); hfaces.push_back(HalfFaceHandle(5));
hfaces.push_back(HalfFaceHandle(7)); hfaces.push_back(HalfFaceHandle(9));
hfaces.push_back(HalfFaceHandle(10)); hfaces.push_back(HalfFaceHandle(21));
CellHandle i_cell = mesh_.add_cell(hfaces, true);
EXPECT_EQ(PolyhedralMesh::InvalidCellHandle, i_cell);
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(1));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(2));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(5));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(7));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(9));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(10));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(HalfFaceHandle(1)));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(HalfFaceHandle(2)));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(HalfFaceHandle(5)));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(HalfFaceHandle(7)));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(HalfFaceHandle(9)));
EXPECT_EQ(CellHandle(0), mesh_.incident_cell(HalfFaceHandle(10)));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(3));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(12));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(15));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(17));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(19));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(20));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(HalfFaceHandle(3)));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(HalfFaceHandle(12)));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(HalfFaceHandle(15)));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(HalfFaceHandle(17)));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(HalfFaceHandle(19)));
EXPECT_EQ(CellHandle(1), mesh_.incident_cell(HalfFaceHandle(20)));
// Test adjacency function
HalfFaceHandle ad_hf1 = mesh_.adjacent_halfface_in_cell(1, 3);
HalfFaceHandle ad_hf1 = mesh_.adjacent_halfface_in_cell(HalfFaceHandle(1), HalfEdgeHandle(3));
// Should be halfface 5
EXPECT_EQ(HalfFaceHandle(5), ad_hf1);
HalfFaceHandle ad_hf2 = mesh_.adjacent_halfface_in_cell(1, 7);
HalfFaceHandle ad_hf2 = mesh_.adjacent_halfface_in_cell(HalfFaceHandle(1), HalfEdgeHandle(7));
// Should be halfface 7
EXPECT_EQ(HalfFaceHandle(7), ad_hf2);
HalfFaceHandle ad_hf3 = mesh_.adjacent_halfface_in_cell(5, 24);
HalfFaceHandle ad_hf3 = mesh_.adjacent_halfface_in_cell(HalfFaceHandle(5), HalfEdgeHandle(24));
// Should be invalid
EXPECT_EQ(PolyhedralMesh::InvalidHalfFaceHandle, ad_hf3);
HalfFaceHandle ad_hf4 = mesh_.adjacent_halfface_in_cell(12, 24);
HalfFaceHandle ad_hf4 = mesh_.adjacent_halfface_in_cell(HalfFaceHandle(12), HalfEdgeHandle(24));
// Should be invalid
EXPECT_EQ(HalfFaceHandle(20), ad_hf4);
HalfFaceHandle ad_hf5 = mesh_.adjacent_halfface_in_cell(0, 0);
HalfFaceHandle ad_hf5 = mesh_.adjacent_halfface_in_cell(HalfFaceHandle(0), HalfEdgeHandle(0));
// Should be invalid
EXPECT_EQ(PolyhedralMesh::InvalidHalfFaceHandle, ad_hf5);
......@@ -1212,12 +1212,12 @@ TEST_F(HexahedralMeshBase, SimpleHexMeshNavigation) {
EXPECT_EQ(HalfFaceHandle(21), mesh_.adjacent_halfface_on_sheet(
HalfFaceHandle(8), HalfEdgeHandle(12)));
HexahedralMesh::CellSheetCellIter csc_it = mesh_.csc_iter(0, HexahedralMesh::YF);
HexahedralMesh::CellSheetCellIter csc_it = mesh_.csc_iter(CellHandle(0), HexahedralMesh::YF);
EXPECT_EQ(CellHandle(1), *csc_it);
HexahedralMesh::HalfFaceSheetHalfFaceIter hfshf_it = mesh_.hfshf_iter(5);
HexahedralMesh::HalfFaceSheetHalfFaceIter hfshf_it = mesh_.hfshf_iter(HalfFaceHandle(5));
EXPECT_EQ(HalfFaceHandle(15), *hfshf_it);
hfshf_it = mesh_.hfshf_iter(6);
hfshf_it = mesh_.hfshf_iter(HalfFaceHandle(6));
EXPECT_EQ(HalfFaceHandle(16), *hfshf_it);
}
......
......@@ -127,7 +127,7 @@ protected:
// Printer class (for STL compliance test)
class Print {
public:
Print(bool _mute = false) : mute_(_mute) {}
explicit Print(bool _mute = false) : mute_(_mute) {}
void mute(bool _mute) { mute_ = _mute; }
bool mute() const { return mute_; }
void operator()(const OpenVolumeMesh::OpenVolumeMeshHandle& _h) const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment