diff --git a/Orthtree/include/CGAL/Orthtree.h b/Orthtree/include/CGAL/Orthtree.h index dc2e41555d1..09159a3024d 100644 --- a/Orthtree/include/CGAL/Orthtree.h +++ b/Orthtree/include/CGAL/Orthtree.h @@ -511,8 +511,7 @@ public: \return pair of the property map and a Boolean which is `true` if the property needed to be created */ template - Pair_optional_adaptor> - add_property(const std::string& name, const T default_value = T()) { + std::pair, bool> 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, bool>(Property_map(p.first), p.second); } @@ -527,8 +526,7 @@ public: \return an optional containing the property map if it exists */ template - Pair_optional_adaptor> - property(const std::string& name) { + std::optional> property(const std::string& name) { auto p = m_node_properties.template get_property_if_exists(name); if (p) return std::optional >(Property_map(*p)); diff --git a/Orthtree/test/Orthtree/test_node_adjacent.cpp b/Orthtree/test/Orthtree/test_node_adjacent.cpp index 2f79a63008b..3655fb2f2c3 100644 --- a/Orthtree/test/Orthtree/test_node_adjacent.cpp +++ b/Orthtree/test/Orthtree/test_node_adjacent.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_node_index.cpp b/Orthtree/test/Orthtree/test_node_index.cpp index 8e045174de1..f2270251e34 100644 --- a/Orthtree/test/Orthtree/test_node_index.cpp +++ b/Orthtree/test/Orthtree/test_node_index.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_bbox.cpp b/Orthtree/test/Orthtree/test_octree_bbox.cpp index 2c944f7080a..c6be3ecfacf 100644 --- a/Orthtree/test/Orthtree/test_octree_bbox.cpp +++ b/Orthtree/test/Orthtree/test_octree_bbox.cpp @@ -1,10 +1,10 @@ #include -#include -#include -#include - #include +#include +#include +#include + using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_copy_move_constructors.cpp b/Orthtree/test/Orthtree/test_octree_copy_move_constructors.cpp index 9b8ae6ffbc8..8a76ac514bb 100644 --- a/Orthtree/test/Orthtree/test_octree_copy_move_constructors.cpp +++ b/Orthtree/test/Orthtree/test_octree_copy_move_constructors.cpp @@ -2,12 +2,12 @@ #define CGAL_TRACE_STREAM std::cerr #include +#include #include -#include #include -#include #include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_custom_properties.cpp b/Orthtree/test/Orthtree/test_octree_custom_properties.cpp index 0e14a51fbbc..3c69724bd8a 100644 --- a/Orthtree/test/Orthtree/test_octree_custom_properties.cpp +++ b/Orthtree/test/Orthtree/test_octree_custom_properties.cpp @@ -1,12 +1,12 @@ #define CGAL_TRACE_STREAM std::cerr #include +#include #include -#include #include -#include #include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; @@ -30,65 +30,42 @@ int main(void) { CGAL_USE(data_prop); // list of properties - std::size_t num = tree.properties().size(); - assert(num == 5); + assert(tree.properties().size() == 5); + auto prop1 = tree.add_property("test", int(5)); + assert(prop1.second); + // One property added + assert(tree.properties().size() == 6); + // Default value should be respected + assert(prop1.first[tree.root()] == 5); + // Changes to individual nodes should be respected + prop1.first[tree.root()] = 0; + assert(prop1.first[tree.root()] == 0); + auto prop2 = tree.add_property("test", int(0)); - assert(prop2.second); + assert(!prop2.second); assert(tree.properties().size() == 6); - auto prop5 = tree.add_property("test", int(0)); - assert(!prop5.second); + auto prop3 = tree.add_property("test2", std::string()); + assert(prop3.second); + assert(tree.properties().size() == 7); - auto a3 = tree.add_property("test1", int(0)); - std::pair, bool> p3 = tree.add_property("test2", int(0)); - std::optional> o3 = tree.add_property("test3", int(0)); + auto prop4 = tree.property("test"); + assert(prop4.has_value()); - auto a4 = tree.add_property("test", int(0)); - std::pair, bool> p4 = tree.add_property("test", int(0)); - std::optional> o4 = tree.add_property("test", int(0)); - - auto a1 = tree.property("test"); - std::pair, bool> p1 = tree.property("test"); - std::optional> o1 = tree.property("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.property("test"); - std::pair, bool> p2 = tree.property("test"); - std::optional> o2 = tree.property("test"); - - //assert(prop3.has_value()); - - auto prop4 = tree.property("test"); - assert(!prop4.has_value()); - - // removal of properties - num = tree.properties().size(); - //tree.remove_node_property(*prop3); - assert(tree.properties().size() == (num - 1)); - - // Default value should be respected - auto node_int_property = tree.add_property("int", 5).first; - assert(node_int_property[tree.root()] == 5); - - // Changes to individual nodes should be respected - node_int_property[tree.root()] = 0; - assert(node_int_property[tree.root()] == 0); + auto prop5 = tree.property("test"); + assert(!prop5.has_value()); // Expanding the tree; new nodes should be assigned the default value tree.refine(10, 1); for (auto n : tree.traverse>()) { // Everything but the root will have the default value - if (!tree.is_root(n)) assert(node_int_property[n] == 5); + if (!tree.is_root(n)) assert(prop1.first[n] == 5); } // The root should have preserved its custom value - assert(node_int_property[tree.root()] == 0); - - + assert(prop1.first[tree.root()] == 0); + tree.remove_property(prop1.first); + assert(tree.properties().size() == 6); return EXIT_SUCCESS; } diff --git a/Orthtree/test/Orthtree/test_octree_equality.cpp b/Orthtree/test/Orthtree/test_octree_equality.cpp index fc71eb647ec..db1c18a9a12 100644 --- a/Orthtree/test/Orthtree/test_octree_equality.cpp +++ b/Orthtree/test/Orthtree/test_octree_equality.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_grade.cpp b/Orthtree/test/Orthtree/test_octree_grade.cpp index 972b4a7168a..226aa29b10f 100644 --- a/Orthtree/test/Orthtree/test_octree_grade.cpp +++ b/Orthtree/test/Orthtree/test_octree_grade.cpp @@ -2,13 +2,13 @@ #define CGAL_TRACE_STREAM std::cerr #include +#include #include #include -#include #include -#include #include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_intersecting.cpp b/Orthtree/test/Orthtree/test_octree_intersecting.cpp index 6b246bb8947..ae40a16037e 100644 --- a/Orthtree/test/Orthtree/test_octree_intersecting.cpp +++ b/Orthtree/test/Orthtree/test_octree_intersecting.cpp @@ -1,12 +1,12 @@ #define CGAL_TRACE_STREAM std::cerr #include +#include #include #include -#include -#include #include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_kernels.cpp b/Orthtree/test/Orthtree/test_octree_kernels.cpp index 3b2353738b6..7cd6fb0de8b 100644 --- a/Orthtree/test/Orthtree/test_octree_kernels.cpp +++ b/Orthtree/test/Orthtree/test_octree_kernels.cpp @@ -1,9 +1,9 @@ #include +#include +#include #include #include #include -#include -#include template void test() diff --git a/Orthtree/test/Orthtree/test_octree_locate.cpp b/Orthtree/test/Orthtree/test_octree_locate.cpp index 70872734149..77a243d7bc6 100644 --- a/Orthtree/test/Orthtree/test_octree_locate.cpp +++ b/Orthtree/test/Orthtree/test_octree_locate.cpp @@ -2,11 +2,11 @@ #define CGAL_TRACE_STREAM std::cerr #include +#include #include -#include #include -#include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_nearest_neighbor.cpp b/Orthtree/test/Orthtree/test_octree_nearest_neighbor.cpp index 18ae90b4005..e558ebbfe6d 100644 --- a/Orthtree/test/Orthtree/test_octree_nearest_neighbor.cpp +++ b/Orthtree/test/Orthtree/test_octree_nearest_neighbor.cpp @@ -2,17 +2,17 @@ #define CGAL_TRACE_STREAM std::cerr #include +#include +#include #include #include -#include #include #include #include #include #include -#include -#include +#include using namespace std::chrono; diff --git a/Orthtree/test/Orthtree/test_octree_refine.cpp b/Orthtree/test/Orthtree/test_octree_refine.cpp index 64ef05648a8..f61b6141e53 100644 --- a/Orthtree/test/Orthtree/test_octree_refine.cpp +++ b/Orthtree/test/Orthtree/test_octree_refine.cpp @@ -2,11 +2,11 @@ #define CGAL_TRACE_STREAM std::cerr #include +#include #include -#include #include -#include +#include using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; diff --git a/Orthtree/test/Orthtree/test_octree_traverse.cpp b/Orthtree/test/Orthtree/test_octree_traverse.cpp index 13d7527bd99..4d96f88442c 100644 --- a/Orthtree/test/Orthtree/test_octree_traverse.cpp +++ b/Orthtree/test/Orthtree/test_octree_traverse.cpp @@ -1,12 +1,12 @@ #define CGAL_TRACE_STREAM std::cerr +#include #include #include - -#include #include -#include +#include + using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3;