From f1a9b3a87124a4a2dfaa1d6fc89a81d5dc1cf44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 19 Jan 2015 17:37:47 +0000 Subject: [PATCH] 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 --- src/OpenMesh/Core/IO/OMFormat.cc | 16 ++++----- src/OpenMesh/Core/IO/writer/OBJWriter.cc | 32 ++++++++--------- src/OpenMesh/Core/IO/writer/OFFWriter.cc | 6 ++-- src/OpenMesh/Core/IO/writer/PLYWriter.cc | 46 ++++++++++++------------ src/OpenMesh/Core/IO/writer/VTKWriter.cc | 6 ++-- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/OpenMesh/Core/IO/OMFormat.cc b/src/OpenMesh/Core/IO/OMFormat.cc index b728c3b1..eddd62af 100644 --- a/src/OpenMesh/Core/IO/OMFormat.cc +++ b/src/OpenMesh/Core/IO/OMFormat.cc @@ -194,20 +194,20 @@ namespace OMFormat { std::ostream& operator << ( std::ostream& _os, const Chunk::Header& _c ) { _os << "Chunk Header : 0x" << std::setw(4) - << std::hex << (*(uint16*)(&_c)) << std::dec << std::endl; + << std::hex << (*(uint16*)(&_c)) << std::dec << '\n'; _os << "entity = " - << as_string(Chunk::Entity(_c.entity_)) << std::endl; + << as_string(Chunk::Entity(_c.entity_)) << '\n'; _os << "type = " << as_string(Chunk::Type(_c.type_)); if ( Chunk::Type(_c.type_)!=Chunk::Type_Custom) { - _os << std::endl + _os << '\n' << "signed = " - << _c.signed_ << std::endl; + << _c.signed_ << '\n'; _os << "float = " - << _c.float_ << std::endl; + << _c.float_ << '\n'; _os << "dim = " - << as_string(Chunk::Dim(_c.dim_)) << std::endl; + << as_string(Chunk::Dim(_c.dim_)) << '\n'; _os << "bits = " << (_c.float_ ? as_string(Chunk::Float_Size(_c.bits_)) @@ -226,8 +226,8 @@ namespace OMFormat { << "version = 0x" << std::hex << (uint16)_h.version_ << std::dec << " (" << major_version(_h.version_) << "." << minor_version(_h.version_) << ")\n" - << "#V = " << _h.n_vertices_ << std::endl - << "#F = " << _h.n_faces_ << std::endl + << "#V = " << _h.n_vertices_ << '\n' + << "#F = " << _h.n_faces_ << '\n' << "#E = " << _h.n_edges_; return _os; } diff --git a/src/OpenMesh/Core/IO/writer/OBJWriter.cc b/src/OpenMesh/Core/IO/writer/OBJWriter.cc index eb71f32d..15269ed8 100644 --- a/src/OpenMesh/Core/IO/writer/OBJWriter.cc +++ b/src/OpenMesh/Core/IO/writer/OBJWriter.cc @@ -177,18 +177,18 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const //write the materials if ( _opt.color_has_alpha() ) for (size_t i=0; i < materialA_.size(); i++){ - _out << "newmtl " << "mat" << i << std::endl; - _out << "Ka 0.5000 0.5000 0.5000" << std::endl; - _out << "Kd " << materialA_[i][0] << materialA_[i][1] << materialA_[i][2] << std::endl;; - _out << "Tr " << materialA_[i][3] << std::endl; - _out << "illum 1" << std::endl; + _out << "newmtl " << "mat" << i << '\n'; + _out << "Ka 0.5000 0.5000 0.5000" << '\n'; + _out << "Kd " << materialA_[i][0] << materialA_[i][1] << materialA_[i][2] << '\n';; + _out << "Tr " << materialA_[i][3] << '\n'; + _out << "illum 1" << '\n'; } else for (size_t i=0; i < material_.size(); i++){ - _out << "newmtl " << "mat" << i << std::endl; - _out << "Ka 0.5000 0.5000 0.5000" << std::endl; - _out << "Kd " << material_[i][0] << material_[i][1] << material_[i][2] << std::endl;; - _out << "illum 1" << std::endl; + _out << "newmtl " << "mat" << i << '\n'; + _out << "Ka 0.5000 0.5000 0.5000" << '\n'; + _out << "Kd " << material_[i][0] << material_[i][1] << material_[i][2] << '\n';; + _out << "illum 1" << '\n'; } return true; @@ -246,11 +246,11 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec // header _out << "# " << _be.n_vertices() << " vertices, "; - _out << _be.n_faces() << " faces" << std::endl; + _out << _be.n_faces() << " faces" << '\n'; // material file if (useMatrial && _opt.check(Options::FaceColor) ) - _out << "mtllib " << objName_ << ".mat" << std::endl; + _out << "mtllib " << objName_ << ".mat" << '\n'; // vertex data (point, normals, texcoords) for (i=0, nV=_be.n_vertices(); i::max(); @@ -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(lastMat != material) { - _out << "usemtl mat" << material << std::endl; + _out << "usemtl mat" << material << '\n'; lastMat = material; } } @@ -327,7 +327,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec } } - _out << std::endl; + _out << '\n'; } material_.clear(); diff --git a/src/OpenMesh/Core/IO/writer/OFFWriter.cc b/src/OpenMesh/Core/IO/writer/OFFWriter.cc index 6855d68b..3271e47f 100644 --- a/src/OpenMesh/Core/IO/writer/OFFWriter.cc +++ b/src/OpenMesh/Core/IO/writer/OFFWriter.cc @@ -242,7 +242,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const _out << " " << t[0] << " " << t[1]; } - _out << "\n"; + _out << '\n'; } @@ -281,7 +281,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const } } } - _out << "\n"; + _out << '\n'; } } else @@ -318,7 +318,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const } } - _out << "\n"; + _out << '\n'; } } diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.cc b/src/OpenMesh/Core/IO/writer/PLYWriter.cc index 521a5cd8..d0c257e0 100644 --- a/src/OpenMesh/Core/IO/writer/PLYWriter.cc +++ b/src/OpenMesh/Core/IO/writer/PLYWriter.cc @@ -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 { //writing header - _out << "ply" << std::endl; + _out << "ply" << '\n'; if (_opt.is_binary()) { _out << "format "; @@ -179,48 +179,48 @@ void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _ _out << "binary_big_endian "; else _out << "binary_little_endian "; - _out << "1.0" << std::endl; + _out << "1.0" << '\n'; } 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 y" << std::endl; - _out << "property float z" << std::endl; + _out << "property float x" << '\n'; + _out << "property float y" << '\n'; + _out << "property float z" << '\n'; if ( _opt.vertex_has_normal() ){ - _out << "property float nx" << std::endl; - _out << "property float ny" << std::endl; - _out << "property float nz" << std::endl; + _out << "property float nx" << '\n'; + _out << "property float ny" << '\n'; + _out << "property float nz" << '\n'; } if ( _opt.vertex_has_texcoord() ){ - _out << "property float u" << std::endl; - _out << "property float v" << std::endl; + _out << "property float u" << '\n'; + _out << "property float v" << '\n'; } if ( _opt.vertex_has_color() ){ if ( _opt.color_is_float() ) { - _out << "property float red" << std::endl; - _out << "property float green" << std::endl; - _out << "property float blue" << std::endl; + _out << "property float red" << '\n'; + _out << "property float green" << '\n'; + _out << "property float blue" << '\n'; if ( _opt.color_has_alpha() ) - _out << "property float alpha" << std::endl; + _out << "property float alpha" << '\n'; } else { - _out << "property uchar red" << std::endl; - _out << "property uchar green" << std::endl; - _out << "property uchar blue" << std::endl; + _out << "property uchar red" << '\n'; + _out << "property uchar green" << '\n'; + _out << "property uchar blue" << '\n'; 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 << "property list uchar int vertex_indices" << std::endl; - _out << "end_header" << std::endl; + _out << "element face " << _be.n_faces() << '\n'; + _out << "property list uchar int vertex_indices" << '\n'; + _out << "end_header" << '\n'; } diff --git a/src/OpenMesh/Core/IO/writer/VTKWriter.cc b/src/OpenMesh/Core/IO/writer/VTKWriter.cc index 7ec0661d..18d7e059 100644 --- a/src/OpenMesh/Core/IO/writer/VTKWriter.cc +++ b/src/OpenMesh/Core/IO/writer/VTKWriter.cc @@ -81,11 +81,11 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std size_t nv = _be.n_vertices(); for (size_t i = 0; i < nv; ++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 - _out << "POLYGONS " << nf << ' ' << polygon_table_size << std::endl; + _out << "POLYGONS " << nf << ' ' << polygon_table_size << '\n'; for (size_t i = 0; i < nf; ++i) { _be.get_vhandles(FaceHandle(int(i)), vhandles); @@ -93,7 +93,7 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std for (size_t j = 0; j < vhandles.size(); ++j) { _out << " " << vhandles[j].idx(); } - _out << std::endl; + _out << '\n'; } return true;