diff --git a/src/OpenMesh/Core/IO/writer/BaseWriter.hh b/src/OpenMesh/Core/IO/writer/BaseWriter.hh
index 5c2afe99..cb78e8cb 100644
--- a/src/OpenMesh/Core/IO/writer/BaseWriter.hh
+++ b/src/OpenMesh/Core/IO/writer/BaseWriter.hh
@@ -99,12 +99,14 @@ public:
/// Write to file _filename. Data source specified by BaseExporter _be.
virtual bool write(const std::string& _filename,
BaseExporter& _be,
- Options _opt) const = 0;
+ Options _opt,
+ std::streamsize _precision = 6) const = 0;
/// Write to std::ostream _os. Data source specified by BaseExporter _be.
virtual bool write(std::ostream& _os,
BaseExporter& _be,
- Options _opt) const = 0;
+ Options _opt,
+ std::streamsize _precision = 6) const = 0;
/// Returns expected size of file if binary format is supported else 0.
virtual size_t binary_size(BaseExporter&, Options) const { return 0; }
diff --git a/src/OpenMesh/Core/IO/writer/OBJWriter.cc b/src/OpenMesh/Core/IO/writer/OBJWriter.cc
index 39b29d54..805e48a5 100644
--- a/src/OpenMesh/Core/IO/writer/OBJWriter.cc
+++ b/src/OpenMesh/Core/IO/writer/OBJWriter.cc
@@ -4,10 +4,10 @@
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
- *---------------------------------------------------------------------------*
+ *---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
- * OpenMesh is free software: you can redistribute it and/or modify *
+ * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, *
* see . *
* *
-\*===========================================================================*/
+\*===========================================================================*/
/*===========================================================================*\
- * *
+ * *
* $Revision$ *
* $Date$ *
* *
@@ -80,7 +80,7 @@ _OBJWriter_::_OBJWriter_() { IOManager().register_module(this); }
bool
_OBJWriter_::
-write(const std::string& _filename, BaseExporter& _be, Options _opt) const
+write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
std::fstream out(_filename.c_str(), std::ios_base::out );
@@ -91,6 +91,8 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
return false;
}
+ out.precision(_precision);
+
{
#if defined(WIN32)
std::string::size_type dot = _filename.find_last_of("\\/");
@@ -196,7 +198,7 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const
bool
_OBJWriter_::
-write(std::ostream& _out, BaseExporter& _be, Options _opt) const
+write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
unsigned int i, j, nV, nF, idx;
Vec3f v, n;
@@ -209,6 +211,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt) const
omlog() << "[OBJWriter] : write file\n";
+ _out.precision(_precision);
// check exporter features
if (!check( _be, _opt))
@@ -297,18 +300,18 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt) const
for (j=0; j< vhandles.size(); ++j)
{
-
+
// Write vertex index
idx = vhandles[j].idx() + 1;
_out << " " << idx;
// write separator
_out << "/" ;
-
+
// write vertex texture coordinate index
if (_opt.check(Options::VertexTexCoord))
_out << idx;
-
+
// write separator
_out << "/" ;
diff --git a/src/OpenMesh/Core/IO/writer/OBJWriter.hh b/src/OpenMesh/Core/IO/writer/OBJWriter.hh
index 8eafe1d5..7090b239 100644
--- a/src/OpenMesh/Core/IO/writer/OBJWriter.hh
+++ b/src/OpenMesh/Core/IO/writer/OBJWriter.hh
@@ -4,10 +4,10 @@
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
- *---------------------------------------------------------------------------*
+ *---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
- * OpenMesh is free software: you can redistribute it and/or modify *
+ * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, *
* see . *
* *
-\*===========================================================================*/
+\*===========================================================================*/
/*===========================================================================*\
- * *
+ * *
* $Revision$ *
* $Date$ *
* *
@@ -73,7 +73,7 @@ namespace IO {
//=== IMPLEMENTATION ==========================================================
-/**
+/**
This class defines the OBJ writer. This class is further singleton'ed
by SingletonT to OBJWriter.
*/
@@ -89,9 +89,9 @@ public:
std::string get_description() const { return "Alias/Wavefront"; }
std::string get_extensions() const { return "obj"; }
- bool write(const std::string&, BaseExporter&, Options) const;
-
- bool write(std::ostream&, BaseExporter&, Options) const;
+ bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
+
+ bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
size_t binary_size(BaseExporter&, Options) const { return 0; }
diff --git a/src/OpenMesh/Core/IO/writer/OFFWriter.cc b/src/OpenMesh/Core/IO/writer/OFFWriter.cc
index 3ea2cdd6..79254392 100644
--- a/src/OpenMesh/Core/IO/writer/OFFWriter.cc
+++ b/src/OpenMesh/Core/IO/writer/OFFWriter.cc
@@ -4,10 +4,10 @@
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
- *---------------------------------------------------------------------------*
+ *---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
- * OpenMesh is free software: you can redistribute it and/or modify *
+ * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, *
* see . *
* *
-\*===========================================================================*/
+\*===========================================================================*/
/*===========================================================================*\
- * *
+ * *
* $Revision$ *
* $Date$ *
* *
@@ -78,7 +78,7 @@ _OFFWriter_::_OFFWriter_() { IOManager().register_module(this); }
bool
_OFFWriter_::
-write(const std::string& _filename, BaseExporter& _be, Options _opt) const
+write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
// check exporter features
if ( !check( _be, _opt ) )
@@ -88,7 +88,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
// check writer features
if ( _opt.check(Options::FaceNormal) ) // not supported by format
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) );
@@ -100,6 +100,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
return false;
}
+ out.precision(_precision);
// write header line
if (_opt.check(Options::VertexTexCoord)) out << "ST";
@@ -126,7 +127,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
bool
_OFFWriter_::
-write(std::ostream& _os, BaseExporter& _be, Options _opt) const
+write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
// check exporter features
if ( !check( _be, _opt ) )
@@ -136,8 +137,8 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt) const
// check writer features
if ( _opt.check(Options::FaceNormal) ) // not supported by format
return false;
-
-
+
+
if (!_os.good())
{
omerr() << "[OFFWriter] : cannot write to stream "
@@ -145,6 +146,7 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt) const
return false;
}
+ _os.precision(_precision);
// write header line
if (_opt.check(Options::VertexTexCoord)) _os << "ST";
@@ -195,16 +197,16 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
{
vh = VertexHandle(i);
v = _be.point(vh);
-
+
//Vertex
_out << v[0] << " " << v[1] << " " << v[2];
-
+
// VertexNormal
if ( _opt.vertex_has_normal() ) {
n = _be.normal(vh);
_out << " " << n[0] << " " << n[1] << " " << n[2];
}
-
+
// VertexColor
if ( _opt.vertex_has_color() ) {
//with alpha
@@ -217,26 +219,26 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << " " << c[0] << " " << c[1] << " " << c[2];
}
}
-
+
// TexCoord
if (_opt.vertex_has_texcoord() ) {
t = _be.texcoord(vh);
_out << " " << t[0] << " " << t[1];
}
-
+
_out << "\n";
-
+
}
-
+
// faces (indices starting at 0)
if (_be.is_triangle_mesh())
{
for (i=0, nF=_be.n_faces(); i. *
* *
-\*===========================================================================*/
+\*===========================================================================*/
/*===========================================================================*\
- * *
+ * *
* $Revision$ *
* $Date$ *
* *
@@ -74,8 +74,8 @@ namespace IO {
//=== IMPLEMENTATION ==========================================================
-/**
- Implementation of the OFF format writer. This class is singleton'ed by
+/**
+ Implementation of the OFF format writer. This class is singleton'ed by
SingletonT to OFFWriter.
By passing Options to the write function you can manipulate the writing behavoir.
@@ -100,9 +100,9 @@ public:
std::string get_description() const { return "no description"; }
std::string get_extensions() const { return "off"; }
- bool write(const std::string&, BaseExporter&, Options) const;
-
- bool write(std::ostream&, BaseExporter&, Options) const;
+ bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
+
+ bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
size_t binary_size(BaseExporter& _be, Options _opt) const;
diff --git a/src/OpenMesh/Core/IO/writer/OMWriter.cc b/src/OpenMesh/Core/IO/writer/OMWriter.cc
index f11d91b6..b1cfdd62 100644
--- a/src/OpenMesh/Core/IO/writer/OMWriter.cc
+++ b/src/OpenMesh/Core/IO/writer/OMWriter.cc
@@ -4,10 +4,10 @@
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
- *---------------------------------------------------------------------------*
+ *---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
- * OpenMesh is free software: you can redistribute it and/or modify *
+ * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, *
* see . *
* *
-\*===========================================================================*/
+\*===========================================================================*/
/*===========================================================================*\
- * *
+ * *
* $Revision$ *
* $Date$ *
* *
@@ -83,27 +83,28 @@ const OMFormat::uint8 _OMWriter_::version_ = OMFormat::mk_version(1,2);
_OMWriter_::
-_OMWriter_()
-{
- IOManager().register_module(this);
+_OMWriter_()
+{
+ IOManager().register_module(this);
}
bool
_OMWriter_::write(const std::string& _filename, BaseExporter& _be,
- Options _opt) const
+ Options _opt, std::streamsize _precision) const
{
// check whether exporter can give us an OpenMesh BaseKernel
if (!_be.kernel()) return false;
- // check for om extension in filename, we can only handle OM
- if (_filename.rfind(".om") == std::string::npos)
+ // check for om extension in filename, we can only handle OM
+ if (_filename.rfind(".om") == std::string::npos)
return false;
_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())
@@ -114,7 +115,7 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
// call stream save method
bool rc = write(ofs, _be, _opt);
-
+
// close filestream
ofs.close();
@@ -126,9 +127,10 @@ _OMWriter_::write(const std::string& _filename, BaseExporter& _be,
//-----------------------------------------------------------------------------
bool
-_OMWriter_::write(std::ostream& _os, BaseExporter& _be, Options _opt) 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 ) )
@@ -187,7 +189,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// -------------------- write header
OMFormat::Header header;
-
+
header.magic_[0] = 'O';
header.magic_[1] = 'M';
header.mesh_ = _be.is_triangle_mesh() ? 'T' : 'P';
@@ -195,16 +197,16 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
header.n_vertices_ = _be.n_vertices();
header.n_faces_ = _be.n_faces();
header.n_edges_ = _be.n_edges();
-
+
bytes += store( _os, header, swap );
-
+
// ---------------------------------------- write chunks
-
+
OMFormat::Chunk::Header chunk_header;
-
-
+
+
// -------------------- write vertex data
-
+
// ---------- write vertex position
if (_be.n_vertices())
{
@@ -217,7 +219,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.float_ = OMFormat::is_float(v[0]);
chunk_header.dim_ = OMFormat::dim(v);
chunk_header.bits_ = OMFormat::bits(v[0]);
-
+
bytes += store( _os, chunk_header, swap );
for (i=0, nV=_be.n_vertices(); istore(_os, swap);
}
@@ -382,15 +384,15 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// -------------------- write custom properties
-
+
BaseKernel::const_prop_iterator prop;
-
+
for (prop = _be.kernel()->vprops_begin();
prop != _be.kernel()->vprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
- bytes += store_binary_custom_chunk(_os, **prop,
+ bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Vertex, swap );
}
for (prop = _be.kernel()->fprops_begin();
@@ -398,7 +400,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
- bytes += store_binary_custom_chunk(_os, **prop,
+ bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Face, swap );
}
for (prop = _be.kernel()->eprops_begin();
@@ -406,7 +408,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
- bytes += store_binary_custom_chunk(_os, **prop,
+ bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Edge, swap );
}
for (prop = _be.kernel()->hprops_begin();
@@ -414,7 +416,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
- bytes += store_binary_custom_chunk(_os, **prop,
+ bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Halfedge, swap );
}
for (prop = _be.kernel()->mprops_begin();
@@ -422,7 +424,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
- bytes += store_binary_custom_chunk(_os, **prop,
+ bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Mesh, swap );
}
@@ -433,7 +435,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
// ----------------------------------------------------------------------------
-size_t _OMWriter_::store_binary_custom_chunk(std::ostream& _os,
+size_t _OMWriter_::store_binary_custom_chunk(std::ostream& _os,
const BaseProperty& _bp,
OMFormat::Chunk::Entity _entity,
bool _swap) const
@@ -441,7 +443,7 @@ size_t _OMWriter_::store_binary_custom_chunk(std::ostream& _os,
omlog() << "Custom Property " << OMFormat::as_string(_entity) << " property ["
<< _bp.name() << "]" << std::endl;
- // Don't store if
+ // Don't store if
// 1. it is not persistent
// 2. it's name is empty
if ( !_bp.persistent() || _bp.name().empty() )
@@ -467,7 +469,7 @@ size_t _OMWriter_::store_binary_custom_chunk(std::ostream& _os,
// write custom chunk
- // 1. chunk header
+ // 1. chunk header
bytes += store( _os, chdr, _swap );
// 2. property name
diff --git a/src/OpenMesh/Core/IO/writer/OMWriter.hh b/src/OpenMesh/Core/IO/writer/OMWriter.hh
index 0f922e83..f91c4d59 100644
--- a/src/OpenMesh/Core/IO/writer/OMWriter.hh
+++ b/src/OpenMesh/Core/IO/writer/OMWriter.hh
@@ -4,10 +4,10 @@
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
- *---------------------------------------------------------------------------*
+ *---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
- * OpenMesh is free software: you can redistribute it and/or modify *
+ * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, *
* see . *
* *
-\*===========================================================================*/
+\*===========================================================================*/
/*===========================================================================*\
- * *
+ * *
* $Revision$ *
* $Date$ *
* *
@@ -82,8 +82,8 @@ class BaseExporter;
//=== IMPLEMENTATION ==========================================================
-/**
- * Implementation of the OM format writer. This class is singleton'ed by
+/**
+ * Implementation of the OM format writer. This class is singleton'ed by
* SingletonT to OMWriter.
*/
class OPENMESHDLLEXPORT _OMWriter_ : public BaseWriter
@@ -98,12 +98,12 @@ public:
std::string get_description() const
{ return "OpenMesh Format"; }
-
+
std::string get_extensions() const
{ return "om"; }
- bool write(std::ostream&, BaseExporter&, Options) const;
-
+ bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
+
size_t binary_size(BaseExporter& _be, Options _opt) const;
@@ -114,10 +114,10 @@ protected:
static const OMFormat::uchar magic_[3];
static const OMFormat::uint8 version_;
- bool write(const std::string&, BaseExporter&, Options) const;
+ bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write_binary(std::ostream&, BaseExporter&, Options) const;
-
+
size_t store_binary_custom_chunk( std::ostream&, const BaseProperty&,
OMFormat::Chunk::Entity, bool) const;
diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.cc b/src/OpenMesh/Core/IO/writer/PLYWriter.cc
index a728f4ba..3a21e4f3 100644
--- a/src/OpenMesh/Core/IO/writer/PLYWriter.cc
+++ b/src/OpenMesh/Core/IO/writer/PLYWriter.cc
@@ -78,7 +78,7 @@ _PLYWriter_::_PLYWriter_() { IOManager().register_module(this); }
bool
_PLYWriter_::
-write(const std::string& _filename, BaseExporter& _be, Options _opt) const
+write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
// check exporter features
if ( !check( _be, _opt ) )
@@ -93,7 +93,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
_opt.unset(Options::FaceNormal);
omerr() << "[PLYWriter] : Warning: Face normals are not supported and thus not exported! " << std::endl;
}
-
+
if ( _opt.check(Options::FaceColor) ) {
// Face normals are not supported
// Uncheck these options and output message that
@@ -115,6 +115,8 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
return false;
}
+ out.precision(_precision);
+
// write to file
bool result = (_opt.check(Options::Binary) ?
write_binary(out, _be, _opt) :
@@ -130,7 +132,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
bool
_PLYWriter_::
-write(std::ostream& _os, BaseExporter& _be, Options _opt) const
+write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
// check exporter features
if ( !check( _be, _opt ) )
@@ -143,7 +145,7 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt) const
options_ = _opt;
-
+
if (!_os.good())
{
omerr() << "[PLYWriter] : cannot write to stream "
@@ -151,6 +153,8 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt) const
return false;
}
+ _os.precision(_precision);
+
// write to file
bool result = (_opt.check(Options::Binary) ?
write_binary(_os, _be, _opt) :
@@ -396,7 +400,7 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
_out << "property float32 x" << std::endl;
_out << "property float32 y" << std::endl;
_out << "property float32 z" << std::endl;
-
+
if ( _opt.vertex_has_normal() ){
_out << "property float32 nx" << std::endl;
_out << "property float32 ny" << std::endl;
diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.hh b/src/OpenMesh/Core/IO/writer/PLYWriter.hh
index 6183cc2c..c0fd4f00 100644
--- a/src/OpenMesh/Core/IO/writer/PLYWriter.hh
+++ b/src/OpenMesh/Core/IO/writer/PLYWriter.hh
@@ -4,10 +4,10 @@
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
- *---------------------------------------------------------------------------*
+ *---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
- * OpenMesh is free software: you can redistribute it and/or modify *
+ * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, *
* see . *
* *
-\*===========================================================================*/
+\*===========================================================================*/
/*===========================================================================*\
- * *
+ * *
* $Revision$ *
* $Date$ *
* *
@@ -95,10 +95,10 @@ public:
std::string get_description() const { return "PLY polygon file format"; }
std::string get_extensions() const { return "ply"; }
- bool write(const std::string&, BaseExporter&, Options) const;
+ bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
+
+ bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
- bool write(std::ostream&, BaseExporter&, Options) const;
-
size_t binary_size(BaseExporter& _be, Options _opt) const;
enum ValueType {
diff --git a/src/OpenMesh/Core/IO/writer/STLWriter.cc b/src/OpenMesh/Core/IO/writer/STLWriter.cc
index cf136197..556c5af9 100644
--- a/src/OpenMesh/Core/IO/writer/STLWriter.cc
+++ b/src/OpenMesh/Core/IO/writer/STLWriter.cc
@@ -79,7 +79,7 @@ _STLWriter_::_STLWriter_() { IOManager().register_module(this); }
bool
_STLWriter_::
-write(const std::string& _filename, BaseExporter& _be, Options _opt) const
+write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
// check exporter features
if (!check(_be, _opt)) return false;
@@ -118,7 +118,7 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt) const
bool
_STLWriter_::
-write(std::ostream& _os, BaseExporter& _be, Options _opt) const
+write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
// check exporter features
if (!check(_be, _opt)) return false;
@@ -129,6 +129,8 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt) const
_opt.check(Options::FaceColor))
return false;
+ _os.precision(_precision);
+
if (_opt & Options::Binary)
return write_stlb(_os, _be, _opt);
else
@@ -209,7 +211,7 @@ write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
bool
_STLWriter_::
-write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */) const
+write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const
{
omlog() << "[STLWriter] : write ascii file\n";
@@ -217,7 +219,7 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */) const
Vec3f a, b, c, n;
std::vector vhandles;
FaceHandle fh;
- std::streamsize prec = _out.precision();
+ _out.precision(_precision);
// header
@@ -239,7 +241,6 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */) const
_be.normal(fh) :
((c-b) % (a-b)).normalize());
- _out.precision(prec);
_out << "facet normal " << n[0] << " " << n[1] << " " << n[2] << "\nouter loop\n";
_out.precision(10);
_out << "vertex " << a[0] << " " << a[1] << " " << a[2] << "\n";
@@ -340,7 +341,7 @@ write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
bool
_STLWriter_::
-write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */) const
+write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const
{
omlog() << "[STLWriter] : write binary file\n";
@@ -349,6 +350,7 @@ write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */) const
Vec3f a, b, c, n;
std::vector vhandles;
FaceHandle fh;
+ _out.precision(_precision);
// write header
diff --git a/src/OpenMesh/Core/IO/writer/STLWriter.hh b/src/OpenMesh/Core/IO/writer/STLWriter.hh
index a5647159..98c87af4 100644
--- a/src/OpenMesh/Core/IO/writer/STLWriter.hh
+++ b/src/OpenMesh/Core/IO/writer/STLWriter.hh
@@ -93,17 +93,17 @@ public:
std::string get_description() const { return "Stereolithography Format"; }
std::string get_extensions() const { return "stla stlb"; }
- bool write(const std::string&, BaseExporter&, Options) const;
+ bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
- bool write(std::ostream&, BaseExporter&, Options) const;
+ bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
size_t binary_size(BaseExporter&, Options) const;
private:
bool write_stla(const std::string&, BaseExporter&, Options) const;
- bool write_stla(std::ostream&, BaseExporter&, Options) const;
+ bool write_stla(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write_stlb(const std::string&, BaseExporter&, Options) const;
- bool write_stlb(std::ostream&, BaseExporter&, Options) const;
+ bool write_stlb(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
};