From 36b66946b81daa0f6c94880a1d4383bf6bfdbac6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 30 Sep 2025 08:30:55 +0100 Subject: [PATCH] after Mael's review --- BGL/include/CGAL/boost/graph/IO/PLY.h | 23 ++++++------------- .../include/CGAL/Surface_mesh/IO/PLY.h | 10 ++++---- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/IO/PLY.h b/BGL/include/CGAL/boost/graph/IO/PLY.h index c069ef7e96e..6d16eaee686 100644 --- a/BGL/include/CGAL/boost/graph/IO/PLY.h +++ b/BGL/include/CGAL/boost/graph/IO/PLY.h @@ -161,7 +161,6 @@ bool read_PLY(std::istream& is, } - /*! \ingroup PkgBGLIoFuncsPLY @@ -333,10 +332,6 @@ bool read_PLY(const std::string& fname, \cgalParamNEnd \cgalNamedParamsEnd -\note The point and vector types of the point and normal property map must be `double`or `float` - in order to respect the specification of the PLY file format. - A `Cartesian_converter_property_map` can be used to convert the points and vectors on the fly. - \returns `true` if writing was successful, `false` otherwise. */ template @@ -456,13 +451,13 @@ bool write_PLY(std::ostream& os, const Point_3& p = get(vpm, vd); internal::output_properties(os, &p, make_ply_point_writer (Identity_property_map())); if constexpr (!parameters::is_default_parameter::value) - { - auto vnm = get_parameter(np, internal_np::vertex_normal_map); - typedef decltype(vnm) Normal_map; - typedef typename Normal_map::value_type Vector_3; - Vector_3 vec = get(vnm,vd); - internal::output_properties(os, &vec, make_ply_normal_writer (Identity_property_map())); - } + { + auto vnm = get_parameter(np, internal_np::vertex_normal_map); + typedef decltype(vnm) Normal_map; + typedef typename Normal_map::value_type Vector_3; + Vector_3 vec = get(vnm,vd); + internal::output_properties(os, &vec, make_ply_normal_writer (Identity_property_map())); + } if(has_vcolor) { const CGAL::IO::Color& c = get(vcm, vd); @@ -576,10 +571,6 @@ bool write_PLY(std::ostream& os, const Graph& g, const CGAL_NP_CLASS& np = param \cgalParamNEnd \cgalNamedParamsEnd -\note The point and vector types of the point and normal property map must be `double`or `float` - in order to respect the specification of the PLY file format. - A `Cartesian_converter_property_map` can be used to convert the points and vectors on the fly. - \returns `true` if writing was successful, `false` otherwise. */ template diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 24808879542..1b8cccd58f4 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -475,15 +475,15 @@ bool fill_simplex_specific_header(std::ostream& os, if constexpr (std::is_same::value) { os << "property float nx" << std::endl - << "property float ny" << std::endl - << "property float nz" << std::endl; + << "property float ny" << std::endl + << "property float nz" << std::endl; printers.push_back(new Property_printer(vnm)); } else { os << "property double nx" << std::endl - << "property double ny" << std::endl - << "property double nz" << std::endl; + << "property double ny" << std::endl + << "property double nz" << std::endl; auto fvnm = CGAL::make_cartesian_converter_property_map(vnm); printers.push_back(new Property_printer(fvnm)); } @@ -989,7 +989,6 @@ namespace IO { /// /// \returns `true` if writing was successful, `false` otherwise. - template bool write_PLY(std::ostream& os, @@ -1002,6 +1001,7 @@ bool write_PLY(std::ostream& os, typedef typename SMesh::Face_index FIndex; typedef typename SMesh::Edge_index EIndex; typedef typename SMesh::Halfedge_index HIndex; + if(!os.good()) return false;