From 64acf21a1b3249757daccb9609955c47760475ad Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 15 Nov 2024 14:12:05 +0100 Subject: [PATCH 1/3] read and write doubles instead of floats --- BGL/include/CGAL/boost/graph/IO/OM.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/IO/OM.h b/BGL/include/CGAL/boost/graph/IO/OM.h index 9d393022a030..1040652eff44 100644 --- a/BGL/include/CGAL/boost/graph/IO/OM.h +++ b/BGL/include/CGAL/boost/graph/IO/OM.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -34,7 +35,7 @@ namespace internal { template bool read_OM(const std::string& fname, Graph& g, VPM vpm, VFeaturePM vfpm, EFeaturePM efpm) { - typedef OpenMesh::PolyMesh_ArrayKernelT<> OMesh; + typedef OpenMesh::PolyMesh_ArrayKernelT OMesh; typedef typename boost::graph_traits::vertex_descriptor om_vertex_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor om_halfedge_descriptor; @@ -75,7 +76,7 @@ bool read_OM(const std::string& fname, Graph& g, VPM vpm, VFeaturePM vfpm, EFeat template bool write_OM(std::string fname, const Graph& g, VPM vpm, VFeaturePM vfpm, EFeaturePM efpm) { - typedef OpenMesh::PolyMesh_ArrayKernelT<> OMesh; + typedef OpenMesh::PolyMesh_ArrayKernelT OMesh; typedef typename boost::graph_traits::vertex_descriptor om_vertex_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor om_halfedge_descriptor; @@ -108,7 +109,7 @@ bool write_OM(std::string fname, const Graph& g, VPM vpm, VFeaturePM vfpm, EFeat omesh.status(omv).set_feature(isfeature); } - return OpenMesh::IO::write_mesh(omesh, fname, OpenMesh::IO::Options::Status); + return OpenMesh::IO::write_mesh(omesh, fname, OpenMesh::IO::Options::Status, 18); } } // end of internal namespace From 7c156fa6cd9b6a977223241a1c97294da0b027d1 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 15 Nov 2024 14:59:21 +0100 Subject: [PATCH 2/3] use NP stream_precision --- BGL/include/CGAL/boost/graph/IO/OM.h | 14 +++++++++++--- Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp | 6 ++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/IO/OM.h b/BGL/include/CGAL/boost/graph/IO/OM.h index 1040652eff44..9c582267ae19 100644 --- a/BGL/include/CGAL/boost/graph/IO/OM.h +++ b/BGL/include/CGAL/boost/graph/IO/OM.h @@ -74,7 +74,8 @@ bool read_OM(const std::string& fname, Graph& g, VPM vpm, VFeaturePM vfpm, EFeat } template -bool write_OM(std::string fname, const Graph& g, VPM vpm, VFeaturePM vfpm, EFeaturePM efpm) +bool write_OM(std::string fname, const Graph& g, VPM vpm, VFeaturePM vfpm, EFeaturePM efpm, + const std::streamsize precision) { typedef OpenMesh::PolyMesh_ArrayKernelT OMesh; typedef typename boost::graph_traits::vertex_descriptor om_vertex_descriptor; @@ -109,7 +110,7 @@ bool write_OM(std::string fname, const Graph& g, VPM vpm, VFeaturePM vfpm, EFeat omesh.status(omv).set_feature(isfeature); } - return OpenMesh::IO::write_mesh(omesh, fname, OpenMesh::IO::Options::Status, 18); + return OpenMesh::IO::write_mesh(omesh, fname, OpenMesh::IO::Options::Status, precision); } } // end of internal namespace @@ -209,6 +210,11 @@ bool read_OM(const std::string& fname, \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and `bool` as value type.} \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{the precision of the stream `os`} + \cgalParamNEnd \cgalNamedParamsEnd \returns `true` if writing was successful, `false` otherwise. @@ -229,7 +235,9 @@ bool write_OM(const std::string& fname, CGAL::Constant_property_map(false)); auto vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, g)); - return internal::write_OM(fname, g, vpm, vfpm, efpm); + std::streamsize precision = choose_parameter(get_parameter(np, internal_np::stream_precision), + 18); + return internal::write_OM(fname, g, vpm, vfpm, efpm, precision); } diff --git a/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp b/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp index 286fdd5bc01d..6b08185ab4d2 100644 --- a/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp +++ b/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp @@ -180,12 +180,14 @@ save(QFileInfo fileinfo, QList& items) res = CGAL::IO::write_OM((const char*)fileinfo.filePath().toUtf8() , *sm_item->face_graph() , CGAL::parameters::vertex_is_constrained_map(selection_item->constrained_vertices_pmap()) - .edge_is_constrained_map(selection_item->constrained_edges_pmap())); + .edge_is_constrained_map(selection_item->constrained_edges_pmap()) + .stream_precision(18)); } else { res = CGAL::IO::write_OM((const char*)fileinfo.filePath().toUtf8() - , *sm_item->face_graph()); + , *sm_item->face_graph() + , CGAL::parameters::stream_precision(18)); } if (res) From 7632a01f6ce822786021ee24c41d1102c5629417 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 15 Nov 2024 16:22:07 +0100 Subject: [PATCH 3/3] 18->17 Co-authored-by: Sebastien Loriot --- Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp b/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp index 6b08185ab4d2..ab81338bf068 100644 --- a/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp +++ b/Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp @@ -181,13 +181,13 @@ save(QFileInfo fileinfo, QList& items) , *sm_item->face_graph() , CGAL::parameters::vertex_is_constrained_map(selection_item->constrained_vertices_pmap()) .edge_is_constrained_map(selection_item->constrained_edges_pmap()) - .stream_precision(18)); + .stream_precision(17)); } else { res = CGAL::IO::write_OM((const char*)fileinfo.filePath().toUtf8() , *sm_item->face_graph() - , CGAL::parameters::stream_precision(18)); + , CGAL::parameters::stream_precision(17)); } if (res)