Commit f1a9b3a8 authored by Jan Möbius's avatar Jan Möbius
Browse files

Avoid std::endl in the writers to avoid flushing the output stream on every...

Avoid std::endl in the writers to avoid flushing the output stream on every line. (Thanks to Roman Zoller for the hint). 



git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1209 fdac6126-5c0c-442c-9429-916003d36597
parent a1617b1b
...@@ -194,20 +194,20 @@ namespace OMFormat { ...@@ -194,20 +194,20 @@ namespace OMFormat {
std::ostream& operator << ( std::ostream& _os, const Chunk::Header& _c ) std::ostream& operator << ( std::ostream& _os, const Chunk::Header& _c )
{ {
_os << "Chunk Header : 0x" << std::setw(4) _os << "Chunk Header : 0x" << std::setw(4)
<< std::hex << (*(uint16*)(&_c)) << std::dec << std::endl; << std::hex << (*(uint16*)(&_c)) << std::dec << '\n';
_os << "entity = " _os << "entity = "
<< as_string(Chunk::Entity(_c.entity_)) << std::endl; << as_string(Chunk::Entity(_c.entity_)) << '\n';
_os << "type = " _os << "type = "
<< as_string(Chunk::Type(_c.type_)); << as_string(Chunk::Type(_c.type_));
if ( Chunk::Type(_c.type_)!=Chunk::Type_Custom) if ( Chunk::Type(_c.type_)!=Chunk::Type_Custom)
{ {
_os << std::endl _os << '\n'
<< "signed = " << "signed = "
<< _c.signed_ << std::endl; << _c.signed_ << '\n';
_os << "float = " _os << "float = "
<< _c.float_ << std::endl; << _c.float_ << '\n';
_os << "dim = " _os << "dim = "
<< as_string(Chunk::Dim(_c.dim_)) << std::endl; << as_string(Chunk::Dim(_c.dim_)) << '\n';
_os << "bits = " _os << "bits = "
<< (_c.float_ << (_c.float_
? as_string(Chunk::Float_Size(_c.bits_)) ? as_string(Chunk::Float_Size(_c.bits_))
...@@ -226,8 +226,8 @@ namespace OMFormat { ...@@ -226,8 +226,8 @@ namespace OMFormat {
<< "version = 0x" << std::hex << (uint16)_h.version_ << std::dec << "version = 0x" << std::hex << (uint16)_h.version_ << std::dec
<< " (" << major_version(_h.version_) << " (" << major_version(_h.version_)
<< "." << minor_version(_h.version_) << ")\n" << "." << minor_version(_h.version_) << ")\n"
<< "#V = " << _h.n_vertices_ << std::endl << "#V = " << _h.n_vertices_ << '\n'
<< "#F = " << _h.n_faces_ << std::endl << "#F = " << _h.n_faces_ << '\n'
<< "#E = " << _h.n_edges_; << "#E = " << _h.n_edges_;
return _os; return _os;
} }
......
...@@ -177,18 +177,18 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const ...@@ -177,18 +177,18 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const
//write the materials //write the materials
if ( _opt.color_has_alpha() ) if ( _opt.color_has_alpha() )
for (size_t i=0; i < materialA_.size(); i++){ for (size_t i=0; i < materialA_.size(); i++){
_out << "newmtl " << "mat" << i << std::endl; _out << "newmtl " << "mat" << i << '\n';
_out << "Ka 0.5000 0.5000 0.5000" << std::endl; _out << "Ka 0.5000 0.5000 0.5000" << '\n';
_out << "Kd " << materialA_[i][0] << materialA_[i][1] << materialA_[i][2] << std::endl;; _out << "Kd " << materialA_[i][0] << materialA_[i][1] << materialA_[i][2] << '\n';;
_out << "Tr " << materialA_[i][3] << std::endl; _out << "Tr " << materialA_[i][3] << '\n';
_out << "illum 1" << std::endl; _out << "illum 1" << '\n';
} }
else else
for (size_t i=0; i < material_.size(); i++){ for (size_t i=0; i < material_.size(); i++){
_out << "newmtl " << "mat" << i << std::endl; _out << "newmtl " << "mat" << i << '\n';
_out << "Ka 0.5000 0.5000 0.5000" << std::endl; _out << "Ka 0.5000 0.5000 0.5000" << '\n';
_out << "Kd " << material_[i][0] << material_[i][1] << material_[i][2] << std::endl;; _out << "Kd " << material_[i][0] << material_[i][1] << material_[i][2] << '\n';;
_out << "illum 1" << std::endl; _out << "illum 1" << '\n';
} }
return true; return true;
...@@ -246,11 +246,11 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec ...@@ -246,11 +246,11 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
// header // header
_out << "# " << _be.n_vertices() << " vertices, "; _out << "# " << _be.n_vertices() << " vertices, ";
_out << _be.n_faces() << " faces" << std::endl; _out << _be.n_faces() << " faces" << '\n';
// material file // material file
if (useMatrial && _opt.check(Options::FaceColor) ) if (useMatrial && _opt.check(Options::FaceColor) )
_out << "mtllib " << objName_ << ".mat" << std::endl; _out << "mtllib " << objName_ << ".mat" << '\n';
// vertex data (point, normals, texcoords) // vertex data (point, normals, texcoords)
for (i=0, nV=_be.n_vertices(); i<nV; ++i) for (i=0, nV=_be.n_vertices(); i<nV; ++i)
...@@ -260,13 +260,13 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec ...@@ -260,13 +260,13 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
n = _be.normal(vh); n = _be.normal(vh);
t = _be.texcoord(vh); t = _be.texcoord(vh);
_out << "v " << v[0] <<" "<< v[1] <<" "<< v[2] << std::endl; _out << "v " << v[0] <<" "<< v[1] <<" "<< v[2] << '\n';
if (_opt.check(Options::VertexNormal)) if (_opt.check(Options::VertexNormal))
_out << "vn " << n[0] <<" "<< n[1] <<" "<< n[2] << std::endl; _out << "vn " << n[0] <<" "<< n[1] <<" "<< n[2] << '\n';
if (_opt.check(Options::VertexTexCoord)) if (_opt.check(Options::VertexTexCoord))
_out << "vt " << t[0] <<" "<< t[1] << std::endl; _out << "vt " << t[0] <<" "<< t[1] << '\n';
} }
size_t lastMat = std::numeric_limits<std::size_t>::max(); size_t lastMat = std::numeric_limits<std::size_t>::max();
...@@ -294,7 +294,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec ...@@ -294,7 +294,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
// if we are ina a new material block, specify in the file which material to use // if we are ina a new material block, specify in the file which material to use
if(lastMat != material) { if(lastMat != material) {
_out << "usemtl mat" << material << std::endl; _out << "usemtl mat" << material << '\n';
lastMat = material; lastMat = material;
} }
} }
...@@ -327,7 +327,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec ...@@ -327,7 +327,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
} }
} }
_out << std::endl; _out << '\n';
} }
material_.clear(); material_.clear();
......
...@@ -242,7 +242,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const ...@@ -242,7 +242,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << " " << t[0] << " " << t[1]; _out << " " << t[0] << " " << t[1];
} }
_out << "\n"; _out << '\n';
} }
...@@ -281,7 +281,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const ...@@ -281,7 +281,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
} }
} }
} }
_out << "\n"; _out << '\n';
} }
} }
else else
...@@ -318,7 +318,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const ...@@ -318,7 +318,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
} }
} }
_out << "\n"; _out << '\n';
} }
} }
......
...@@ -171,7 +171,7 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci ...@@ -171,7 +171,7 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _opt) const { void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _opt) const {
//writing header //writing header
_out << "ply" << std::endl; _out << "ply" << '\n';
if (_opt.is_binary()) { if (_opt.is_binary()) {
_out << "format "; _out << "format ";
...@@ -179,48 +179,48 @@ void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _ ...@@ -179,48 +179,48 @@ void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _
_out << "binary_big_endian "; _out << "binary_big_endian ";
else else
_out << "binary_little_endian "; _out << "binary_little_endian ";
_out << "1.0" << std::endl; _out << "1.0" << '\n';
} else } else
_out << "format ascii 1.0" << std::endl; _out << "format ascii 1.0" << '\n';
_out << "element vertex " << _be.n_vertices() << std::endl; _out << "element vertex " << _be.n_vertices() << '\n';
_out << "property float x" << std::endl; _out << "property float x" << '\n';
_out << "property float y" << std::endl; _out << "property float y" << '\n';
_out << "property float z" << std::endl; _out << "property float z" << '\n';
if ( _opt.vertex_has_normal() ){ if ( _opt.vertex_has_normal() ){
_out << "property float nx" << std::endl; _out << "property float nx" << '\n';
_out << "property float ny" << std::endl; _out << "property float ny" << '\n';
_out << "property float nz" << std::endl; _out << "property float nz" << '\n';
} }
if ( _opt.vertex_has_texcoord() ){ if ( _opt.vertex_has_texcoord() ){
_out << "property float u" << std::endl; _out << "property float u" << '\n';
_out << "property float v" << std::endl; _out << "property float v" << '\n';
} }
if ( _opt.vertex_has_color() ){ if ( _opt.vertex_has_color() ){
if ( _opt.color_is_float() ) { if ( _opt.color_is_float() ) {
_out << "property float red" << std::endl; _out << "property float red" << '\n';
_out << "property float green" << std::endl; _out << "property float green" << '\n';
_out << "property float blue" << std::endl; _out << "property float blue" << '\n';
if ( _opt.color_has_alpha() ) if ( _opt.color_has_alpha() )
_out << "property float alpha" << std::endl; _out << "property float alpha" << '\n';
} else { } else {
_out << "property uchar red" << std::endl; _out << "property uchar red" << '\n';
_out << "property uchar green" << std::endl; _out << "property uchar green" << '\n';
_out << "property uchar blue" << std::endl; _out << "property uchar blue" << '\n';
if ( _opt.color_has_alpha() ) if ( _opt.color_has_alpha() )
_out << "property uchar alpha" << std::endl; _out << "property uchar alpha" << '\n';
} }
} }
_out << "element face " << _be.n_faces() << std::endl; _out << "element face " << _be.n_faces() << '\n';
_out << "property list uchar int vertex_indices" << std::endl; _out << "property list uchar int vertex_indices" << '\n';
_out << "end_header" << std::endl; _out << "end_header" << '\n';
} }
......
...@@ -81,11 +81,11 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std ...@@ -81,11 +81,11 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std
size_t nv = _be.n_vertices(); size_t nv = _be.n_vertices();
for (size_t i = 0; i < nv; ++i) { for (size_t i = 0; i < nv; ++i) {
Vec3f v = _be.point(VertexHandle(int(i))); Vec3f v = _be.point(VertexHandle(int(i)));
_out << v[0] << ' ' << v[1] << ' ' << v[2] << std::endl; _out << v[0] << ' ' << v[1] << ' ' << v[2] << '\n';
} }
// faces // faces
_out << "POLYGONS " << nf << ' ' << polygon_table_size << std::endl; _out << "POLYGONS " << nf << ' ' << polygon_table_size << '\n';
for (size_t i = 0; i < nf; ++i) { for (size_t i = 0; i < nf; ++i) {
_be.get_vhandles(FaceHandle(int(i)), vhandles); _be.get_vhandles(FaceHandle(int(i)), vhandles);
...@@ -93,7 +93,7 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std ...@@ -93,7 +93,7 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std
for (size_t j = 0; j < vhandles.size(); ++j) { for (size_t j = 0; j < vhandles.size(); ++j) {
_out << " " << vhandles[j].idx(); _out << " " << vhandles[j].idx();
} }
_out << std::endl; _out << '\n';
} }
return true; return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment