removed _node from Orthtree property API

This commit is contained in:
Sven Oesau 2024-02-05 18:11:01 +01:00
parent 3310585228
commit e4686a21a9
2 changed files with 14 additions and 14 deletions

View File

@ -512,7 +512,7 @@ public:
*/
template <typename T>
std::pair<Property_map<T>, bool>
add_node_property(const std::string& name, const T default_value = T()) {
add_property(const std::string& name, const T default_value = T()) {
auto p = m_node_properties.get_or_add_property(name, default_value);
return std::pair<Property_map<T>, bool>(Property_map<T>(p.first), p.second);
}
@ -528,7 +528,7 @@ public:
*/
template <typename T>
Pair_optional_adaptor<Property_map<T>>
node_property(const std::string& name) {
property(const std::string& name) {
auto p = m_node_properties.template get_property_if_exists<T>(name);
if (p)
return std::optional<Property_map<T> >(Property_map<T>(*p));
@ -553,7 +553,7 @@ public:
\return true if property was a valid property of the tree.
*/
template <typename T>
bool remove_node_property(Property_map<T> property) {
bool remove_property(Property_map<T> property) {
return m_node_properties.remove_property(property.array());
}

View File

@ -26,35 +26,35 @@ int main(void) {
Octree tree({points, points.point_map()});
// Testing built in node properties
typename Octree::Property_map<typename Octree::Node_data> data_prop = *tree.node_property<typename Octree::Node_data>("contents");
typename Octree::Property_map<typename Octree::Node_data> data_prop = *tree.property<typename Octree::Node_data>("contents");
CGAL_USE(data_prop);
// list of properties
std::size_t num = tree.properties().size();
assert(num == 5);
auto prop2 = tree.add_node_property("test", int(0));
auto prop2 = tree.add_property("test", int(0));
assert(prop2.second);
assert(tree.properties().size() == 6);
auto prop5 = tree.add_node_property("test", int(0));
auto prop5 = tree.add_property("test", int(0));
assert(!prop5.second);
auto a1 = tree.node_property<int>("test");
std::pair<typename Octree::Property_map<int>, bool> p1 = tree.node_property<int>("test");
std::optional<typename Octree::Property_map<int>> o1 = tree.node_property<int>("test");
auto a1 = tree.property<int>("test");
std::pair<typename Octree::Property_map<int>, bool> p1 = tree.property<int>("test");
std::optional<typename Octree::Property_map<int>> o1 = tree.property<int>("test");
auto f = a1.first;
auto pf1 = p1.first;
auto of1 = o1.value();
auto fo1 = a1.value();
std::cout << f.size() << std::endl;
auto a2 = tree.node_property<std::string>("test");
std::pair<typename Octree::Property_map<std::string>, bool> p2 = tree.node_property<std::string>("test");
std::optional<typename Octree::Property_map<std::string>> o2 = tree.node_property<std::string>("test");
auto a2 = tree.property<std::string>("test");
std::pair<typename Octree::Property_map<std::string>, bool> p2 = tree.property<std::string>("test");
std::optional<typename Octree::Property_map<std::string>> o2 = tree.property<std::string>("test");
//assert(prop3.has_value());
auto prop4 = tree.node_property<std::string>("test");
auto prop4 = tree.property<std::string>("test");
assert(!prop4.has_value());
// removal of properties
@ -63,7 +63,7 @@ int main(void) {
assert(tree.properties().size() == (num - 1));
// Default value should be respected
auto node_int_property = tree.add_node_property<int>("int", 5).first;
auto node_int_property = tree.add_property<int>("int", 5).first;
assert(node_int_property[tree.root()] == 5);
// Changes to individual nodes should be respected