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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.precision(_precision);
|
|
||||||
|
|
||||||
// write header line
|
// write header line
|
||||||
if (_opt.check(Options::VertexTexCoord)) out << "ST";
|
if (_opt.check(Options::VertexTexCoord)) out << "ST";
|
||||||
if (_opt.check(Options::VertexColor) || _opt.check(Options::FaceColor)) out << "C";
|
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";
|
out << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
if (!_opt.check(Options::Binary))
|
||||||
|
out.precision(_precision);
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
bool result = (_opt.check(Options::Binary) ?
|
bool result = (_opt.check(Options::Binary) ?
|
||||||
write_binary(out, _be, _opt) :
|
write_binary(out, _be, _opt) :
|
||||||
@@ -146,8 +147,6 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_os.precision(_precision);
|
|
||||||
|
|
||||||
// write header line
|
// write header line
|
||||||
if (_opt.check(Options::VertexTexCoord)) _os << "ST";
|
if (_opt.check(Options::VertexTexCoord)) _os << "ST";
|
||||||
if (_opt.check(Options::VertexColor) || _opt.check(Options::FaceColor)) _os << "C";
|
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";
|
if (_opt.check(Options::Binary)) _os << " BINARY";
|
||||||
_os << "\n";
|
_os << "\n";
|
||||||
|
|
||||||
|
if (!_opt.check(Options::Binary))
|
||||||
|
_os.precision(_precision);
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
bool result = (_opt.check(Options::Binary) ?
|
bool result = (_opt.check(Options::Binary) ?
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ _OMWriter_()
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
_OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
_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
|
// check whether exporter can give us an OpenMesh BaseKernel
|
||||||
if (!_be.kernel()) return false;
|
if (!_be.kernel()) return false;
|
||||||
@@ -104,7 +104,6 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
|||||||
_opt += Options::Binary; // only binary format supported
|
_opt += Options::Binary; // only binary format supported
|
||||||
|
|
||||||
std::ofstream ofs(_filename.c_str(), std::ios::binary);
|
std::ofstream ofs(_filename.c_str(), std::ios::binary);
|
||||||
ofs.precision(_precision);
|
|
||||||
|
|
||||||
// check if file is open
|
// check if file is open
|
||||||
if (!ofs.is_open())
|
if (!ofs.is_open())
|
||||||
@@ -127,10 +126,9 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool
|
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";
|
// std::clog << "[OMWriter]::write( stream )\n";
|
||||||
_os.precision(_precision);
|
|
||||||
|
|
||||||
// check exporter features
|
// check exporter features
|
||||||
if ( !check( _be, _opt ) )
|
if ( !check( _be, _opt ) )
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_opt.check(Options::Binary))
|
||||||
out.precision(_precision);
|
out.precision(_precision);
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
@@ -153,6 +154,7 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_opt.check(Options::Binary))
|
||||||
_os.precision(_precision);
|
_os.precision(_precision);
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
|
|||||||
@@ -81,36 +81,25 @@ bool
|
|||||||
_STLWriter_::
|
_STLWriter_::
|
||||||
write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
|
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 ?
|
// binary or ascii ?
|
||||||
if (_filename.rfind(".stla") != std::string::npos)
|
if (_filename.rfind(".stla") != std::string::npos)
|
||||||
{
|
{
|
||||||
_opt -= Options::Binary;
|
_opt -= Options::Binary;
|
||||||
return write_stla(_filename, _be, _opt);
|
|
||||||
}
|
}
|
||||||
else if (_filename.rfind(".stlb") != std::string::npos)
|
else if (_filename.rfind(".stlb") != std::string::npos)
|
||||||
{
|
{
|
||||||
_opt += Options::Binary;
|
_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))
|
_opt.check(Options::FaceColor))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!_opt.check(Options::Binary))
|
||||||
_os.precision(_precision);
|
_os.precision(_precision);
|
||||||
|
|
||||||
if (_opt & Options::Binary)
|
if (_opt & Options::Binary)
|
||||||
|
|||||||
Reference in New Issue
Block a user