Merge pull request #5369 from sgiraudot/Point_set_3-Fix_broken_properties_and_types-GF

[Point Set 3] Fix broken properties and types
This commit is contained in:
Laurent Rineau 2021-02-18 15:18:06 +01:00
commit adf74f81b7
2 changed files with 9 additions and 3 deletions

View File

@ -17,6 +17,7 @@
#include <stack> #include <stack>
#include <typeindex>
#include <CGAL/Surface_mesh/Properties.h> #include <CGAL/Surface_mesh/Properties.h>
@ -933,15 +934,15 @@ public:
/*! /*!
\brief Returns a vector of pairs that describe properties and associated types. \brief Returns a vector of pairs that describe properties and associated types.
*/ */
std::vector<std::pair<std::string, std::type_info> > properties_and_types() const std::vector<std::pair<std::string, std::type_index> > properties_and_types() const
{ {
std::vector<std::string> prop = m_base.properties(); std::vector<std::string> prop = m_base.properties();
prop.erase (prop.begin()); // remove "index" prop.erase (prop.begin()); // remove "index"
prop.erase (prop.begin()); // remove "point" prop.erase (prop.begin()); // remove "point"
std::vector<std::pair<std::string, std::type_info> > out; out.reserve (prop.size()); std::vector<std::pair<std::string, std::type_index> > out; out.reserve (prop.size());
for (std::size_t i = 0; i < prop.size(); ++ i) for (std::size_t i = 0; i < prop.size(); ++ i)
out.push_back (std::make_pair (prop[i], m_base.get_type(prop[i]))); out.push_back (std::make_pair (prop[i], std::type_index(m_base.get_type(prop[i]))));
return out; return out;
} }

View File

@ -106,6 +106,11 @@ int main (int, char**)
point_set.add_property_map<int> ("label", 0); point_set.add_property_map<int> ("label", 0);
point_set.add_property_map<double> ("intensity", 0.0); point_set.add_property_map<double> ("intensity", 0.0);
auto pnt = point_set.properties_and_types();
std::cerr << "Properties = " << std::endl;
for (const auto& p : pnt)
std::cerr << " * " << p.first << " with type " << p.second.name() << std::endl;
test (point_set.base().n_properties() == 4, "point set should have 4 properties."); test (point_set.base().n_properties() == 4, "point set should have 4 properties.");
Point p_before = *(point_set.points().begin()); Point p_before = *(point_set.points().begin());