diff --git a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h index be015411a56..af8d2fc3ea2 100644 --- a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h +++ b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h @@ -253,6 +253,29 @@ public: } }; +template +class Double_coordinate_printer + : public Abstract_property_printer +{ + PropertyMap m_pmap; +public: + Double_coordinate_printer(const PropertyMap& pmap) : m_pmap(pmap) { } + + virtual void print(std::ostream& stream, const Index& index) + { + write(stream, to_double(get(m_pmap, index).x())); + if (get_mode(stream) == CGAL::IO::ASCII) { + stream << " "; + } + write(stream, to_double(get(m_pmap, index).y())); + if (get_mode(stream) == CGAL::IO::ASCII) { + stream << " "; + } + write(stream, to_double(get(m_pmap, index).z())); + } +}; + + template ::value_type> diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 324b78a1af4..fe482b997c7 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -449,14 +449,19 @@ bool fill_simplex_specific_header(std::ostream& os, os << "property float x" << std::endl << "property float y" << std::endl << "property float z" << std::endl; + + printers.push_back(new Property_printer(sm.points())); } else { os << "property double x" << std::endl << "property double y" << std::endl << "property double z" << std::endl; + + + printers.push_back(new Double_coordinate_printer(sm.points())); } - printers.push_back(new Property_printer(sm.points())); + return true; }