Fixed some cppcheck warnings

This commit is contained in:
Jan Möbius
2018-04-05 09:08:44 +02:00
parent bd3ec6a988
commit 76e33791e0
15 changed files with 28 additions and 32 deletions

View File

@@ -13,7 +13,7 @@ public:
public: public:
// construct with a given mesh // construct with a given mesh
SmootherT(Mesh& _mesh) explicit SmootherT(Mesh& _mesh)
: mesh_(_mesh) : mesh_(_mesh)
{ {
mesh_.add_property( cog_ ); mesh_.add_property( cog_ );

View File

@@ -56,7 +56,7 @@ public:
typedef T value_type; typedef T value_type;
CmdOption(const T& _val) : val_(_val), valid_(true), enabled_(false) { } explicit CmdOption(const T& _val) : val_(_val), valid_(true), enabled_(false) { }
CmdOption() : val_(T()),valid_(false), enabled_(false) { } CmdOption() : val_(T()),valid_(false), enabled_(false) { }
// has been set and has a value // has been set and has a value

View File

@@ -123,7 +123,7 @@ public:
/// default constructor /// default constructor
DecimaterViewerWidget(QWidget* _parent=0) explicit DecimaterViewerWidget(QWidget* _parent=0)
: MeshViewerWidget(_parent), : MeshViewerWidget(_parent),
animate_(false), animate_(false),
timer_(0), timer_(0),

View File

@@ -82,7 +82,7 @@ class MeshViewerWidget : public MeshViewerWidgetT<MyMesh>
Q_OBJECT Q_OBJECT
public: public:
/// default constructor /// default constructor
MeshViewerWidget(QWidget* parent=0) : MeshViewerWidgetT<MyMesh>(parent) explicit MeshViewerWidget(QWidget* parent=0) : MeshViewerWidgetT<MyMesh>(parent)
{} {}
OpenMesh::IO::Options& options() { return _options; } OpenMesh::IO::Options& options() { return _options; }
const OpenMesh::IO::Options& options() const { return _options; } const OpenMesh::IO::Options& options() const { return _options; }

View File

@@ -139,17 +139,15 @@ void VDPMClientViewerWidget::mesh_coloring()
vEnd(mesh_.vertices_end()); vEnd(mesh_.vertices_end());
VHierarchyNodeHandle node_handle; VHierarchyNodeHandle node_handle;
float ratio;
unsigned char r, g, b;
for (; vIt!=vEnd; ++vIt) for (; vIt!=vEnd; ++vIt)
{ {
node_handle = mesh_.data(*vIt).vhierarchy_node_handle(); node_handle = mesh_.data(*vIt).vhierarchy_node_handle();
ratio = vhierarchy_.node(node_handle).ratio(); const float ratio = vhierarchy_.node(node_handle).ratio();
r = (unsigned char) ((1.0f - ratio) * myYellow[0] + ratio * myBlue[0]); const unsigned char r = (unsigned char) ((1.0f - ratio) * myYellow[0] + ratio * myBlue[0]);
g = (unsigned char) ((1.0f - ratio) * myYellow[1] + ratio * myBlue[1]); const unsigned char g = (unsigned char) ((1.0f - ratio) * myYellow[1] + ratio * myBlue[1]);
b = (unsigned char) ((1.0f - ratio) * myYellow[2] + ratio * myBlue[2]); const unsigned char b = (unsigned char) ((1.0f - ratio) * myYellow[2] + ratio * myBlue[2]);
mesh_.set_color(*vIt, OpenMesh::Vec3uc(r,g,b)); mesh_.set_color(*vIt, OpenMesh::Vec3uc(r,g,b));
} }

View File

@@ -138,17 +138,15 @@ void VDPMClientViewerWidget::mesh_coloring()
vEnd(mesh_.vertices_end()); vEnd(mesh_.vertices_end());
VHierarchyNodeHandle node_handle; VHierarchyNodeHandle node_handle;
float ratio;
unsigned char r, g, b;
for (; vIt!=vEnd; ++vIt) for (; vIt!=vEnd; ++vIt)
{ {
node_handle = mesh_.data(*vIt).vhierarchy_node_handle(); node_handle = mesh_.data(*vIt).vhierarchy_node_handle();
ratio = vhierarchy_.node(node_handle).ratio(); const float ratio = vhierarchy_.node(node_handle).ratio();
r = (unsigned char) ((1.0f - ratio) * myYellow[0] + ratio * myBlue[0]); const unsigned char r = (unsigned char) ((1.0f - ratio) * myYellow[0] + ratio * myBlue[0]);
g = (unsigned char) ((1.0f - ratio) * myYellow[1] + ratio * myBlue[1]); const unsigned char g = (unsigned char) ((1.0f - ratio) * myYellow[1] + ratio * myBlue[1]);
b = (unsigned char) ((1.0f - ratio) * myYellow[2] + ratio * myBlue[2]); const unsigned char b = (unsigned char) ((1.0f - ratio) * myYellow[2] + ratio * myBlue[2]);
mesh_.set_color(*vIt, OpenMesh::Vec3uc(r,g,b)); mesh_.set_color(*vIt, OpenMesh::Vec3uc(r,g,b));
} }

View File

@@ -1062,7 +1062,7 @@ std::string get_property_name(std::string _string1, std::string _string2) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
_PLYReader_::ValueType get_property_type(std::string _string1, std::string _string2) { _PLYReader_::ValueType get_property_type(std::string& _string1, std::string& _string2) {
if (_string1 == "float32" || _string2 == "float32") if (_string1 == "float32" || _string2 == "float32")

View File

@@ -176,7 +176,7 @@ class CmpVec
{ {
public: public:
CmpVec(float _eps=FLT_MIN) : eps_(_eps) {} explicit CmpVec(float _eps=FLT_MIN) : eps_(_eps) {}
bool operator()( const Vec3f& _v0, const Vec3f& _v1 ) const bool operator()( const Vec3f& _v0, const Vec3f& _v1 ) const
{ {

View File

@@ -163,7 +163,7 @@ _OMWriter_::write(std::ostream& _os, BaseExporter& _be, Options _opt, std::strea
#ifndef DOXY_IGNORE_THIS #ifndef DOXY_IGNORE_THIS
template <typename T> struct Enabler template <typename T> struct Enabler
{ {
Enabler( T& obj ) : obj_(obj) explicit Enabler( T& obj ) : obj_(obj)
{} {}
~Enabler() { obj_.enable(); } ~Enabler() { obj_.enable(); }

View File

@@ -158,7 +158,7 @@ write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
int i, nF(int(_be.n_faces())), nV; int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n; Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles; std::vector<VertexHandle> vhandles;
FaceHandle fh; FaceHandle fh;
@@ -172,7 +172,7 @@ write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
for (i=0; i<nF; ++i) for (i=0; i<nF; ++i)
{ {
fh = FaceHandle(i); fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles); const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3) if (nV == 3)
{ {
@@ -211,7 +211,7 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
{ {
omlog() << "[STLWriter] : write ascii file\n"; omlog() << "[STLWriter] : write ascii file\n";
int i, nF(int(_be.n_faces())), nV; int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n; Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles; std::vector<VertexHandle> vhandles;
FaceHandle fh; FaceHandle fh;
@@ -226,7 +226,7 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
for (i=0; i<nF; ++i) for (i=0; i<nF; ++i)
{ {
fh = FaceHandle(i); fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles); const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3) if (nV == 3)
{ {
@@ -273,7 +273,7 @@ write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
} }
int i, nF(int(_be.n_faces())), nV; int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n; Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles; std::vector<VertexHandle> vhandles;
FaceHandle fh; FaceHandle fh;
@@ -294,7 +294,7 @@ write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
for (i=0; i<nF; ++i) for (i=0; i<nF; ++i)
{ {
fh = FaceHandle(i); fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles); const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3) if (nV == 3)
{ {
@@ -344,7 +344,7 @@ write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
omlog() << "[STLWriter] : write binary file\n"; omlog() << "[STLWriter] : write binary file\n";
int i, nF(int(_be.n_faces())), nV; int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n; Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles; std::vector<VertexHandle> vhandles;
FaceHandle fh; FaceHandle fh;
@@ -366,7 +366,7 @@ write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
for (i=0; i<nF; ++i) for (i=0; i<nF; ++i)
{ {
fh = FaceHandle(i); fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles); const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3) if (nV == 3)
{ {

View File

@@ -13,7 +13,7 @@ public:
public: public:
// construct with a given mesh // construct with a given mesh
SmootherT(Mesh& _mesh) explicit SmootherT(Mesh& _mesh)
: mesh_(_mesh) : mesh_(_mesh)
{ {
mesh_.add_property( cog_ ); mesh_.add_property( cog_ );

View File

@@ -134,7 +134,7 @@ class UnittestObserver : public OpenMesh::Decimater::Observer
size_t notifies_; size_t notifies_;
size_t all_steps_; size_t all_steps_;
public: public:
UnittestObserver(size_t _steps) :Observer(_steps), notifies_(0), all_steps_(0) {} explicit UnittestObserver(size_t _steps) :Observer(_steps), notifies_(0), all_steps_(0) {}
void notify(size_t _step) void notify(size_t _step)
{ {

View File

@@ -112,7 +112,7 @@ class UnittestObserver : public OpenMesh::Decimater::Observer
size_t notifies_; size_t notifies_;
size_t all_steps_; size_t all_steps_;
public: public:
UnittestObserver(size_t _steps) :Observer(_steps), notifies_(0), all_steps_(0) {} explicit UnittestObserver(size_t _steps) :Observer(_steps), notifies_(0), all_steps_(0) {}
void notify(size_t _step) void notify(size_t _step)
{ {

View File

@@ -112,7 +112,7 @@ class UnittestObserver : public OpenMesh::Decimater::Observer
size_t notifies_; size_t notifies_;
size_t all_steps_; size_t all_steps_;
public: public:
UnittestObserver(size_t _steps) :Observer(_steps), notifies_(0), all_steps_(0) {} explicit UnittestObserver(size_t _steps) :Observer(_steps), notifies_(0), all_steps_(0) {}
void notify(size_t _step) void notify(size_t _step)
{ {

View File

@@ -197,7 +197,7 @@ public:
public: public:
// construct with a given mesh // construct with a given mesh
SmootherT(Mesh& _mesh) explicit SmootherT(Mesh& _mesh)
: mesh_(_mesh) : mesh_(_mesh)
{ {
mesh_.add_property( cog_ ); mesh_.add_property( cog_ );