Add precision support to Geomview streams

This commit is contained in:
Mael Rouxel-Labbé 2020-10-14 15:32:27 +02:00
parent bc3b6eaeb7
commit 0583a4862e
17 changed files with 23 additions and 16 deletions

View File

@ -304,7 +304,7 @@ bool write_GOCAD(std::ostream& os,
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
os << "GOCAD TSurf 1\n"
"HEADER {\n"

View File

@ -118,7 +118,7 @@ public:
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
m_os << std::setprecision(precision);
m_os.precision(precision);
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_const_property_map(CGAL::vertex_point, g));

View File

@ -362,7 +362,7 @@ bool write_PLY(std::ostream& os,
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
// Write header
os << "ply" << std::endl

View File

@ -251,7 +251,7 @@ bool write_STL(std::ostream& os,
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
if(get_mode(os) == IO::BINARY)
{

View File

@ -440,7 +440,7 @@ bool write_VTP(std::ostream& os,
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
os << "<?xml version=\"1.0\"?>\n"
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";

View File

@ -49,6 +49,9 @@ public:
~Geomview_stream();
void precision(const int p) { prec = p; }
int precision() const { return prec; }
Geomview_stream &operator<<(const Color &c);
Geomview_stream &operator<<(const std::string & s);
Geomview_stream &operator<<(int i);
@ -218,6 +221,7 @@ private:
double radius; // radius of vertices
int in, out; // file descriptors for input and output pipes
int pid; // the geomview process identification
int prec; // precision of the (ASCII) stream
std::map<std::string, int> id; // used to get a unique ID per type.
};

View File

@ -43,7 +43,7 @@ Geomview_stream::Geomview_stream(const Bbox_3 &bbox,
: bb(bbox), vertex_color(black()), edge_color(black()), face_color(black()),
wired_flag(false), echo_flag(true), raw_flag(false),
trace_flag(false), binary_flag(false),
line_width(1)
line_width(1),prec(6)
{
setup_geomview(machine, login);
frame(bbox);
@ -242,6 +242,7 @@ Geomview_stream::operator<<(int i)
} else {
// transform the int in a character sequence and put whitespace around
std::ostringstream str;
str.precision(prec);
str << i << ' ' << std::ends;
*this << str.str().c_str();
}
@ -264,6 +265,7 @@ Geomview_stream::operator<<(unsigned int i)
} else {
// transform the int in a character sequence and put whitespace around
std::ostringstream str;
str.precision(prec);
str << i << ' ' << std::ends;
*this << str.str().c_str();
}
@ -299,6 +301,7 @@ Geomview_stream::operator<<(double d)
} else {
// 'copy' the float in a string and append a blank
std::ostringstream str;
str.precision(prec);
str << f << ' ' << std::ends;
*this << str.str().c_str();
}

View File

@ -496,7 +496,7 @@ bool write_PLY(std::ostream& os,
}
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
os << "ply" << std::endl
<< ((get_mode(os) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl

View File

@ -67,7 +67,7 @@ bool write_OFF_PSP(std::ostream& os,
}
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
// Write header
os << "NOFF" << std::endl;

View File

@ -213,7 +213,7 @@ bool write_PLY(std::ostream& os,
}
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
if (has_normals)
return write_PLY_with_properties(os, points,

View File

@ -68,7 +68,7 @@ bool write_XYZ_PSP(std::ostream& os,
}
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
// Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)

View File

@ -300,7 +300,7 @@ bool write_GOCAD(std::ostream& os,
set_ascii_mode(os); // GOCAD is ASCII only
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
os << "GOCAD TSurf 1\n"
"HEADER {\n"

View File

@ -50,7 +50,7 @@ public:
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
m_os << std::setprecision(precision);
m_os.precision(precision);
m_writer.write_header(m_os, points.size(), 0, polygons.size());
for(std::size_t i=0, end=points.size(); i<end; ++i)

View File

@ -468,7 +468,7 @@ bool write_PLY(std::ostream& out,
return false;
const int precision = parameters::choose_parameter(parameters::get_parameter(np, internal_np::stream_precision), 6);
out << std::setprecision(precision);
out.precision(precision);
// Write header
out << "ply" << std::endl

View File

@ -306,7 +306,7 @@ bool write_STL(std::ostream& os,
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
if(get_mode(os) == IO::BINARY)
{

View File

@ -396,7 +396,7 @@ bool write_VTP(std::ostream& os,
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
os << "<?xml version=\"1.0\"?>\n"
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";

View File

@ -922,7 +922,7 @@ bool write_PLY(std::ostream& os,
return false;
const int precision = parameters::choose_parameter(parameters::get_parameter(np, internal_np::stream_precision), 6);
os << std::setprecision(precision);
os.precision(precision);
os << "ply" << std::endl
<< ((get_mode(os) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl