From 37089e953db25c20c8490b88904094e5b481b0c9 Mon Sep 17 00:00:00 2001 From: JacksonCampolattaro Date: Tue, 20 Jun 2023 14:57:33 +0200 Subject: [PATCH] Revert `::property_map()` to old behavior; new behavior is moved to `::get_property_map()` --- .../include/CGAL/Surface_mesh/IO/OFF.h | 8 +++--- .../include/CGAL/Surface_mesh/IO/PLY.h | 26 +++++++++---------- .../include/CGAL/Surface_mesh/Surface_mesh.h | 14 ++++++++-- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h index f746b55a2ce..170ffa75bfa 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h @@ -338,7 +338,7 @@ bool write_OFF_with_or_without_fcolors(std::ostream& os, const bool has_fcolors = !(is_default_parameter::value); - auto fcolors = sm.template property_map("f:color"); + auto fcolors = sm.template get_property_map("f:color"); if(!has_fcolors && fcolors && fcolors->size() > 0) return write_OFF_BGL(os, sm, np.face_color_map(fcolors.value())); @@ -361,7 +361,7 @@ bool write_OFF_with_or_without_vtextures(std::ostream& os, const bool has_vtextures = !(is_default_parameter::value); - auto vtextures = sm.template property_map("v:texcoord"); + auto vtextures = sm.template get_property_map("v:texcoord"); if(!has_vtextures && vtextures && vtextures->size() > 0) return write_OFF_with_or_without_fcolors(os, sm, np.vertex_texture_map(vtextures.value())); @@ -382,7 +382,7 @@ bool write_OFF_with_or_without_vcolors(std::ostream& os, const bool has_vcolors = !(is_default_parameter::value); - auto vcolors = sm.template property_map("v:color"); + auto vcolors = sm.template get_property_map("v:color"); if(!has_vcolors && vcolors && vcolors->size() > 0) return write_OFF_with_or_without_vtextures(os, sm, np.vertex_color_map(vcolors.value())); @@ -405,7 +405,7 @@ bool write_OFF_with_or_without_vnormals(std::ostream& os, const bool has_vnormals = !(is_default_parameter::value); - auto vnormals = sm.template property_map("v:normal"); + auto vnormals = sm.template get_property_map("v:normal"); if(!has_vnormals && vnormals && vnormals->size() > 0) return write_OFF_with_or_without_vcolors(os, sm, np.vertex_normal_map(vnormals.value())); diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 4f1f50dde98..8c21027b022 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -460,7 +460,7 @@ bool fill_simplex_specific_header(std::ostream& os, if(prop == "v:normal") { - auto pmap = sm.template property_map(prop); + auto pmap = sm.template get_property_map(prop); if(pmap) { if(std::is_same::value) @@ -482,7 +482,7 @@ bool fill_simplex_specific_header(std::ostream& os, if(prop == "v:color") { - auto pmap = sm.template property_map(prop); + auto pmap = sm.template get_property_map(prop); if(pmap) { os << "property uchar red" << std::endl @@ -514,7 +514,7 @@ bool fill_simplex_specific_header(std::ostream& os, if(prop == "f:color") { - auto pmap = sm.template property_map(prop); + auto pmap = sm.template get_property_map(prop); if(pmap) { os << "property uchar red" << std::endl @@ -700,7 +700,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, std::string name = get_property_raw_name(prop[i], Simplex()); { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property char " << name << std::endl; @@ -709,7 +709,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property uchar " << name << std::endl; @@ -718,7 +718,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property short " << name << std::endl; @@ -727,7 +727,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property ushort " << name << std::endl; @@ -736,7 +736,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property int " << name << std::endl; @@ -745,7 +745,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property uint " << name << std::endl; @@ -754,7 +754,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property int " << name << std::endl; @@ -763,7 +763,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property uint " << name << std::endl; @@ -772,7 +772,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property float " << name << std::endl; @@ -781,7 +781,7 @@ void fill_header(std::ostream& os, const Surface_mesh& sm, } } { - auto pmap = sm.template property_map(prop[i]); + auto pmap = sm.template get_property_map(prop[i]); if(pmap) { os << "property double " << name << std::endl; diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index 5cea7e1a744..01a6e121e20 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -1880,11 +1880,21 @@ public: return {{array.get()}, created}; } + /// returns a property map named `name` with key type `I` and value type `T`, + /// and a Boolean that is `true` if the property was created. + template + std::pair, bool> + property_map(const std::string& name) const { + auto [array, created] = + const_cast*>(this)->get_property_container().template get_or_add_property(name); + return {{array.get()}, created}; + } + /// returns a property map named `name` with key type `I` and value type `T`, /// if such a property map exists template std::optional> - property_map(const std::string& name) { + get_property_map(const std::string& name) { auto maybe_property_map = get_property_container().template get_property_if_exists(name); if (!maybe_property_map) return {}; else return {{maybe_property_map.value()}}; @@ -1892,7 +1902,7 @@ public: template std::optional> - property_map(const std::string& name) const { + get_property_map(const std::string& name) const { auto maybe_property_map = const_cast*>(this)->get_property_container().template get_property_if_exists(name); if (!maybe_property_map) return {}; else return {{maybe_property_map.value()}};