Merge branch 'property-maps' into orthtree-generalization

This commit is contained in:
JacksonCampolattaro 2023-06-21 15:37:39 +02:00
commit 0a3bb33367
3 changed files with 29 additions and 19 deletions

View File

@ -338,7 +338,7 @@ bool write_OFF_with_or_without_fcolors(std::ostream& os,
const bool has_fcolors = !(is_default_parameter<CGAL_NP_CLASS, internal_np::face_color_map_t>::value);
auto fcolors = sm.template property_map<Face_index, CGAL::IO::Color>("f:color");
auto fcolors = sm.template get_property_map<Face_index, CGAL::IO::Color>("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<CGAL_NP_CLASS, internal_np::vertex_texture_map_t>::value);
auto vtextures = sm.template property_map<Vertex_index, Texture>("v:texcoord");
auto vtextures = sm.template get_property_map<Vertex_index, Texture>("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<CGAL_NP_CLASS, internal_np::vertex_color_map_t>::value);
auto vcolors = sm.template property_map<Vertex_index, CGAL::IO::Color>("v:color");
auto vcolors = sm.template get_property_map<Vertex_index, CGAL::IO::Color>("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<CGAL_NP_CLASS, internal_np::vertex_normal_map_t>::value);
auto vnormals = sm.template property_map<Vertex_index, Normal>("v:normal");
auto vnormals = sm.template get_property_map<Vertex_index, Normal>("v:normal");
if(!has_vnormals && vnormals && vnormals->size() > 0)
return write_OFF_with_or_without_vcolors(os, sm, np.vertex_normal_map(vnormals.value()));

View File

@ -460,7 +460,7 @@ bool fill_simplex_specific_header(std::ostream& os,
if(prop == "v:normal")
{
auto pmap = sm.template property_map<VIndex, Vector>(prop);
auto pmap = sm.template get_property_map<VIndex, Vector>(prop);
if(pmap)
{
if(std::is_same<FT, float>::value)
@ -482,7 +482,7 @@ bool fill_simplex_specific_header(std::ostream& os,
if(prop == "v:color")
{
auto pmap = sm.template property_map<VIndex, Color>(prop);
auto pmap = sm.template get_property_map<VIndex, Color>(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<FIndex, Color>(prop);
auto pmap = sm.template get_property_map<FIndex, Color>(prop);
if(pmap)
{
os << "property uchar red" << std::endl
@ -700,7 +700,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
std::string name = get_property_raw_name<Point>(prop[i], Simplex());
{
auto pmap = sm.template property_map<Simplex,boost::int8_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::int8_t>(prop[i]);
if(pmap)
{
os << "property char " << name << std::endl;
@ -709,7 +709,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,boost::uint8_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::uint8_t>(prop[i]);
if(pmap)
{
os << "property uchar " << name << std::endl;
@ -718,7 +718,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,boost::int16_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::int16_t>(prop[i]);
if(pmap)
{
os << "property short " << name << std::endl;
@ -727,7 +727,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,boost::uint16_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::uint16_t>(prop[i]);
if(pmap)
{
os << "property ushort " << name << std::endl;
@ -736,7 +736,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,boost::int32_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::int32_t>(prop[i]);
if(pmap)
{
os << "property int " << name << std::endl;
@ -745,7 +745,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,boost::uint32_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::uint32_t>(prop[i]);
if(pmap)
{
os << "property uint " << name << std::endl;
@ -754,7 +754,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,boost::int64_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::int64_t>(prop[i]);
if(pmap)
{
os << "property int " << name << std::endl;
@ -763,7 +763,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,boost::uint64_t>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,boost::uint64_t>(prop[i]);
if(pmap)
{
os << "property uint " << name << std::endl;
@ -772,7 +772,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,float>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,float>(prop[i]);
if(pmap)
{
os << "property float " << name << std::endl;
@ -781,7 +781,7 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
}
}
{
auto pmap = sm.template property_map<Simplex,double>(prop[i]);
auto pmap = sm.template get_property_map<Simplex,double>(prop[i]);
if(pmap)
{
os << "property double " << name << std::endl;

View File

@ -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 <class I, class T>
std::pair<Property_map<I, T>, bool>
property_map(const std::string& name) const {
auto [array, created] =
const_cast<Surface_mesh<P>*>(this)->get_property_container<I>().template get_or_add_property<T>(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 <class I, class T>
std::optional<Property_map<I, T>>
property_map(const std::string& name) {
get_property_map(const std::string& name) {
auto maybe_property_map = get_property_container<I>().template get_property_if_exists<T>(name);
if (!maybe_property_map) return {};
else return {{maybe_property_map.value()}};
@ -1892,7 +1902,7 @@ public:
template <class I, class T>
std::optional<Property_map<I, T>>
property_map(const std::string& name) const {
get_property_map(const std::string& name) const {
auto maybe_property_map = const_cast<Surface_mesh<P>*>(this)->get_property_container<I>().template get_property_if_exists<T>(name);
if (!maybe_property_map) return {};
else return {{maybe_property_map.value()}};