diff --git a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h index 2e8bbad3a89..9a7b7afd914 100644 --- a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h +++ b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h @@ -298,6 +298,42 @@ public: } }; + +template ::value_type, + typename ElementType = typename VectorType::value_type> +class Simple_property_vector_printer + : public Abstract_property_printer +{ + PropertyMap m_pmap; +public: + Simple_property_vector_printer(const PropertyMap& pmap) : m_pmap(pmap) { } + + virtual void print(std::ostream& stream, const Index& index) + { + const VectorType& vec = get(m_pmap, index); + if(get_mode(stream) == CGAL::IO::ASCII) + { + stream << vec.size(); + for(const ElementType& v : vec) + { + stream << " " << v; + } + } + else + { + unsigned char size = (unsigned char)(vec.size()); + stream.write(reinterpret_cast(&size), sizeof(size)); + for(const ElementType& v : vec) + { + ElementType t = ElementType(v); + stream.write(reinterpret_cast(&t), sizeof(t)); + } + } + } +}; + } // namespace internal } // namespace IO } // namespace CGAL diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 1e59286bd01..e0afe1bd5e6 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -590,6 +590,17 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, typedef typename SMesh::template Property_map Uint64_map; typedef typename SMesh::template Property_map Float_map; typedef typename SMesh::template Property_map Double_map; + // vector types for "property list"s + typedef typename SMesh::template Property_map> vector_Int8_map; + typedef typename SMesh::template Property_map> vector_Uint8_map; + typedef typename SMesh::template Property_map> vector_Int16_map; + typedef typename SMesh::template Property_map> vector_Uint16_map; + typedef typename SMesh::template Property_map> vector_Int32_map; + typedef typename SMesh::template Property_map> vector_Uint32_map; + typedef typename SMesh::template Property_map> vector_Int64_map; + typedef typename SMesh::template Property_map> vector_Uint64_map; + typedef typename SMesh::template Property_map> vector_Float_map; + typedef typename SMesh::template Property_map> vector_Double_map; std::vector prop = sm.template properties(); @@ -702,6 +713,106 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, continue; } } + { + vector_Int8_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar char " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Uint8_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar uchar " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Int16_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar short " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Uint16_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar ushort " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Int32_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar int " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Uint32_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar uint " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Int64_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar int " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Uint64_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar uint " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Float_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar float " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } + { + vector_Double_map pmap; + boost::tie(pmap, okay) = sm.template property_map>(prop[i]); + if(okay) + { + os << "property list uchar double " << name << std::endl; + printers.push_back(new internal::Simple_property_vector_printer(pmap)); + continue; + } + } } }