only set precision for writers that write ascii
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@749 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -100,8 +100,6 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
||||
return false;
|
||||
}
|
||||
|
||||
out.precision(_precision);
|
||||
|
||||
// write header line
|
||||
if (_opt.check(Options::VertexTexCoord)) out << "ST";
|
||||
if (_opt.check(Options::VertexColor) || _opt.check(Options::FaceColor)) out << "C";
|
||||
@@ -111,6 +109,9 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
||||
out << "\n";
|
||||
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
out.precision(_precision);
|
||||
|
||||
// write to file
|
||||
bool result = (_opt.check(Options::Binary) ?
|
||||
write_binary(out, _be, _opt) :
|
||||
@@ -146,8 +147,6 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
||||
return false;
|
||||
}
|
||||
|
||||
_os.precision(_precision);
|
||||
|
||||
// write header line
|
||||
if (_opt.check(Options::VertexTexCoord)) _os << "ST";
|
||||
if (_opt.check(Options::VertexColor) || _opt.check(Options::FaceColor)) _os << "C";
|
||||
@@ -156,6 +155,8 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
||||
if (_opt.check(Options::Binary)) _os << " BINARY";
|
||||
_os << "\n";
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
_os.precision(_precision);
|
||||
|
||||
// write to file
|
||||
bool result = (_opt.check(Options::Binary) ?
|
||||
|
||||
@@ -91,7 +91,7 @@ _OMWriter_()
|
||||
|
||||
bool
|
||||
_OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
||||
Options _opt, std::streamsize _precision) const
|
||||
Options _opt, std::streamsize /*_precision*/) const
|
||||
{
|
||||
// check whether exporter can give us an OpenMesh BaseKernel
|
||||
if (!_be.kernel()) return false;
|
||||
@@ -104,7 +104,6 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
||||
_opt += Options::Binary; // only binary format supported
|
||||
|
||||
std::ofstream ofs(_filename.c_str(), std::ios::binary);
|
||||
ofs.precision(_precision);
|
||||
|
||||
// check if file is open
|
||||
if (!ofs.is_open())
|
||||
@@ -127,10 +126,9 @@ _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, Options _opt, std::streamsize /*_precision*/) const
|
||||
{
|
||||
// std::clog << "[OMWriter]::write( stream )\n";
|
||||
_os.precision(_precision);
|
||||
|
||||
// check exporter features
|
||||
if ( !check( _be, _opt ) )
|
||||
|
||||
@@ -115,6 +115,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
out.precision(_precision);
|
||||
|
||||
// write to file
|
||||
@@ -153,6 +154,7 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
_os.precision(_precision);
|
||||
|
||||
// write to file
|
||||
|
||||
@@ -81,36 +81,25 @@ bool
|
||||
_STLWriter_::
|
||||
write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
||||
{
|
||||
// check exporter features
|
||||
if (!check(_be, _opt)) return false;
|
||||
|
||||
|
||||
// check writer features
|
||||
if (_opt.check(Options::VertexNormal) ||
|
||||
_opt.check(Options::VertexTexCoord) ||
|
||||
_opt.check(Options::FaceColor))
|
||||
return false;
|
||||
|
||||
|
||||
// binary or ascii ?
|
||||
if (_filename.rfind(".stla") != std::string::npos)
|
||||
{
|
||||
_opt -= Options::Binary;
|
||||
return write_stla(_filename, _be, _opt);
|
||||
}
|
||||
else if (_filename.rfind(".stlb") != std::string::npos)
|
||||
{
|
||||
_opt += Options::Binary;
|
||||
return write_stlb(_filename, _be, _opt);
|
||||
}
|
||||
else if (_filename.rfind(".stl") != std::string::npos)
|
||||
{
|
||||
return (_opt.check( Options::Binary )
|
||||
? write_stlb(_filename, _be, _opt)
|
||||
: write_stla(_filename, _be, _opt) );
|
||||
}
|
||||
|
||||
return false;
|
||||
// open file
|
||||
std::fstream out(_filename.c_str(), (_opt.check(Options::Binary) ? std::ios_base::binary | std::ios_base::out
|
||||
: std::ios_base::out) );
|
||||
|
||||
bool result = write(out, _be, _opt, _precision);
|
||||
|
||||
out.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -129,6 +118,7 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
||||
_opt.check(Options::FaceColor))
|
||||
return false;
|
||||
|
||||
if (!_opt.check(Options::Binary))
|
||||
_os.precision(_precision);
|
||||
|
||||
if (_opt & Options::Binary)
|
||||
|
||||
Reference in New Issue
Block a user