restore old behavior with a forward constructor

drawback: construction with initilization list become ambiguous
This commit is contained in:
Sébastien Loriot 2024-02-29 19:14:04 +01:00
parent 3da1087bfe
commit dffac51a18
21 changed files with 48 additions and 40 deletions

View File

@ -301,7 +301,7 @@ Octree octree(points, points.point_map());
typedef CGAL::Point_set_3<Kernel::Point_3> Point_set;
typedef CGAL::Octree<Kernel, Point_set, Point_map, false> Octree;
...
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
\endcode
The node class does not exist anymore and has been replaced by the lightweight type `Node_index`. All information formerly contained in the node class is now accessible via the `Orthtree` interface.

View File

@ -29,7 +29,7 @@ int main(int argc, char **argv) {
std::cout << "loaded " << points.number_of_points() << " points\n" << std::endl;
// Create an octree from the points
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
// Build the octree with a small bucket size, using a more verbose method
octree.refine(CGAL::Orthtrees::Maximum_number_of_inliers(10));

View File

@ -46,7 +46,7 @@ int main(int argc, char **argv) {
std::cout << "loaded " << points.number_of_points() << " points" << std::endl;
// Create an octree from the points
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
// Build the octree using our custom split predicate
octree.refine(Split_by_ratio(2));

View File

@ -31,7 +31,7 @@ int main(int argc, char** argv) {
std::cout << "loaded " << points.number_of_points() << " points" << std::endl;
// Create an octree from the points
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
// Build the octree
octree.refine(10, 20);

View File

@ -60,7 +60,7 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}
Octree tree({mesh, mesh.points()});
Octree tree(mesh, mesh.points());
OTraits::Split_predicate_node_min_extent sp(0.01);
tree.refine(sp);

View File

@ -54,7 +54,7 @@ int main(int argc, char** argv) {
std::cout << "loaded " << points.number_of_points() << " points\n" << std::endl;
// Create an octree from the points
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
// Build the octree
octree.refine();

View File

@ -29,7 +29,7 @@ int main(int argc, char** argv) {
std::cout << "loaded " << points.number_of_points() << " points\n" << std::endl;
// Create an octree from the points
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
// Build the octree using the default arguments
octree.refine();

View File

@ -30,7 +30,7 @@ int main(int argc, char **argv) {
std::cout << "loaded " << points.number_of_points() << " points\n" << std::endl;
// Create an octree from the points
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
// Build the octree
octree.refine();

View File

@ -235,7 +235,7 @@ public:
/// @{
/*!
\brief creates an orthtree for a traits instance.
\brief constructs an orthtree for a traits instance.
The constructed orthtree has a root node with no children,
containing the contents determined by `Construct_root_node_contents` from the traits class.
@ -275,10 +275,18 @@ public:
data(root()) = m_traits.construct_root_node_contents_object()();
}
/*!
constructs an orthtree from a set of arguments provided to the traits constructor
*/
template <class Arg1, class Arg2, class ... Args>
explicit Orthtree(Arg1&& arg1, Arg2&& arg2, Args&& ... args)
: Orthtree(Traits(std::forward<Arg1>(arg1), std::forward<Arg2>(arg2), std::forward<Args>(args)...))
{}
/// @}
// copy constructor
Orthtree(const Orthtree& other) :
explicit Orthtree(const Orthtree& other) :
m_traits(other.m_traits),
m_node_properties(other.m_node_properties),
m_node_contents(m_node_properties),
@ -289,7 +297,7 @@ public:
m_bbox(other.m_bbox), m_side_per_depth(other.m_side_per_depth) {}
// move constructor
Orthtree(Orthtree&& other) :
explicit Orthtree(Orthtree&& other) :
m_traits(other.m_traits),
m_node_properties(std::move(other.m_node_properties)),
m_node_contents(m_node_properties),

View File

@ -34,7 +34,7 @@ int main(void) {
points.insert({-1, -1, -1.8});
points.insert({-1, -1, -1.9});
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
std::cout << octree << std::endl;

View File

@ -33,7 +33,7 @@ int main(void) {
points.insert({-1, -1, -1.8});
points.insert({-1, -1, -1.9});
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
std::cout << "root: " << octree.local_coordinates(octree.root()) << std::endl;

View File

@ -19,7 +19,7 @@ void test_1_node() {
points.insert({-1, -1, -1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
Octree::Bbox expected_bbox{-1, -1, -1, -1, -1, -1};
@ -36,7 +36,7 @@ void test_9_nodes() {
points.insert({1, 1, 1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Compare the top node
@ -63,7 +63,7 @@ void test_25_nodes() {
points.insert({1, 0.5, 1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Compare the top node

View File

@ -57,7 +57,7 @@ int main()
for (std::size_t i = 0; i < nb_pts; ++i)
points.insert(*(generator++));
Octree base({ points, points.point_map() });
Octree base(points, points.point_map());
test(base);
Octree_without_data base2({});

View File

@ -23,7 +23,7 @@ int main(void) {
for (std::size_t i = 0; i < nb_pts; ++i)
points.insert(*(generator++));
Octree tree({points, points.point_map()});
Octree tree(points, points.point_map());
// Testing built in node properties
typename Octree::Property_map<typename Octree::Node_data> data_prop = *tree.property<typename Octree::Node_data>("contents");

View File

@ -25,8 +25,8 @@ void test_identical_trees() {
points.insert({1, 1, 1});
// Create a pair of trees from the same point set
Octree a({points, points.point_map()});
Octree b({points, points.point_map()});
Octree a(points, points.point_map());
Octree b(points, points.point_map());
// Refine both trees using the same criteria
a.refine(10, 1);
@ -51,8 +51,8 @@ void test_identical_contents_different_criteria() {
points.insert({1, 1, 1});
// Create a pair of trees from the same point set
Octree a({points, points.point_map()});
Octree b({points, points.point_map()});
Octree a(points, points.point_map());
Octree b(points, points.point_map());
// Refine both trees using different criteria
a.refine(10, 1);
@ -86,8 +86,8 @@ void test_different_contents_identical_criteria() {
points_b.insert({1, 1, 2});
// Create a pair of trees from the different point sets
Octree a({points_a, points_a.point_map()});
Octree b({points_b, points_b.point_map()});
Octree a(points_a, points_a.point_map());
Octree b(points_b, points_b.point_map());
// Refine both trees using the same criteria
a.refine(10, 1);

View File

@ -48,7 +48,7 @@ void test(std::size_t dataset_size) {
points.insert(*(generator++));
// Build an octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
// Refine the octree
octree.refine();

View File

@ -18,7 +18,7 @@ void test()
for (std::size_t i = 0; i < 100; ++i)
points.insert(*(generator++));
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine();
octree.grade();
}

View File

@ -21,7 +21,7 @@ void test_1_point() {
points.insert({-1, -1, -1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Because there's only the root node, any point should be placed in it
@ -47,7 +47,7 @@ void test_8_points() {
points.insert({1, 1, 1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Existing points should end up in the same place
@ -88,7 +88,7 @@ void test_10_points() {
points.insert({-1, -0.75, 1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Existing points should end up in the same place

View File

@ -66,7 +66,7 @@ void naive_vs_octree(std::size_t dataset_size) {
// Do the same using the octree
Point octree_nearest = *generator;
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 20);
auto octree_start_time = high_resolution_clock::now();
{
@ -118,7 +118,7 @@ void kdtree_vs_octree(std::size_t dataset_size, std::size_t K) {
// Do the same using the octree
std::vector<Point_set::Index> octree_nearest_neighbors;
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 20);
auto octree_start_time = high_resolution_clock::now();
octree.nearest_neighbors(random_point, K, std::back_inserter(octree_nearest_neighbors));

View File

@ -37,7 +37,7 @@ void test_1_point() {
points.insert({-1, -1, -1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Check that the root node was never split
@ -53,11 +53,11 @@ void test_2_points() {
points.insert({1, -1, -1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// The octree should have been split once
Octree other({points, points.point_map()});
Octree other(points, points.point_map());
other.split(other.root());
assert(Octree::is_topology_equal(other, octree));
assert(1 == octree.depth());
@ -72,10 +72,10 @@ void test_4_points() {
points.insert({1, 1, 4});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
Octree other({points, points.point_map()});
Octree other(points, points.point_map());
other.split(other.root());
other.split(other.node(3));
other.split(other.node(7));

View File

@ -22,7 +22,7 @@ bool test_preorder_1_node() {
points.insert({-1, -1, -1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Create the range
@ -43,7 +43,7 @@ bool test_preorder_9_nodes() {
points.insert({1, -1, -1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Create the range
@ -68,7 +68,7 @@ bool test_level_9_nodes() {
points.insert({1, -1, -1});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
// Create the range
@ -94,7 +94,7 @@ bool test_preorder_25_nodes() {
points.insert({1, 1, 4});
// Create the octree
Octree octree({points, points.point_map()});
Octree octree(points, points.point_map());
octree.refine(10, 1);
std::cout << octree << std::endl;