Some more cppcheck fixes

This commit is contained in:
Jan Möbius
2023-03-01 12:58:05 +01:00
parent c18457ae02
commit 12e1efdb8a
11 changed files with 77 additions and 77 deletions

View File

@@ -125,21 +125,21 @@ public:
std::streamsize _precision = 6) const = 0;
/// Returns expected size of file if binary format is supported else 0.
virtual size_t binary_size(BaseExporter&, Options) const { return 0; }
virtual size_t binary_size(BaseExporter&, const Options&) const { return 0; }
protected:
bool check(BaseExporter& _be, Options _opt) const
bool check(BaseExporter& _be, const Options& _writeOptions) const
{
// Check for all Options. When we want to write them (_opt.check() ) , they have to be available ( has_ )
// Converts to not A (write them) or B (available)
return ( !_opt.check(Options::VertexNormal ) || _be.has_vertex_normals())
&& ( !_opt.check(Options::VertexTexCoord)|| _be.has_vertex_texcoords())
&& ( !_opt.check(Options::VertexColor) || _be.has_vertex_colors())
&& ( !_opt.check(Options::FaceNormal) || _be.has_face_normals())
&& ( !_opt.check(Options::FaceColor) || _be.has_face_colors());
return ( !_writeOptions.check(Options::VertexNormal ) || _be.has_vertex_normals())
&& ( !_writeOptions.check(Options::VertexTexCoord)|| _be.has_vertex_texcoords())
&& ( !_writeOptions.check(Options::VertexColor) || _be.has_vertex_colors())
&& ( !_writeOptions.check(Options::FaceNormal) || _be.has_face_normals())
&& ( !_writeOptions.check(Options::FaceColor) || _be.has_face_colors());
}
};

View File

@@ -95,7 +95,7 @@ public:
bool write(std::ostream&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter&, Options) const override { return 0; }
size_t binary_size(BaseExporter&, const Options&) const override { return 0; }
private:

View File

@@ -136,7 +136,7 @@ write(std::ostream& _os, BaseExporter& _be, const Options& _writeOptions, std::s
bool
_OFFWriter_::
write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
write_ascii(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions) const
{
unsigned int i, nV, nF;
@@ -155,7 +155,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << _be.n_faces() << " ";
_out << 0 << "\n";
if (_opt.color_is_float())
if (_writeOptions.color_is_float())
_out << std::fixed;
@@ -169,16 +169,16 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << v[0] << " " << v[1] << " " << v[2];
// VertexNormal
if ( _opt.vertex_has_normal() ) {
if ( _writeOptions.vertex_has_normal() ) {
n = _be.normal(vh);
_out << " " << n[0] << " " << n[1] << " " << n[2];
}
// VertexColor
if ( _opt.vertex_has_color() ) {
if ( _opt.color_is_float() ) {
if ( _writeOptions.vertex_has_color() ) {
if ( _writeOptions.color_is_float() ) {
//with alpha
if ( _opt.color_has_alpha() ){
if ( _writeOptions.color_has_alpha() ){
cAf = _be.colorAf(vh);
_out << " " << cAf;
}else{
@@ -188,7 +188,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
}
} else {
//with alpha
if ( _opt.color_has_alpha() ){
if ( _writeOptions.color_has_alpha() ){
cA = _be.colorA(vh);
_out << " " << cA;
}else{
@@ -200,7 +200,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
}
// TexCoord
if (_opt.vertex_has_texcoord() ) {
if (_writeOptions.vertex_has_texcoord() ) {
t = _be.texcoord(vh);
_out << " " << t[0] << " " << t[1];
}
@@ -221,10 +221,10 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << vhandles[2].idx();
//face color
if ( _opt.face_has_color() ){
if ( _opt.color_is_float() ) {
if ( _writeOptions.face_has_color() ){
if ( _writeOptions.color_is_float() ) {
//with alpha
if ( _opt.color_has_alpha() ){
if ( _writeOptions.color_has_alpha() ){
cAf = _be.colorAf( FaceHandle(i) );
_out << " " << cAf;
}else{
@@ -234,7 +234,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
}
} else {
//with alpha
if ( _opt.color_has_alpha() ){
if ( _writeOptions.color_has_alpha() ){
cA = _be.colorA( FaceHandle(i) );
_out << " " << cA;
}else{
@@ -257,10 +257,10 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << vhandles[j].idx() << " ";
//face color
if ( _opt.face_has_color() ){
if ( _opt.color_is_float() ) {
if ( _writeOptions.face_has_color() ){
if ( _writeOptions.color_is_float() ) {
//with alpha
if ( _opt.color_has_alpha() ){
if ( _writeOptions.color_has_alpha() ){
cAf = _be.colorAf( FaceHandle(i) );
_out << " " << cAf;
}else{
@@ -270,7 +270,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
}
} else {
//with alpha
if ( _opt.color_has_alpha() ){
if ( _writeOptions.color_has_alpha() ){
cA = _be.colorA( FaceHandle(i) );
_out << " " << cA;
}else{
@@ -312,7 +312,7 @@ void _OFFWriter_::writeValue(std::ostream& _out, float value) const {
bool
_OFFWriter_::
write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
write_binary(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions) const
{
unsigned int i, nV, nF;
@@ -340,21 +340,21 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
writeValue(_out, v[2]);
// vertex normal
if ( _opt.vertex_has_normal() ) {
if ( _writeOptions.vertex_has_normal() ) {
n = _be.normal(vh);
writeValue(_out, n[0]);
writeValue(_out, n[1]);
writeValue(_out, n[2]);
}
// vertex color
if ( _opt.vertex_has_color() ) {
if ( _opt.color_is_float() ) {
if ( _writeOptions.vertex_has_color() ) {
if ( _writeOptions.color_is_float() ) {
cf = _be.colorAf(vh);
writeValue(_out, cf[0]);
writeValue(_out, cf[1]);
writeValue(_out, cf[2]);
if ( _opt.color_has_alpha() )
if ( _writeOptions.color_has_alpha() )
writeValue(_out, cf[3]);
} else {
c = _be.colorA(vh);
@@ -362,12 +362,12 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
writeValue(_out, c[1]);
writeValue(_out, c[2]);
if ( _opt.color_has_alpha() )
if ( _writeOptions.color_has_alpha() )
writeValue(_out, c[3]);
}
}
// texCoords
if (_opt.vertex_has_texcoord() ) {
if (_writeOptions.vertex_has_texcoord() ) {
t = _be.texcoord(vh);
writeValue(_out, t[0]);
writeValue(_out, t[1]);
@@ -388,14 +388,14 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
writeValue(_out, vhandles[2].idx());
//face color
if ( _opt.face_has_color() ){
if ( _opt.color_is_float() ) {
if ( _writeOptions.face_has_color() ){
if ( _writeOptions.color_is_float() ) {
cf = _be.colorAf( FaceHandle(i) );
writeValue(_out, cf[0]);
writeValue(_out, cf[1]);
writeValue(_out, cf[2]);
if ( _opt.color_has_alpha() )
if ( _writeOptions.color_has_alpha() )
writeValue(_out, cf[3]);
} else {
c = _be.colorA( FaceHandle(i) );
@@ -403,7 +403,7 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
writeValue(_out, c[1]);
writeValue(_out, c[2]);
if ( _opt.color_has_alpha() )
if ( _writeOptions.color_has_alpha() )
writeValue(_out, c[3]);
}
}
@@ -420,14 +420,14 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
writeValue(_out, vhandles[j].idx() );
//face color
if ( _opt.face_has_color() ){
if ( _opt.color_is_float() ) {
if ( _writeOptions.face_has_color() ){
if ( _writeOptions.color_is_float() ) {
cf = _be.colorAf( FaceHandle(i) );
writeValue(_out, cf[0]);
writeValue(_out, cf[1]);
writeValue(_out, cf[2]);
if ( _opt.color_has_alpha() )
if ( _writeOptions.color_has_alpha() )
writeValue(_out, cf[3]);
} else {
c = _be.colorA( FaceHandle(i) );
@@ -435,7 +435,7 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
writeValue(_out, c[1]);
writeValue(_out, c[2]);
if ( _opt.color_has_alpha() )
if ( _writeOptions.color_has_alpha() )
writeValue(_out, c[3]);
}
}
@@ -450,7 +450,7 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
size_t
_OFFWriter_::
binary_size(BaseExporter& _be, Options _opt) const
binary_size(BaseExporter& _be, const Options& _writeOptions) const
{
size_t header(0);
size_t data(0);
@@ -459,7 +459,7 @@ binary_size(BaseExporter& _be, Options _opt) const
size_t _3ui(3*sizeof(unsigned int));
size_t _4ui(4*sizeof(unsigned int));
if ( !_opt.is_binary() )
if ( !_writeOptions.is_binary() )
return 0;
else
{
@@ -470,19 +470,19 @@ binary_size(BaseExporter& _be, Options _opt) const
data += _be.n_vertices() * _3floats; // vertex data
}
if ( _opt.vertex_has_normal() && _be.has_vertex_normals() )
if ( _writeOptions.vertex_has_normal() && _be.has_vertex_normals() )
{
header += 1; // N
data += _be.n_vertices() * _3floats;
}
if ( _opt.vertex_has_color() && _be.has_vertex_colors() )
if ( _writeOptions.vertex_has_color() && _be.has_vertex_colors() )
{
header += 1; // C
data += _be.n_vertices() * _3floats;
}
if ( _opt.vertex_has_texcoord() && _be.has_vertex_texcoords() )
if ( _writeOptions.vertex_has_texcoord() && _be.has_vertex_texcoords() )
{
size_t _2floats(2*sizeof(float));
header += 2; // ST
@@ -505,8 +505,8 @@ binary_size(BaseExporter& _be, Options _opt) const
}
// face colors
if ( _opt.face_has_color() && _be.has_face_colors() ){
if ( _opt.color_has_alpha() )
if ( _writeOptions.face_has_color() && _be.has_face_colors() ){
if ( _writeOptions.color_has_alpha() )
data += _be.n_faces() * _4ui;
else
data += _be.n_faces() * _3ui;

View File

@@ -104,7 +104,7 @@ public:
bool write(std::ostream&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter& _be, Options _opt) const override;
size_t binary_size(BaseExporter& _be, const Options& _opt) const override;
protected:
@@ -112,8 +112,8 @@ protected:
void writeValue(std::ostream& _out, unsigned int value) const;
void writeValue(std::ostream& _out, float value) const;
bool write_ascii(std::ostream& _in, BaseExporter&, Options) const;
bool write_binary(std::ostream& _in, BaseExporter&, Options) const;
bool write_ascii(std::ostream& _in, BaseExporter&, const Options& _writeOptions) const;
bool write_binary(std::ostream& _in, BaseExporter&, const Options& _writeOptions) const;
};

View File

@@ -175,7 +175,7 @@ template <typename T> struct Enabler
bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
Options _opt) const
const Options& _writeOptions) const
{
#ifndef DOXY_IGNORE_THIS
Enabler<mostream> enabler(omlog());
@@ -184,7 +184,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
size_t bytes = 0;
const bool swap =
_opt.check(Options::Swap) || (Endian::local() == Endian::MSB);
_writeOptions.check(Options::Swap) || (Endian::local() == Endian::MSB);
unsigned int i, nV, nF;
Vec3f v;
@@ -245,7 +245,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// ---------- write vertex normal
if (_be.n_vertices() && _opt.check( Options::VertexNormal ))
if (_be.n_vertices() && _writeOptions.check( Options::VertexNormal ))
{
Vec3f n = _be.normal(VertexHandle(0));
Vec3d nd = _be.normald(VertexHandle(0));
@@ -279,7 +279,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
}
// ---------- write vertex color
if (_be.n_vertices() && _opt.check( Options::VertexColor ) && _be.has_vertex_colors() )
if (_be.n_vertices() && _writeOptions.check( Options::VertexColor ) && _be.has_vertex_colors() )
{
Vec3uc c = _be.color(VertexHandle(0));
@@ -297,7 +297,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
}
// ---------- write vertex texture coords
if (_be.n_vertices() && _opt.check(Options::VertexTexCoord)) {
if (_be.n_vertices() && _writeOptions.check(Options::VertexTexCoord)) {
t = _be.texcoord(VertexHandle(0));
@@ -344,7 +344,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// ---------- write face texture coords
if (_OMWriter_::version_ > OMFormat::mk_version(2,1) && _be.n_edges() && _opt.check(Options::FaceTexCoord))
if (_OMWriter_::version_ > OMFormat::mk_version(2,1) && _be.n_edges() && _writeOptions.check(Options::FaceTexCoord))
{
t = _be.texcoord(HalfedgeHandle(0));
@@ -407,7 +407,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// ---------- write face normals
if (_be.n_faces() && _be.has_face_normals() && _opt.check(Options::FaceNormal) )
if (_be.n_faces() && _be.has_face_normals() && _writeOptions.check(Options::FaceNormal) )
{
#define NEW_STYLE 0
#if NEW_STYLE
@@ -459,7 +459,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// ---------- write face color
if (_be.n_faces() && _be.has_face_colors() && _opt.check( Options::FaceColor ))
if (_be.n_faces() && _be.has_face_colors() && _writeOptions.check( Options::FaceColor ))
{
#define NEW_STYLE 0
#if NEW_STYLE
@@ -491,7 +491,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
}
// ---------- write vertex status
if (_be.n_vertices() && _be.has_vertex_status() && _opt.check(Options::Status))
if (_be.n_vertices() && _be.has_vertex_status() && _writeOptions.check(Options::Status))
{
auto s = _be.status(VertexHandle(0));
chunk_header.name_ = false;
@@ -510,7 +510,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
}
// ---------- write edge status
if (_be.n_edges() && _be.has_edge_status() && _opt.check(Options::Status))
if (_be.n_edges() && _be.has_edge_status() && _writeOptions.check(Options::Status))
{
auto s = _be.status(EdgeHandle(0));
chunk_header.name_ = false;
@@ -529,7 +529,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
}
// ---------- write halfedge status
if (_be.n_edges() && _be.has_halfedge_status() && _opt.check(Options::Status))
if (_be.n_edges() && _be.has_halfedge_status() && _writeOptions.check(Options::Status))
{
auto s = _be.status(HalfedgeHandle(0));
chunk_header.name_ = false;
@@ -548,7 +548,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
}
// ---------- write face status
if (_be.n_faces() && _be.has_face_status() && _opt.check(Options::Status))
if (_be.n_faces() && _be.has_face_status() && _writeOptions.check(Options::Status))
{
auto s = _be.status(FaceHandle(0));
chunk_header.name_ = false;
@@ -568,7 +568,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// -------------------- write custom properties
if (_opt.check(Options::Custom))
if (_writeOptions.check(Options::Custom))
{
const auto store_property = [this, &_os, swap, &bytes](
const BaseKernel::const_prop_iterator _it_begin,
@@ -672,7 +672,7 @@ size_t _OMWriter_::store_binary_custom_chunk(std::ostream& _os,
// ----------------------------------------------------------------------------
size_t _OMWriter_::binary_size(BaseExporter& /* _be */, Options /* _opt */) const
size_t _OMWriter_::binary_size(BaseExporter& /* _be */, const Options& /* _opt */) const
{
// std::clog << "[OMWriter]: binary_size()" << std::endl;
size_t bytes = sizeof( OMFormat::Header );

View File

@@ -106,7 +106,7 @@ public:
bool write(std::ostream&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter& _be, Options _opt) const override;
size_t binary_size(BaseExporter& _be, const Options& _opt) const override;
static OMFormat::uint8 get_version() { return version_; }
@@ -116,9 +116,9 @@ protected:
static const OMFormat::uchar magic_[3];
static const OMFormat::uint8 version_;
bool write(const std::string&, BaseExporter&, const Options&, std::streamsize _precision = 6) const override;
bool write(const std::string&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
bool write_binary(std::ostream&, BaseExporter&, Options) const;
bool write_binary(std::ostream&, BaseExporter&, const Options& _writeOptions) const;
size_t store_binary_custom_chunk(std::ostream&, BaseProperty&,

View File

@@ -708,7 +708,7 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
size_t
_PLYWriter_::
binary_size(BaseExporter& _be, Options _opt) const
binary_size(BaseExporter& _be, const Options& _writeOptions) const
{
size_t header(0);
size_t data(0);
@@ -716,7 +716,7 @@ binary_size(BaseExporter& _be, Options _opt) const
size_t _3ui(3*sizeof(unsigned int));
size_t _4ui(4*sizeof(unsigned int));
if ( !_opt.is_binary() )
if ( !_writeOptions.is_binary() )
return 0;
else
{
@@ -728,19 +728,19 @@ binary_size(BaseExporter& _be, Options _opt) const
data += _be.n_vertices() * _3floats; // vertex data
}
if ( _opt.vertex_has_normal() && _be.has_vertex_normals() )
if ( _writeOptions.vertex_has_normal() && _be.has_vertex_normals() )
{
header += 1; // N
data += _be.n_vertices() * _3floats;
}
if ( _opt.vertex_has_color() && _be.has_vertex_colors() )
if ( _writeOptions.vertex_has_color() && _be.has_vertex_colors() )
{
header += 1; // C
data += _be.n_vertices() * _3floats;
}
if ( _opt.vertex_has_texcoord() && _be.has_vertex_texcoords() )
if ( _writeOptions.vertex_has_texcoord() && _be.has_vertex_texcoords() )
{
size_t _2floats(2*sizeof(float));
header += 2; // ST
@@ -765,8 +765,8 @@ binary_size(BaseExporter& _be, Options _opt) const
}
// face colors
if ( _opt.face_has_color() && _be.has_face_colors() ){
if ( _opt.color_has_alpha() )
if ( _writeOptions.face_has_color() && _be.has_face_colors() ){
if ( _writeOptions.color_has_alpha() )
data += _be.n_faces() * _4ui;
else
data += _be.n_faces() * _3ui;

View File

@@ -102,7 +102,7 @@ public:
bool write(std::ostream&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter& _be, Options _opt) const override;
size_t binary_size(BaseExporter& _be, const Options& _opt) const override;
enum ValueType {
Unsupported = 0,

View File

@@ -409,7 +409,7 @@ write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
size_t
_STLWriter_::
binary_size(BaseExporter& _be, Options /* _opt */) const
binary_size(BaseExporter& _be, const Options& /* _opt */) const
{
size_t bytes(0);
size_t _12floats(12*sizeof(float));

View File

@@ -95,7 +95,7 @@ public:
bool write(std::ostream&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter&, Options) const override;
size_t binary_size(BaseExporter&, const Options&) const override;
private:
bool write_stla(const std::string&, BaseExporter&, Options) const;

View File

@@ -35,7 +35,7 @@ public:
bool write(const std::string&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
bool write(std::ostream&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter&, Options) const override { return 0; }
size_t binary_size(BaseExporter&, const Options&) const override { return 0; }
};
//== TYPE DEFINITION ==========================================================