From 32078f1c23915a5e3a9b85c8dfe08ce5841a7d45 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 26 Jan 2024 14:35:26 +0000 Subject: [PATCH] Point_set_3: property uchar refers to the range 0..255 not the char type --- Point_set_3/test/Point_set_3/CMakeLists.txt | 1 + Point_set_3/test/Point_set_3/issue7996.cpp | 59 +++++++++++++++++++ .../include/CGAL/IO/PLY/PLY_writer.h | 2 +- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Point_set_3/test/Point_set_3/issue7996.cpp diff --git a/Point_set_3/test/Point_set_3/CMakeLists.txt b/Point_set_3/test/Point_set_3/CMakeLists.txt index 4daea00a56b..879f204e069 100644 --- a/Point_set_3/test/Point_set_3/CMakeLists.txt +++ b/Point_set_3/test/Point_set_3/CMakeLists.txt @@ -10,6 +10,7 @@ find_package(CGAL REQUIRED) create_single_source_cgal_program("point_set_test.cpp") create_single_source_cgal_program("point_set_test_join.cpp") create_single_source_cgal_program("test_deprecated_io_ps.cpp") +create_single_source_cgal_program("issue7996.cpp") #Use LAS #disable if MSVC 2017 diff --git a/Point_set_3/test/Point_set_3/issue7996.cpp b/Point_set_3/test/Point_set_3/issue7996.cpp new file mode 100644 index 00000000000..17e568fb07d --- /dev/null +++ b/Point_set_3/test/Point_set_3/issue7996.cpp @@ -0,0 +1,59 @@ +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point; +typedef CGAL::Point_set_3 Point_set; + + +int main() +{ + Point_set ps; + ps.insert(Point(0,0,0)); + ps.insert(Point(1,1,1)); + + Point_set::Property_map + red = ps.add_property_map("red" , 0).first, + green = ps.add_property_map("green", 0).first, + blue = ps.add_property_map("blue" , 0).first; + + + int i = 1; + for (Point_set::iterator it = ps.begin(); it != ps.end(); ++ it){ + put(red, *it, static_cast(11 * i++)); + put(green, *it, static_cast(11 * i++)); + put(blue, *it, static_cast(11 * i++)); + } + + { + std::ofstream out("ascii.ply"); + out << ps; + out.close(); + + Point_set ps2; + std::ifstream in("ascii.ply"); + in >> ps2; + + std::cout << ps2 << std::endl; + } + + { + std::ofstream out("binary.ply", std::ios::binary); + CGAL::set_binary_mode(out); + out << ps; + out.close(); + + Point_set ps2; + std::ifstream in("binary.ply", std::ios::binary); + CGAL::set_binary_mode(in); + in >> ps2; + + std::cout << ps2 << std::endl; + } + + + return 0; +} diff --git a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h index be015411a56..126c12ab773 100644 --- a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h +++ b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h @@ -266,7 +266,7 @@ public: virtual void print(std::ostream& stream, const Index& index) { if(get_mode(stream) == CGAL::IO::ASCII) - stream << get(m_pmap, index); + stream << no_char_character(get(m_pmap, index)); else { Type t = Type(get(m_pmap, index));