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`
|
||||
/// must be available in `Graph`.}
|
||||
/// \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
|
||||
///
|
||||
template <typename Graph,
|
||||
|
|
@ -255,6 +261,9 @@ bool write_GOCAD(std::ostream& os,
|
|||
if(!os.good())
|
||||
return false;
|
||||
|
||||
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||
os << std::setprecision(precision);
|
||||
|
||||
os << "GOCAD TSurf 1\n"
|
||||
"HEADER {\n"
|
||||
"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`
|
||||
/// must be available in `Graph`.}
|
||||
/// \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
|
||||
///
|
||||
template <typename Graph,
|
||||
|
|
|
|||
|
|
@ -117,6 +117,9 @@ public:
|
|||
if(!m_os.good())
|
||||
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),
|
||||
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`
|
||||
must be available in `Graph`.}
|
||||
\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
|
||||
|
||||
\returns `true` if writing was successful.
|
||||
|
|
|
|||
|
|
@ -335,10 +335,10 @@ bool write_PLY(std::ostream& os,
|
|||
get_const_property_map(boost::vertex_point, g));
|
||||
|
||||
if(!os.good())
|
||||
{
|
||||
std::cerr << "Error: cannot open file" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||
os << std::setprecision(precision);
|
||||
|
||||
// Write header
|
||||
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`
|
||||
must be available in `Graph`.}
|
||||
\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
|
||||
|
||||
\pre The graph must contain only triangle faces.
|
||||
|
|
@ -218,6 +224,9 @@ bool write_STL(std::ostream& os,
|
|||
if(!os.good())
|
||||
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)
|
||||
{
|
||||
os << "FileType: Binary ";
|
||||
|
|
@ -247,7 +256,7 @@ bool write_STL(std::ostream& os,
|
|||
}
|
||||
else
|
||||
{
|
||||
os << "solid"<<std::endl;;
|
||||
os << "solid" << std::endl;
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
halfedge_descriptor h = halfedge(f, g);
|
||||
|
|
@ -260,9 +269,9 @@ bool write_STL(std::ostream& os,
|
|||
os << "vertex " << p << "\n";
|
||||
os << "vertex " << q << "\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();
|
||||
|
|
@ -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`
|
||||
must be available in `Graph`.}
|
||||
\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
|
||||
|
||||
\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);
|
||||
if(binary)
|
||||
CGAL::set_mode(os, CGAL::IO::BINARY);
|
||||
|
||||
return write_STL(os, g, np);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -410,6 +410,12 @@ void write_polys_points(std::ostream& os,
|
|||
* as key type and `std::size_t` as value type}
|
||||
* \cgalParamDefault{no vertex indices in the output}
|
||||
* \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
|
||||
*
|
||||
* \pre `g` contains only triangular faces
|
||||
|
|
@ -422,6 +428,12 @@ bool write_VTP(std::ostream& os,
|
|||
using parameters::get_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"
|
||||
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";
|
||||
|
||||
|
|
@ -496,6 +508,12 @@ bool write_VTP(std::ostream& os,
|
|||
* as key type and `std::size_t` as value type}
|
||||
* \cgalParamDefault{no vertex indices in the output}
|
||||
* \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
|
||||
*
|
||||
* \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`
|
||||
must be available in `Graph`.}
|
||||
\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
|
||||
|
||||
\returns `true` if writing was successful.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@
|
|||
#define CGAL_BOOST_GRAPH_POLYGON_MESH_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 {
|
||||
|
||||
|
|
@ -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`
|
||||
* must be available in `Graph`.}
|
||||
* \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
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
#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<PolygonRange> all_polygons;
|
||||
std::vector<ColorRange> all_colors;
|
||||
std::vector<std::string> names;
|
||||
std::vector<Mesh> meshes;
|
||||
|
||||
//testing reading functions.
|
||||
int nb_meshes =
|
||||
CGAL::read_3mf(file_name, meshes);
|
||||
int nb_meshes = CGAL::read_3mf(filename, meshes);
|
||||
|
||||
if(nb_meshes <0)
|
||||
return 1;
|
||||
for(int i = 0; i< nb_meshes; ++i)
|
||||
|
|
|
|||
Loading…
Reference in New Issue