mirror of https://github.com/CGAL/cgal
Use NP::stream_precision in BGL IO
This commit is contained in:
parent
8ca9f00279
commit
cd6a661b68
|
|
@ -231,6 +231,12 @@ bool read_GOCAD(const std::string& fname, Graph& g) { return read_GOCAD(fname, g
|
||||||
/// \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
/// \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||||
/// must be available in `Graph`.}
|
/// must be available in `Graph`.}
|
||||||
/// \cgalParamNEnd
|
/// \cgalParamNEnd
|
||||||
|
///
|
||||||
|
/// \cgalParamNBegin{stream_precision}
|
||||||
|
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
/// \cgalParamType{int}
|
||||||
|
/// \cgalParamDefault{`6`}
|
||||||
|
/// \cgalParamNEnd
|
||||||
/// \cgalNamedParamsEnd
|
/// \cgalNamedParamsEnd
|
||||||
///
|
///
|
||||||
template <typename Graph,
|
template <typename Graph,
|
||||||
|
|
@ -255,6 +261,9 @@ bool write_GOCAD(std::ostream& os,
|
||||||
if(!os.good())
|
if(!os.good())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||||
|
os << std::setprecision(precision);
|
||||||
|
|
||||||
os << "GOCAD TSurf 1\n"
|
os << "GOCAD TSurf 1\n"
|
||||||
"HEADER {\n"
|
"HEADER {\n"
|
||||||
"name:";
|
"name:";
|
||||||
|
|
@ -368,6 +377,12 @@ bool write_GOCAD(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLA
|
||||||
/// \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
/// \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||||
/// must be available in `Graph`.}
|
/// must be available in `Graph`.}
|
||||||
/// \cgalParamNEnd
|
/// \cgalParamNEnd
|
||||||
|
///
|
||||||
|
/// \cgalParamNBegin{stream_precision}
|
||||||
|
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
/// \cgalParamType{int}
|
||||||
|
/// \cgalParamDefault{`6`}
|
||||||
|
/// \cgalParamNEnd
|
||||||
/// \cgalNamedParamsEnd
|
/// \cgalNamedParamsEnd
|
||||||
///
|
///
|
||||||
template <typename Graph,
|
template <typename Graph,
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,9 @@ public:
|
||||||
if(!m_os.good())
|
if(!m_os.good())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||||
|
m_os << std::setprecision(precision);
|
||||||
|
|
||||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||||
get_const_property_map(CGAL::vertex_point, g));
|
get_const_property_map(CGAL::vertex_point, g));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,12 @@ bool read_OBJ(const std::string& fname, Graph& g) { return read_OBJ(fname, g, pa
|
||||||
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||||
must be available in `Graph`.}
|
must be available in `Graph`.}
|
||||||
\cgalParamNEnd
|
\cgalParamNEnd
|
||||||
|
|
||||||
|
\cgalParamNBegin{stream_precision}
|
||||||
|
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
\cgalParamType{int}
|
||||||
|
\cgalParamDefault{`6`}
|
||||||
|
\cgalParamNEnd
|
||||||
\cgalNamedParamsEnd
|
\cgalNamedParamsEnd
|
||||||
|
|
||||||
\returns `true` if writing was successful.
|
\returns `true` if writing was successful.
|
||||||
|
|
|
||||||
|
|
@ -335,10 +335,10 @@ bool write_PLY(std::ostream& os,
|
||||||
get_const_property_map(boost::vertex_point, g));
|
get_const_property_map(boost::vertex_point, g));
|
||||||
|
|
||||||
if(!os.good())
|
if(!os.good())
|
||||||
{
|
|
||||||
std::cerr << "Error: cannot open file" << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||||
|
os << std::setprecision(precision);
|
||||||
|
|
||||||
// Write header
|
// Write header
|
||||||
os << "ply" << std::endl
|
os << "ply" << std::endl
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,12 @@ bool read_STL(const std::string& fname, Graph& g) { return read_STL(fname, g, pa
|
||||||
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||||
must be available in `Graph`.}
|
must be available in `Graph`.}
|
||||||
\cgalParamNEnd
|
\cgalParamNEnd
|
||||||
|
|
||||||
|
\cgalParamNBegin{stream_precision}
|
||||||
|
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
\cgalParamType{int}
|
||||||
|
\cgalParamDefault{`6`}
|
||||||
|
\cgalParamNEnd
|
||||||
\cgalNamedParamsEnd
|
\cgalNamedParamsEnd
|
||||||
|
|
||||||
\pre The graph must contain only triangle faces.
|
\pre The graph must contain only triangle faces.
|
||||||
|
|
@ -218,6 +224,9 @@ bool write_STL(std::ostream& os,
|
||||||
if(!os.good())
|
if(!os.good())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||||
|
os << std::setprecision(precision);
|
||||||
|
|
||||||
if(get_mode(os) == IO::BINARY)
|
if(get_mode(os) == IO::BINARY)
|
||||||
{
|
{
|
||||||
os << "FileType: Binary ";
|
os << "FileType: Binary ";
|
||||||
|
|
@ -247,7 +256,7 @@ bool write_STL(std::ostream& os,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os << "solid"<<std::endl;;
|
os << "solid" << std::endl;
|
||||||
for(const face_descriptor f : faces(g))
|
for(const face_descriptor f : faces(g))
|
||||||
{
|
{
|
||||||
halfedge_descriptor h = halfedge(f, g);
|
halfedge_descriptor h = halfedge(f, g);
|
||||||
|
|
@ -260,9 +269,9 @@ bool write_STL(std::ostream& os,
|
||||||
os << "vertex " << p << "\n";
|
os << "vertex " << p << "\n";
|
||||||
os << "vertex " << q << "\n";
|
os << "vertex " << q << "\n";
|
||||||
os << "vertex " << r << "\n";
|
os << "vertex " << r << "\n";
|
||||||
os << "endloop\nendfacet"<<std::endl;
|
os << "endloop\nendfacet" << std::endl;
|
||||||
}
|
}
|
||||||
os << "endsolid"<<std::endl;;
|
os << "endsolid" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return os.good();
|
return os.good();
|
||||||
|
|
@ -295,6 +304,12 @@ bool write_STL(std::ostream& os,
|
||||||
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||||
must be available in `Graph`.}
|
must be available in `Graph`.}
|
||||||
\cgalParamNEnd
|
\cgalParamNEnd
|
||||||
|
|
||||||
|
\cgalParamNBegin{stream_precision}
|
||||||
|
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
\cgalParamType{int}
|
||||||
|
\cgalParamDefault{`6`}
|
||||||
|
\cgalParamNEnd
|
||||||
\cgalNamedParamsEnd
|
\cgalNamedParamsEnd
|
||||||
|
|
||||||
\pre The graph must contain only triangle faces.
|
\pre The graph must contain only triangle faces.
|
||||||
|
|
@ -308,6 +323,7 @@ bool write_STL(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||||
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
||||||
if(binary)
|
if(binary)
|
||||||
CGAL::set_mode(os, CGAL::IO::BINARY);
|
CGAL::set_mode(os, CGAL::IO::BINARY);
|
||||||
|
|
||||||
return write_STL(os, g, np);
|
return write_STL(os, g, np);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -404,12 +404,18 @@ void write_polys_points(std::ostream& os,
|
||||||
* must be available in `Graph`.}
|
* must be available in `Graph`.}
|
||||||
* \cgalParamNEnd
|
* \cgalParamNEnd
|
||||||
*
|
*
|
||||||
* \cgalParamNBegin{vertex_index_map}
|
* \cgalParamNBegin{vertex_index_map}
|
||||||
* \cgalParamDescription{a property map associating to each vertex of `graph` a unique index between `0` and `num_vertices(graph) - 1`}
|
* \cgalParamDescription{a property map associating to each vertex of `graph` a unique index between `0` and `num_vertices(graph) - 1`}
|
||||||
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||||
* as key type and `std::size_t` as value type}
|
* as key type and `std::size_t` as value type}
|
||||||
* \cgalParamDefault{no vertex indices in the output}
|
* \cgalParamDefault{no vertex indices in the output}
|
||||||
* \cgalParamNEnd
|
* \cgalParamNEnd
|
||||||
|
*
|
||||||
|
* \cgalParamNBegin{stream_precision}
|
||||||
|
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
* \cgalParamType{int}
|
||||||
|
* \cgalParamDefault{`6`}
|
||||||
|
* \cgalParamNEnd
|
||||||
* \cgalNamedParamsEnd
|
* \cgalNamedParamsEnd
|
||||||
*
|
*
|
||||||
* \pre `g` contains only triangular faces
|
* \pre `g` contains only triangular faces
|
||||||
|
|
@ -422,6 +428,12 @@ bool write_VTP(std::ostream& os,
|
||||||
using parameters::get_parameter;
|
using parameters::get_parameter;
|
||||||
using parameters::choose_parameter;
|
using parameters::choose_parameter;
|
||||||
|
|
||||||
|
if(!os.good())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||||
|
os << std::setprecision(precision);
|
||||||
|
|
||||||
os << "<?xml version=\"1.0\"?>\n"
|
os << "<?xml version=\"1.0\"?>\n"
|
||||||
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";
|
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";
|
||||||
|
|
||||||
|
|
@ -490,12 +502,18 @@ bool write_VTP(std::ostream& os,
|
||||||
* must be available in `Graph`.}
|
* must be available in `Graph`.}
|
||||||
* \cgalParamNEnd
|
* \cgalParamNEnd
|
||||||
*
|
*
|
||||||
* \cgalParamNBegin{vertex_index_map}
|
* \cgalParamNBegin{vertex_index_map}
|
||||||
* \cgalParamDescription{a property map associating to each vertex of `graph` a unique index between `0` and `num_vertices(graph) - 1`}
|
* \cgalParamDescription{a property map associating to each vertex of `graph` a unique index between `0` and `num_vertices(graph) - 1`}
|
||||||
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||||
* as key type and `std::size_t` as value type}
|
* as key type and `std::size_t` as value type}
|
||||||
* \cgalParamDefault{no vertex indices in the output}
|
* \cgalParamDefault{no vertex indices in the output}
|
||||||
* \cgalParamNEnd
|
* \cgalParamNEnd
|
||||||
|
*
|
||||||
|
* \cgalParamNBegin{stream_precision}
|
||||||
|
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
* \cgalParamType{int}
|
||||||
|
* \cgalParamDefault{`6`}
|
||||||
|
* \cgalParamNEnd
|
||||||
* \cgalNamedParamsEnd
|
* \cgalNamedParamsEnd
|
||||||
*
|
*
|
||||||
* \pre `g` contains only triangular faces
|
* \pre `g` contains only triangular faces
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@ namespace CGAL {
|
||||||
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||||
must be available in `Graph`.}
|
must be available in `Graph`.}
|
||||||
\cgalParamNEnd
|
\cgalParamNEnd
|
||||||
|
|
||||||
|
\cgalParamNBegin{stream_precision}
|
||||||
|
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
\cgalParamType{int}
|
||||||
|
\cgalParamDefault{`6`}
|
||||||
|
\cgalParamNEnd
|
||||||
\cgalNamedParamsEnd
|
\cgalNamedParamsEnd
|
||||||
|
|
||||||
\returns `true` if writing was successful.
|
\returns `true` if writing was successful.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@
|
||||||
#define CGAL_BOOST_GRAPH_POLYGON_MESH_IO_H
|
#define CGAL_BOOST_GRAPH_POLYGON_MESH_IO_H
|
||||||
|
|
||||||
#include <CGAL/boost/graph/io.h>
|
#include <CGAL/boost/graph/io.h>
|
||||||
#include <CGAL/IO/polygon_soup_io.h>
|
#include <CGAL/IO/helpers.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
@ -181,6 +184,12 @@ bool read_polygon_mesh(const char* fname, Graph& g)
|
||||||
* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||||
* must be available in `Graph`.}
|
* must be available in `Graph`.}
|
||||||
* \cgalParamNEnd
|
* \cgalParamNEnd
|
||||||
|
*
|
||||||
|
* \cgalParamNBegin{stream_precision}
|
||||||
|
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||||
|
* \cgalParamType{int}
|
||||||
|
* \cgalParamDefault{`6`}
|
||||||
|
* \cgalParamNEnd
|
||||||
* \cgalNamedParamsEnd
|
* \cgalNamedParamsEnd
|
||||||
*
|
*
|
||||||
* Other named parameters may be used according to the file extension, see \ref PkgBGLIOFct for an exhaustive list.
|
* Other named parameters may be used according to the file extension, see \ref PkgBGLIOFct for an exhaustive list.
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,17 @@ typedef std::vector<CGAL::Color> ColorRange;
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#ifdef CGAL_LINKED_WITH_3MF
|
#ifdef CGAL_LINKED_WITH_3MF
|
||||||
const char* file_name=(argc == 2) ? argv[1] : "data/test.3mf";
|
const char* filname = (argc == 2) ? argv[1] : "data/test.3mf";
|
||||||
|
|
||||||
std::vector<PointRange> all_points;
|
std::vector<PointRange> all_points;
|
||||||
std::vector<PolygonRange> all_polygons;
|
std::vector<PolygonRange> all_polygons;
|
||||||
std::vector<ColorRange> all_colors;
|
std::vector<ColorRange> all_colors;
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
std::vector<Mesh> meshes;
|
std::vector<Mesh> meshes;
|
||||||
|
|
||||||
//testing reading functions.
|
//testing reading functions.
|
||||||
int nb_meshes =
|
int nb_meshes = CGAL::read_3mf(filename, meshes);
|
||||||
CGAL::read_3mf(file_name, meshes);
|
|
||||||
if(nb_meshes <0)
|
if(nb_meshes <0)
|
||||||
return 1;
|
return 1;
|
||||||
for(int i = 0; i< nb_meshes; ++i)
|
for(int i = 0; i< nb_meshes; ++i)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue