Some cppcheck fixes
This commit is contained in:
@@ -105,23 +105,23 @@ public:
|
||||
/** Write to a file
|
||||
* @param _filename write to file with the given filename
|
||||
* @param _be BaseExporter, which specifies the data source
|
||||
* @param _opt writing options
|
||||
* @param _writeOptions writing options
|
||||
* @param _precision can be used to specify the precision of the floating point notation.
|
||||
*/
|
||||
virtual bool write(const std::string& _filename,
|
||||
BaseExporter& _be,
|
||||
Options _opt,
|
||||
BaseExporter& _be,
|
||||
const Options& _writeOptions,
|
||||
std::streamsize _precision = 6) const = 0;
|
||||
|
||||
/** Write to a std::ostream
|
||||
* @param _os write to std::ostream
|
||||
* @param _be BaseExporter, which specifies the data source
|
||||
* @param _opt writing options
|
||||
* @param _writeOptions writing options
|
||||
* @param _precision can be used to specify the precision of the floating point notation.
|
||||
*/
|
||||
virtual bool write(std::ostream& _os,
|
||||
BaseExporter& _be,
|
||||
Options _opt,
|
||||
BaseExporter& _be,
|
||||
const Options& _writeOptions,
|
||||
std::streamsize _precision = 6) const = 0;
|
||||
|
||||
/// Returns expected size of file if binary format is supported else 0.
|
||||
|
||||
@@ -81,7 +81,7 @@ _OBJWriter_::_OBJWriter_() { IOManager().register_module(this); }
|
||||
|
||||
bool
|
||||
_OBJWriter_::
|
||||
write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(const std::string& _filename, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
std::fstream out(_filename.c_str(), std::ios_base::out );
|
||||
|
||||
@@ -120,7 +120,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
||||
objName_ = objName_.substr(0,dotposition);
|
||||
}
|
||||
|
||||
bool result = write(out, _be, _opt, _precision);
|
||||
bool result = write(out, _be, _writeOptions, _precision);
|
||||
|
||||
out.close();
|
||||
return result;
|
||||
@@ -213,7 +213,7 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const
|
||||
|
||||
bool
|
||||
_OBJWriter_::
|
||||
write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
unsigned int idx;
|
||||
Vec3f v, n;
|
||||
@@ -229,32 +229,32 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
_out.precision(_precision);
|
||||
|
||||
// check exporter features
|
||||
if (!check( _be, _opt)) {
|
||||
if (!check( _be, _writeOptions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// No binary mode for OBJ
|
||||
if ( _opt.check(Options::Binary) ) {
|
||||
if ( _writeOptions.check(Options::Binary) ) {
|
||||
omout() << "[OBJWriter] : Warning, Binary mode requested for OBJ Writer (No support for Binary mode), falling back to standard." << std::endl;
|
||||
}
|
||||
|
||||
// check for unsupported writer features
|
||||
if (_opt.check(Options::FaceNormal) ) {
|
||||
if (_writeOptions.check(Options::FaceNormal) ) {
|
||||
omerr() << "[OBJWriter] : FaceNormal not supported by OBJ Writer" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for unsupported writer features
|
||||
if (_opt.check(Options::VertexColor) ) {
|
||||
if (_writeOptions.check(Options::VertexColor) ) {
|
||||
omerr() << "[OBJWriter] : VertexColor not supported by OBJ Writer" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
//create material file if needed
|
||||
if ( _opt.check(Options::FaceColor) || _opt.texture_file != ""){
|
||||
if ( _writeOptions.check(Options::FaceColor) || _writeOptions.texture_file != ""){
|
||||
|
||||
std::string matFile = path_ + objName_ + _opt.material_file_extension;
|
||||
std::string matFile = path_ + objName_ + _writeOptions.material_file_extension;
|
||||
|
||||
std::fstream matStream(matFile.c_str(), std::ios_base::out );
|
||||
|
||||
@@ -263,7 +263,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
omerr() << "[OBJWriter] : cannot write material file " << matFile << std::endl;
|
||||
|
||||
}else{
|
||||
useMatrial = writeMaterial(matStream, _be, _opt);
|
||||
useMatrial = writeMaterial(matStream, _be, _writeOptions);
|
||||
|
||||
matStream.close();
|
||||
}
|
||||
@@ -274,12 +274,12 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
_out << _be.n_faces() << " faces" << '\n';
|
||||
|
||||
// material file
|
||||
if ( (useMatrial && _opt.check(Options::FaceColor)) || _opt.texture_file != "")
|
||||
_out << "mtllib " << objName_ << _opt.material_file_extension << '\n';
|
||||
if ( (useMatrial && _writeOptions.check(Options::FaceColor)) || _writeOptions.texture_file != "")
|
||||
_out << "mtllib " << objName_ << _writeOptions.material_file_extension << '\n';
|
||||
|
||||
std::map<Vec2f,int> texMap;
|
||||
//collect Texturevertices from halfedges
|
||||
if(_opt.check(Options::FaceTexCoord))
|
||||
if(_writeOptions.check(Options::FaceTexCoord))
|
||||
{
|
||||
std::vector<Vec2f> texCoords;
|
||||
//add all texCoords to map
|
||||
@@ -291,7 +291,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
}
|
||||
|
||||
//collect Texture coordinates from vertices
|
||||
if(_opt.check(Options::VertexTexCoord))
|
||||
if(_writeOptions.check(Options::VertexTexCoord))
|
||||
{
|
||||
for (size_t i=0, nV=_be.n_vertices(); i<nV; ++i)
|
||||
{
|
||||
@@ -303,7 +303,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
|
||||
// assign each texcoord in the map its id
|
||||
// and write the vt entries
|
||||
if(_opt.check(Options::VertexTexCoord) || _opt.check(Options::FaceTexCoord))
|
||||
if(_writeOptions.check(Options::VertexTexCoord) || _writeOptions.check(Options::FaceTexCoord))
|
||||
{
|
||||
int texCount = 0;
|
||||
for(std::map<Vec2f,int>::iterator it = texMap.begin(); it != texMap.end() ; ++it)
|
||||
@@ -323,26 +323,26 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
|
||||
_out << "v " << v[0] <<" "<< v[1] <<" "<< v[2] << '\n';
|
||||
|
||||
if (_opt.check(Options::VertexNormal))
|
||||
if (_writeOptions.check(Options::VertexNormal))
|
||||
_out << "vn " << n[0] <<" "<< n[1] <<" "<< n[2] << '\n';
|
||||
}
|
||||
|
||||
size_t lastMat = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
// we do not want to write seperators if we only write vertex indices
|
||||
bool onlyVertices = !_opt.check(Options::VertexTexCoord)
|
||||
&& !_opt.check(Options::VertexNormal)
|
||||
&& !_opt.check(Options::FaceTexCoord);
|
||||
bool onlyVertices = !_writeOptions.check(Options::VertexTexCoord)
|
||||
&& !_writeOptions.check(Options::VertexNormal)
|
||||
&& !_writeOptions.check(Options::FaceTexCoord);
|
||||
|
||||
// faces (indices starting at 1 not 0)
|
||||
for (size_t i=0, nF=_be.n_faces(); i<nF; ++i)
|
||||
{
|
||||
|
||||
if (useMatrial && _opt.check(Options::FaceColor) ){
|
||||
if (useMatrial && _writeOptions.check(Options::FaceColor) ){
|
||||
size_t material;
|
||||
|
||||
//color with alpha
|
||||
if ( _opt.color_has_alpha() ){
|
||||
if ( _writeOptions.color_has_alpha() ){
|
||||
cA = color_cast<OpenMesh::Vec4f> (_be.colorA( FaceHandle(int(i)) ));
|
||||
material = getMaterial(cA);
|
||||
} else{
|
||||
@@ -374,7 +374,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
_out << "/" ;
|
||||
|
||||
//write texCoords index from halfedge
|
||||
if(_opt.check(Options::FaceTexCoord))
|
||||
if(_writeOptions.check(Options::FaceTexCoord))
|
||||
{
|
||||
_out << texMap[_be.texcoord(_be.getHeh(FaceHandle(int(i)),vhandles[j]))];
|
||||
}
|
||||
@@ -382,12 +382,12 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
else
|
||||
{
|
||||
// write vertex texture coordinate index
|
||||
if (_opt.check(Options::VertexTexCoord))
|
||||
if (_writeOptions.check(Options::VertexTexCoord))
|
||||
_out << texMap[_be.texcoord(vhandles[j])];
|
||||
}
|
||||
|
||||
// write vertex normal index
|
||||
if ( _opt.check(Options::VertexNormal) ) {
|
||||
if ( _writeOptions.check(Options::VertexNormal) ) {
|
||||
// write separator
|
||||
_out << "/" ;
|
||||
_out << idx;
|
||||
|
||||
@@ -91,9 +91,9 @@ public:
|
||||
std::string get_description() const override { return "Alias/Wavefront"; }
|
||||
std::string get_extensions() const override { return "obj"; }
|
||||
|
||||
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
|
||||
bool write(const std::string&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
|
||||
|
||||
bool write(std::ostream&, BaseExporter&, Options, 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; }
|
||||
|
||||
|
||||
@@ -78,12 +78,12 @@ _OFFWriter_::_OFFWriter_() { IOManager().register_module(this); }
|
||||
|
||||
bool
|
||||
_OFFWriter_::
|
||||
write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(const std::string& _filename, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
std::ofstream out(_filename.c_str(), (_opt.check(Options::Binary) ? std::ios_base::binary | std::ios_base::out
|
||||
: std::ios_base::out) );
|
||||
std::ofstream out(_filename.c_str(), (_writeOptions.check(Options::Binary) ? std::ios_base::binary | std::ios_base::out
|
||||
: std::ios_base::out) );
|
||||
|
||||
return write(out, _be, _opt, _precision);
|
||||
return write(out, _be, _writeOptions, _precision);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -91,15 +91,15 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
||||
|
||||
bool
|
||||
_OFFWriter_::
|
||||
write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(std::ostream& _os, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
// check exporter features
|
||||
if ( !check( _be, _opt ) )
|
||||
if ( !check( _be, _writeOptions ) )
|
||||
return false;
|
||||
|
||||
|
||||
// check writer features
|
||||
if ( _opt.check(Options::FaceNormal) ) // not supported by format
|
||||
if ( _writeOptions.check(Options::FaceNormal) ) // not supported by format
|
||||
return false;
|
||||
|
||||
|
||||
@@ -111,20 +111,20 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
||||
}
|
||||
|
||||
// write header line
|
||||
if (_opt.check(Options::VertexTexCoord)) _os << "ST";
|
||||
if (_opt.check(Options::VertexColor) || _opt.check(Options::FaceColor)) _os << "C";
|
||||
if (_opt.check(Options::VertexNormal)) _os << "N";
|
||||
if (_writeOptions.check(Options::VertexTexCoord)) _os << "ST";
|
||||
if (_writeOptions.check(Options::VertexColor) || _writeOptions.check(Options::FaceColor)) _os << "C";
|
||||
if (_writeOptions.check(Options::VertexNormal)) _os << "N";
|
||||
_os << "OFF";
|
||||
if (_opt.check(Options::Binary)) _os << " BINARY";
|
||||
if (_writeOptions.check(Options::Binary)) _os << " BINARY";
|
||||
_os << "\n";
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
if (!_writeOptions.check(Options::Binary))
|
||||
_os.precision(_precision);
|
||||
|
||||
// write to file
|
||||
bool result = (_opt.check(Options::Binary) ?
|
||||
write_binary(_os, _be, _opt) :
|
||||
write_ascii(_os, _be, _opt));
|
||||
bool result = (_writeOptions.check(Options::Binary) ?
|
||||
write_binary(_os, _be, _writeOptions) :
|
||||
write_ascii(_os, _be, _writeOptions));
|
||||
|
||||
|
||||
// return result
|
||||
|
||||
@@ -100,9 +100,9 @@ public:
|
||||
std::string get_description() const override { return "no description"; }
|
||||
std::string get_extensions() const override { return "off"; }
|
||||
|
||||
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
|
||||
bool write(const std::string&, BaseExporter&, const Options&, std::streamsize _precision = 6) const override;
|
||||
|
||||
bool write(std::ostream&, BaseExporter&, Options, 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& _be, Options _opt) const override;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ _OMWriter_()
|
||||
|
||||
bool
|
||||
_OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
||||
Options _opt, std::streamsize /*_precision*/) const
|
||||
const Options& _writeOptions, std::streamsize /*_precision*/) const
|
||||
{
|
||||
// check whether exporter can give us an OpenMesh BaseKernel
|
||||
if (!_be.kernel()) return false;
|
||||
@@ -103,7 +103,9 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
||||
if (_filename.rfind(".om") == std::string::npos)
|
||||
return false;
|
||||
|
||||
_opt += Options::Binary; // only binary format supported
|
||||
Options tmpOptions = _writeOptions;
|
||||
|
||||
tmpOptions += Options::Binary; // only binary format supported
|
||||
|
||||
std::ofstream ofs(_filename.c_str(), std::ios::binary);
|
||||
|
||||
@@ -115,7 +117,7 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
||||
}
|
||||
|
||||
// call stream save method
|
||||
bool rc = write(ofs, _be, _opt);
|
||||
bool rc = write(ofs, _be, tmpOptions);
|
||||
|
||||
// close filestream
|
||||
ofs.close();
|
||||
@@ -128,27 +130,31 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool
|
||||
_OMWriter_::write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize /*_precision*/) const
|
||||
_OMWriter_::write(std::ostream& _os, BaseExporter& _be, const Options& _writeOptions, std::streamsize /*_precision*/) const
|
||||
{
|
||||
// std::clog << "[OMWriter]::write( stream )\n";
|
||||
|
||||
Options tmpOptions = _writeOptions;
|
||||
|
||||
// check exporter features
|
||||
if ( !check( _be, _opt ) )
|
||||
if ( !check( _be, tmpOptions ) )
|
||||
{
|
||||
omerr() << "[OMWriter]: exporter does not support wanted feature!\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Maybe an ascii version will be implemented in the future.
|
||||
// For now, support only a binary format
|
||||
if ( !_opt.check( Options::Binary ) )
|
||||
_opt += Options::Binary;
|
||||
if ( !tmpOptions.check( Options::Binary ) )
|
||||
tmpOptions += Options::Binary;
|
||||
|
||||
// Ignore LSB/MSB bit. Always store in LSB (little endian)
|
||||
_opt += Options::LSB;
|
||||
_opt -= Options::MSB;
|
||||
tmpOptions += Options::LSB;
|
||||
tmpOptions -= Options::MSB;
|
||||
|
||||
return write_binary(_os, _be, _opt);
|
||||
return write_binary(_os, _be, tmpOptions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
std::string get_extensions() const override
|
||||
{ return "om"; }
|
||||
|
||||
bool write(std::ostream&, BaseExporter&, Options, 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& _be, Options _opt) const override;
|
||||
|
||||
@@ -116,7 +116,7 @@ protected:
|
||||
static const OMFormat::uchar magic_[3];
|
||||
static const OMFormat::uint8 version_;
|
||||
|
||||
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
|
||||
bool write(const std::string&, BaseExporter&, const Options&, std::streamsize _precision = 6) const override;
|
||||
|
||||
bool write_binary(std::ostream&, BaseExporter&, Options) const;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ _PLYWriter_::_PLYWriter_()
|
||||
|
||||
bool
|
||||
_PLYWriter_::
|
||||
write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(const std::string& _filename, BaseExporter& _be, const Options& _opt, std::streamsize _precision) const
|
||||
{
|
||||
|
||||
// open file
|
||||
@@ -106,23 +106,24 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
||||
|
||||
bool
|
||||
_PLYWriter_::
|
||||
write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(std::ostream& _os, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
|
||||
options_ = _writeOptions;
|
||||
|
||||
// check exporter features
|
||||
if ( !check( _be, _opt ) )
|
||||
if ( !check( _be, options_ ) )
|
||||
return false;
|
||||
|
||||
|
||||
// check writer features
|
||||
if ( _opt.check(Options::FaceNormal) ) {
|
||||
if ( options_.check(Options::FaceNormal) ) {
|
||||
// Face normals are not supported
|
||||
// Uncheck these options and output message that
|
||||
// they are not written out even though they were requested
|
||||
_opt.unset(Options::FaceNormal);
|
||||
options_.unset(Options::FaceNormal);
|
||||
omerr() << "[PLYWriter] : Warning: Face normals are not supported and thus not exported! " << std::endl;
|
||||
}
|
||||
|
||||
options_ = _opt;
|
||||
|
||||
|
||||
if (!_os.good())
|
||||
@@ -132,13 +133,13 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
if (!options_.check(Options::Binary))
|
||||
_os.precision(_precision);
|
||||
|
||||
// write to file
|
||||
bool result = (_opt.check(Options::Binary) ?
|
||||
write_binary(_os, _be, _opt) :
|
||||
write_ascii(_os, _be, _opt));
|
||||
bool result = (options_.check(Options::Binary) ?
|
||||
write_binary(_os, _be, options_) :
|
||||
write_ascii(_os, _be, options_));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ public:
|
||||
std::string get_description() const override { return "PLY polygon file format"; }
|
||||
std::string get_extensions() const override { return "ply"; }
|
||||
|
||||
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
|
||||
bool write(const std::string&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
|
||||
|
||||
bool write(std::ostream&, BaseExporter&, Options, 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& _be, Options _opt) const override;
|
||||
|
||||
|
||||
@@ -80,23 +80,25 @@ _STLWriter_::_STLWriter_() { IOManager().register_module(this); }
|
||||
|
||||
bool
|
||||
_STLWriter_::
|
||||
write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(const std::string& _filename, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
Options tmpOptions = _writeOptions;
|
||||
|
||||
// binary or ascii ?
|
||||
if (_filename.rfind(".stla") != std::string::npos)
|
||||
{
|
||||
_opt -= Options::Binary;
|
||||
tmpOptions -= Options::Binary;
|
||||
}
|
||||
else if (_filename.rfind(".stlb") != std::string::npos)
|
||||
{
|
||||
_opt += Options::Binary;
|
||||
tmpOptions += Options::Binary;
|
||||
}
|
||||
|
||||
// open file
|
||||
std::fstream out(_filename.c_str(), (_opt.check(Options::Binary) ? std::ios_base::binary | std::ios_base::out
|
||||
: std::ios_base::out) );
|
||||
std::fstream out(_filename.c_str(), (tmpOptions.check(Options::Binary) ? std::ios_base::binary | std::ios_base::out
|
||||
: std::ios_base::out) );
|
||||
|
||||
bool result = write(out, _be, _opt, _precision);
|
||||
bool result = write(out, _be, tmpOptions, _precision);
|
||||
|
||||
out.close();
|
||||
|
||||
@@ -108,24 +110,24 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
||||
|
||||
bool
|
||||
_STLWriter_::
|
||||
write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
write(std::ostream& _os, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
// check exporter features
|
||||
if (!check(_be, _opt)) return false;
|
||||
if (!check(_be, _writeOptions)) return false;
|
||||
|
||||
// check writer features
|
||||
if (_opt.check(Options::VertexNormal) ||
|
||||
_opt.check(Options::VertexTexCoord) ||
|
||||
_opt.check(Options::FaceColor))
|
||||
if (_writeOptions.check(Options::VertexNormal) ||
|
||||
_writeOptions.check(Options::VertexTexCoord) ||
|
||||
_writeOptions.check(Options::FaceColor))
|
||||
return false;
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
if (!_writeOptions.check(Options::Binary))
|
||||
_os.precision(_precision);
|
||||
|
||||
if (_opt & Options::Binary)
|
||||
return write_stlb(_os, _be, _opt);
|
||||
if (_writeOptions & Options::Binary)
|
||||
return write_stlb(_os, _be, _writeOptions);
|
||||
else
|
||||
return write_stla(_os, _be, _opt);
|
||||
return write_stla(_os, _be, _writeOptions);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ public:
|
||||
std::string get_description() const override { return "Stereolithography Format"; }
|
||||
std::string get_extensions() const override { return "stl stla stlb"; }
|
||||
|
||||
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
|
||||
bool write(const std::string&, BaseExporter&, const Options& _writeOptions, std::streamsize _precision = 6) const override;
|
||||
|
||||
bool write(std::ostream&, BaseExporter&, Options, 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;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ _VTKWriter_::_VTKWriter_() { IOManager().register_module(this); }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool _VTKWriter_::write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
bool _VTKWriter_::write(const std::string& _filename, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
std::ofstream out(_filename.c_str());
|
||||
|
||||
@@ -33,22 +33,22 @@ bool _VTKWriter_::write(const std::string& _filename, BaseExporter& _be, Options
|
||||
return false;
|
||||
}
|
||||
|
||||
return write(out, _be, _opt, _precision);
|
||||
return write(out, _be, _writeOptions, _precision);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
|
||||
{
|
||||
VertexHandle vh;
|
||||
|
||||
// check exporter features
|
||||
if (!check(_be, _opt)) {
|
||||
if (!check(_be, _writeOptions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check writer features
|
||||
if (!_opt.is_empty()) {
|
||||
if (!_writeOptions.is_empty()) {
|
||||
omlog() << "[VTKWriter] : writer does not support any options\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
std::string get_description() const override { return "VTK"; }
|
||||
std::string get_extensions() const override { return "vtk"; }
|
||||
|
||||
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
|
||||
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
|
||||
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; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user