mirror of https://github.com/CGAL/cgal
Replace children() helper with individual child() access
This commit is contained in:
parent
33358ae838
commit
e7f236678e
|
|
@ -514,9 +514,9 @@ public:
|
|||
return traverse<Traversal>({*this, std::forward<Args>(args)...});
|
||||
}
|
||||
|
||||
template <typename Traversal>
|
||||
Node_index_range traverse_indices() const {
|
||||
return traverse_indices<Traversal>({*this});
|
||||
template <typename Traversal, typename ...Args>
|
||||
Node_index_range traverse_indices(Args&& ...args) const {
|
||||
return traverse_indices<Traversal>({*this, std::forward<Args>(args)...});
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -740,24 +740,6 @@ public:
|
|||
using Children = typename Node::Children;
|
||||
using Children_const = typename Node::Children_const;
|
||||
|
||||
Children children(Node& node) {
|
||||
CGAL_precondition (!node.is_leaf());
|
||||
return Children{&m_nodes[node.m_children_index.get()], Degree::value};
|
||||
}
|
||||
|
||||
Children children(Node_index node) {
|
||||
return children(m_nodes[node]);
|
||||
}
|
||||
|
||||
Children_const children(const Node& node) const {
|
||||
CGAL_precondition (!node.is_leaf());
|
||||
return Children_const{&m_nodes[node.m_children_index.get()], Degree::value};
|
||||
}
|
||||
|
||||
Children_const children(Node_index node) const {
|
||||
return children(m_nodes[node]);
|
||||
}
|
||||
|
||||
const boost::optional<Node_index> next_sibling(Node_index n) const {
|
||||
|
||||
// Root node has no siblings
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public:
|
|||
} else {
|
||||
|
||||
// todo: this shouldn't be necessary, I'd prefer to directly get m_orthtree[n].m_children_index
|
||||
return m_orthtree.index(m_orthtree.children(n)[0]);
|
||||
return m_orthtree.child(n, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,30 +50,29 @@ int main(void) {
|
|||
assert(!octree.adjacent_node(octree.index(octree.root()), 5));
|
||||
|
||||
// Left Top Front node should have siblings to the Right, Down, and Back
|
||||
auto left_top_back = octree.index(octree.children(octree.root())[Traits::LEFT_TOP_BACK]);
|
||||
auto left_top_back = octree.child(octree.index(octree.root()), Traits::LEFT_TOP_BACK);
|
||||
|
||||
assert(octree.index(&octree.children(octree.root())[Traits::RIGHT_TOP_BACK]) ==
|
||||
octree.adjacent_node(left_top_back, Traits::RIGHT));
|
||||
assert(
|
||||
octree.index(&octree.children(octree.root())[Traits::LEFT_BOTTOM_BACK]) ==
|
||||
octree.adjacent_node(left_top_back, Traits::DOWN));
|
||||
assert(octree.index(&octree.children(octree.root())[Traits::LEFT_TOP_FRONT]) ==
|
||||
assert(octree.child(octree.index(octree.root()), Traits::RIGHT_TOP_BACK) ==
|
||||
octree.adjacent_node(left_top_back, Traits::RIGHT).get());
|
||||
assert(octree.child(octree.index(octree.root()), Traits::LEFT_BOTTOM_BACK) ==
|
||||
octree.adjacent_node(left_top_back, Traits::DOWN).get());
|
||||
assert(octree.child(octree.index(octree.root()), Traits::LEFT_TOP_FRONT) ==
|
||||
octree.adjacent_node(left_top_back, Traits::FRONT));
|
||||
assert(!octree.adjacent_node(left_top_back, Traits::LEFT));
|
||||
assert(!octree.adjacent_node(left_top_back, Traits::UP));
|
||||
assert(!octree.adjacent_node(left_top_back, Traits::BACK));
|
||||
|
||||
std::cout << octree.children(octree.root())[Traits::LEFT_BOTTOM_BACK] << std::endl;
|
||||
std::cout << octree[octree.child(octree.index(octree.root()), Traits::LEFT_BOTTOM_BACK)] << std::endl;
|
||||
|
||||
auto right_top_back_of_left_bottom_back =
|
||||
octree.index(octree.children(octree.children(octree.root())[Traits::LEFT_BOTTOM_BACK])[Traits::RIGHT_TOP_BACK]);
|
||||
octree.child(octree.child(octree.index(octree.root()), Traits::LEFT_BOTTOM_BACK), Traits::RIGHT_TOP_BACK);
|
||||
|
||||
assert(
|
||||
octree.index(&octree.children(octree.children(octree.root())[Traits::LEFT_BOTTOM_BACK])[Traits::LEFT_TOP_BACK]) ==
|
||||
octree.child(octree.child(octree.index(octree.root()), Traits::LEFT_BOTTOM_BACK), Traits::LEFT_TOP_BACK) ==
|
||||
octree.adjacent_node(right_top_back_of_left_bottom_back, Traits::LEFT)
|
||||
);
|
||||
assert(
|
||||
octree.index(&octree.children(octree.root())[Traits::RIGHT_BOTTOM_BACK]) ==
|
||||
octree.child(octree.index(octree.root()), Traits::RIGHT_BOTTOM_BACK) ==
|
||||
octree.adjacent_node(right_top_back_of_left_bottom_back, Traits::RIGHT)
|
||||
);
|
||||
assert(octree.adjacent_node(right_top_back_of_left_bottom_back, Traits::RIGHT).has_value());
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ int main(void) {
|
|||
Octree octree(points, points.point_map());
|
||||
octree.refine(10, 1);
|
||||
|
||||
std::cout << "root: " << octree.root().local_coordinates() << std::endl;
|
||||
std::cout << "first child: " << octree.children(octree.root())[0].local_coordinates() << std::endl;
|
||||
std::cout << "fifth child: " << octree.children(octree.root())[4].local_coordinates() << std::endl;
|
||||
std::cout << "root: " << octree.local_coordinates(octree.index(octree.root())) << std::endl;
|
||||
std::cout << "first child: " << octree.local_coordinates(octree.child(octree.index(octree.root()), 0)) << std::endl;
|
||||
std::cout << "fifth child: " << octree.local_coordinates(octree.child(octree.index(octree.root()), 4)) << std::endl;
|
||||
std::cout << "fifth child of first child: "
|
||||
<< octree.children(octree.children(octree.root())[0])[4].local_coordinates() << std::endl;
|
||||
<< octree.local_coordinates(octree.child(octree.child(octree.index(octree.root()), 0), 4)) << std::endl;
|
||||
|
||||
// TODO
|
||||
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ void test_9_nodes() {
|
|||
assert(octree.bbox(octree.root()) == CGAL::Bbox_3(-1.1, -1.1, -1.1, 1.1, 1.1, 1.1));
|
||||
|
||||
// Compare the child nodes
|
||||
assert(octree.bbox(octree.children(octree.root())[0]) == CGAL::Bbox_3(-1.1, -1.1, -1.1, 0, 0, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[1]) == CGAL::Bbox_3(0, -1.1, -1.1, 1.1, 0, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[2]) == CGAL::Bbox_3(-1.1, 0, -1.1, 0, 1.1, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[3]) == CGAL::Bbox_3(0, 0, -1.1, 1.1, 1.1, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[4]) == CGAL::Bbox_3(-1.1, -1.1, 0, 0, 0, 1.1));
|
||||
assert(octree.bbox(octree.children(octree.root())[5]) == CGAL::Bbox_3(0, -1.1, 0, 1.1, 0, 1.1));
|
||||
assert(octree.bbox(octree.children(octree.root())[6]) == CGAL::Bbox_3(-1.1, 0, 0, 0, 1.1, 1.1));
|
||||
assert(octree.bbox(octree.children(octree.root())[7]) == CGAL::Bbox_3(0, 0, 0, 1.1, 1.1, 1.1));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 0)) == CGAL::Bbox_3(-1.1, -1.1, -1.1, 0, 0, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 1)) == CGAL::Bbox_3(0, -1.1, -1.1, 1.1, 0, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 2)) == CGAL::Bbox_3(-1.1, 0, -1.1, 0, 1.1, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 3)) == CGAL::Bbox_3(0, 0, -1.1, 1.1, 1.1, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 4)) == CGAL::Bbox_3(-1.1, -1.1, 0, 0, 0, 1.1));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 5)) == CGAL::Bbox_3(0, -1.1, 0, 1.1, 0, 1.1));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 6)) == CGAL::Bbox_3(-1.1, 0, 0, 0, 1.1, 1.1));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 7)) == CGAL::Bbox_3(0, 0, 0, 1.1, 1.1, 1.1));
|
||||
}
|
||||
|
||||
void test_25_nodes() {
|
||||
|
|
@ -69,49 +69,49 @@ void test_25_nodes() {
|
|||
assert(octree.bbox(octree.root()) == CGAL::Bbox_3(-1.5, -1.5, -1.5, 1.5, 1.5, 1.5));
|
||||
|
||||
// Compare the child nodes
|
||||
assert(octree.bbox(octree.children(octree.root())[0]) == CGAL::Bbox_3(-1.5, -1.5, -1.5, 0, 0, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[1]) == CGAL::Bbox_3(0, -1.5, -1.5, 1.5, 0, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[2]) == CGAL::Bbox_3(-1.5, 0, -1.5, 0, 1.5, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[3]) == CGAL::Bbox_3(0, 0, -1.5, 1.5, 1.5, 0));
|
||||
assert(octree.bbox(octree.children(octree.root())[4]) == CGAL::Bbox_3(-1.5, -1.5, 0, 0, 0, 1.5));
|
||||
assert(octree.bbox(octree.children(octree.root())[5]) == CGAL::Bbox_3(0, -1.5, 0, 1.5, 0, 1.5));
|
||||
assert(octree.bbox(octree.children(octree.root())[6]) == CGAL::Bbox_3(-1.5, 0, 0, 0, 1.5, 1.5));
|
||||
assert(octree.bbox(octree.children(octree.root())[7]) == CGAL::Bbox_3(0, 0, 0, 1.5, 1.5, 1.5));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 0)) == CGAL::Bbox_3(-1.5, -1.5, -1.5, 0, 0, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 1)) == CGAL::Bbox_3(0, -1.5, -1.5, 1.5, 0, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 2)) == CGAL::Bbox_3(-1.5, 0, -1.5, 0, 1.5, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 3)) == CGAL::Bbox_3(0, 0, -1.5, 1.5, 1.5, 0));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 4)) == CGAL::Bbox_3(-1.5, -1.5, 0, 0, 0, 1.5));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 5)) == CGAL::Bbox_3(0, -1.5, 0, 1.5, 0, 1.5));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 6)) == CGAL::Bbox_3(-1.5, 0, 0, 0, 1.5, 1.5));
|
||||
assert(octree.bbox(octree.child(octree.index(octree.root()), 7)) == CGAL::Bbox_3(0, 0, 0, 1.5, 1.5, 1.5));
|
||||
|
||||
// Compare children of the first child
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[0]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 0)) ==
|
||||
CGAL::Bbox_3(-1.5, -1.5, -1.5, -0.75, -0.75, -0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[1]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 1)) ==
|
||||
CGAL::Bbox_3(-0.75, -1.5, -1.5, 0, -0.75, -0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[2]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 2)) ==
|
||||
CGAL::Bbox_3(-1.5, -0.75, -1.5, -0.75, 0, -0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[3]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 3)) ==
|
||||
CGAL::Bbox_3(-0.75, -0.75, -1.5, 0, 0, -0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[4]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 4)) ==
|
||||
CGAL::Bbox_3(-1.5, -1.5, -0.75, -0.75, -0.75, 0));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[5]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 5)) ==
|
||||
CGAL::Bbox_3(-0.75, -1.5, -0.75, 0, -0.75, 0));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[6]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 6)) ==
|
||||
CGAL::Bbox_3(-1.5, -0.75, -0.75, -0.75, 0, 0));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[0])[7]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 0), 7)) ==
|
||||
CGAL::Bbox_3(-0.75, -0.75, -0.75, 0, 0, 0));
|
||||
|
||||
// Compare children of the last child
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[0]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 0)) ==
|
||||
CGAL::Bbox_3(0, 0, 0, 0.75, 0.75, 0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[1]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 1)) ==
|
||||
CGAL::Bbox_3(0.75, 0, 0, 1.5, 0.75, 0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[2]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 2)) ==
|
||||
CGAL::Bbox_3(0, 0.75, 0, 0.75, 1.5, 0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[3]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 3)) ==
|
||||
CGAL::Bbox_3(0.75, 0.75, 0, 1.5, 1.5, 0.75));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[4]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 4)) ==
|
||||
CGAL::Bbox_3(0, 0, 0.75, 0.75, 0.75, 1.5));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[5]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 5)) ==
|
||||
CGAL::Bbox_3(0.75, 0, 0.75, 1.5, 0.75, 1.5));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[6]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 6)) ==
|
||||
CGAL::Bbox_3(0, 0.75, 0.75, 0.75, 1.5, 1.5));
|
||||
assert(octree.bbox(octree.children(octree.children(octree.root())[7])[7]) ==
|
||||
assert(octree.bbox(octree.child(octree.child(octree.index(octree.root()), 7), 7)) ==
|
||||
CGAL::Bbox_3(0.75, 0.75, 0.75, 1.5, 1.5, 1.5));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,10 +68,10 @@ int main(void) {
|
|||
|
||||
// Check the results
|
||||
assert(4 == nodes.size());
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::RIGHT_TOP_BACK]) == nodes[0]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::RIGHT_BOTTOM_FRONT]) == nodes[1]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::LEFT_TOP_FRONT]) == nodes[2]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::RIGHT_TOP_FRONT]) == nodes[3]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::RIGHT_TOP_BACK) == nodes[0]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::RIGHT_BOTTOM_FRONT) == nodes[1]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::LEFT_TOP_FRONT) == nodes[2]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::RIGHT_TOP_FRONT) == nodes[3]);
|
||||
}
|
||||
|
||||
// Intersection with a ray
|
||||
|
|
@ -86,18 +86,19 @@ int main(void) {
|
|||
|
||||
// Check the results
|
||||
assert(8 == nodes.size());
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::LEFT_BOTTOM_BACK]) == nodes[0]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::LEFT_BOTTOM_BACK) == nodes[0]);
|
||||
assert(
|
||||
octree.index(octree.children(
|
||||
octree.children(octree.root())[Octree::Traits::RIGHT_BOTTOM_BACK])[Octree::Traits::LEFT_TOP_FRONT])
|
||||
octree.child(octree.child(octree.index(octree.root()),
|
||||
Octree::Traits::RIGHT_BOTTOM_BACK),
|
||||
Octree::Traits::LEFT_TOP_FRONT)
|
||||
== nodes[1]
|
||||
);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::LEFT_TOP_BACK]) == nodes[2]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::RIGHT_TOP_BACK]) == nodes[3]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::LEFT_BOTTOM_FRONT]) == nodes[4]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::RIGHT_BOTTOM_FRONT]) == nodes[5]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::LEFT_TOP_FRONT]) == nodes[6]);
|
||||
assert(octree.index(octree.children(octree.root())[Octree::Traits::RIGHT_TOP_FRONT]) == nodes[7]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::LEFT_TOP_BACK) == nodes[2]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::RIGHT_TOP_BACK) == nodes[3]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::LEFT_BOTTOM_FRONT) == nodes[4]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::RIGHT_BOTTOM_FRONT) == nodes[5]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::LEFT_TOP_FRONT) == nodes[6]);
|
||||
assert(octree.child(octree.index(octree.root()), Octree::Traits::RIGHT_TOP_FRONT) == nodes[7]);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -52,24 +52,24 @@ void test_8_points() {
|
|||
octree.refine(10, 1);
|
||||
|
||||
// Existing points should end up in the same place
|
||||
assert(octree.index(octree.children(octree.root())[0]) == octree.locate({-1, -1, -1}));
|
||||
assert(octree.index(octree.children(octree.root())[1]) == octree.locate({1, -1, -1}));
|
||||
assert(octree.index(octree.children(octree.root())[2]) == octree.locate({-1, 1, -1}));
|
||||
assert(octree.index(octree.children(octree.root())[3]) == octree.locate({1, 1, -1}));
|
||||
assert(octree.index(octree.children(octree.root())[4]) == octree.locate({-1, -1, 1}));
|
||||
assert(octree.index(octree.children(octree.root())[5]) == octree.locate({1, -1, 1}));
|
||||
assert(octree.index(octree.children(octree.root())[6]) == octree.locate({-1, 1, 1}));
|
||||
assert(octree.index(octree.children(octree.root())[7]) == octree.locate({1, 1, 1}));
|
||||
assert(octree.child(octree.index(octree.root()), 0) == octree.locate({-1, -1, -1}));
|
||||
assert(octree.child(octree.index(octree.root()), 1) == octree.locate({1, -1, -1}));
|
||||
assert(octree.child(octree.index(octree.root()), 2) == octree.locate({-1, 1, -1}));
|
||||
assert(octree.child(octree.index(octree.root()), 3) == octree.locate({1, 1, -1}));
|
||||
assert(octree.child(octree.index(octree.root()), 4) == octree.locate({-1, -1, 1}));
|
||||
assert(octree.child(octree.index(octree.root()), 5) == octree.locate({1, -1, 1}));
|
||||
assert(octree.child(octree.index(octree.root()), 6) == octree.locate({-1, 1, 1}));
|
||||
assert(octree.child(octree.index(octree.root()), 7) == octree.locate({1, 1, 1}));
|
||||
|
||||
// Points adjacent to the existing points should also end up in the same place
|
||||
assert(octree.index(octree.children(octree.root())[0]) == octree.locate({-1.1, -1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[1]) == octree.locate({1.1, -1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[2]) == octree.locate({-1.1, 1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[3]) == octree.locate({1.1, 1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[4]) == octree.locate({-1.1, -1.1, 1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[5]) == octree.locate({1.1, -1.1, 1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[6]) == octree.locate({-1.1, 1.1, 1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[7]) == octree.locate({1.1, 1.1, 1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 0) == octree.locate({-1.1, -1.1, -1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 1) == octree.locate({1.1, -1.1, -1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 2) == octree.locate({-1.1, 1.1, -1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 3) == octree.locate({1.1, 1.1, -1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 4) == octree.locate({-1.1, -1.1, 1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 5) == octree.locate({1.1, -1.1, 1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 6) == octree.locate({-1.1, 1.1, 1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 7) == octree.locate({1.1, 1.1, 1.1}));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -93,28 +93,28 @@ void test_10_points() {
|
|||
octree.refine(10, 1);
|
||||
|
||||
// Existing points should end up in the same place
|
||||
assert(octree.index(octree.children(octree.root())[0]) == octree.locate({-1, -1, -1}));
|
||||
assert(octree.index(octree.children(octree.root())[1]) == octree.locate({1, -1, -1}));
|
||||
assert(octree.index(octree.children(octree.root())[2]) == octree.locate({-1, 1, -1}));
|
||||
assert(octree.index(octree.children(octree.children(octree.children(octree.root())[3])[3])[3]) ==
|
||||
assert(octree.child(octree.index(octree.root()), 0) == octree.locate({-1, -1, -1}));
|
||||
assert(octree.child(octree.index(octree.root()), 1) == octree.locate({1, -1, -1}));
|
||||
assert(octree.child(octree.index(octree.root()), 2) == octree.locate({-1, 1, -1}));
|
||||
assert(octree.child(octree.child(octree.child(octree.index(octree.root()), 3), 3), 3) ==
|
||||
octree.locate({1, 1, -1}));
|
||||
assert(octree.index(octree.children(octree.children(octree.children(octree.root())[4])[4])[4]) ==
|
||||
assert(octree.child(octree.child(octree.child(octree.index(octree.root()), 4), 4), 4) ==
|
||||
octree.locate({-1, -1, 1}));
|
||||
assert(octree.index(octree.children(octree.root())[5]) == octree.locate({1, -1, 1}));
|
||||
assert(octree.index(octree.children(octree.root())[6]) == octree.locate({-1, 1, 1}));
|
||||
assert(octree.index(octree.children(octree.root())[7]) == octree.locate({1, 1, 1}));
|
||||
assert(octree.child(octree.index(octree.root()), 5) == octree.locate({1, -1, 1}));
|
||||
assert(octree.child(octree.index(octree.root()), 6) == octree.locate({-1, 1, 1}));
|
||||
assert(octree.child(octree.index(octree.root()), 7) == octree.locate({1, 1, 1}));
|
||||
|
||||
// Points adjacent to the existing points might end up in different places
|
||||
assert(octree.index(octree.children(octree.root())[0]) == octree.locate({-1.1, -1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[1]) == octree.locate({1.1, -1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[2]) == octree.locate({-1.1, 1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.children(octree.children(octree.root())[3])[3])[3]) ==
|
||||
assert(octree.child(octree.index(octree.root()), 0) == octree.locate({-1.1, -1.1, -1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 1) == octree.locate({1.1, -1.1, -1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 2) == octree.locate({-1.1, 1.1, -1.1}));
|
||||
assert(octree.child(octree.child(octree.child(octree.index(octree.root()), 3), 3), 3) ==
|
||||
octree.locate({1.1, 1.1, -1.1}));
|
||||
assert(octree.index(octree.children(octree.children(octree.children(octree.root())[4])[4])[4]) ==
|
||||
assert(octree.child(octree.child(octree.child(octree.index(octree.root()), 4), 4), 4) ==
|
||||
octree.locate({-1.1, -1.1, 1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[5]) == octree.locate({1.1, -1.1, 1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[6]) == octree.locate({-1.1, 1.1, 1.1}));
|
||||
assert(octree.index(octree.children(octree.root())[7]) == octree.locate({1.1, 1.1, 1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 5) == octree.locate({1.1, -1.1, 1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 6) == octree.locate({-1.1, 1.1, 1.1}));
|
||||
assert(octree.child(octree.index(octree.root()), 7) == octree.locate({1.1, 1.1, 1.1}));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ void test_4_points() {
|
|||
// The octree should have been split once on the first level, and twice on the second
|
||||
Octree other(points, points.point_map());
|
||||
other.split(other.index(other.root()));
|
||||
other.split(other.index(other.children(other.root())[3]));
|
||||
other.split(other.index(other.children(other.root())[7]));
|
||||
other.split(other.child(other.index(other.root()), 3));
|
||||
other.split(other.child(other.index(other.root()), 7));
|
||||
assert(Octree::is_topology_equal(other, octree));
|
||||
assert(2 == octree.depth());
|
||||
|
||||
// Applying another splitting criterion shouldn't reset the tree.
|
||||
octree.refine(Split_nth_child_of_root(2));
|
||||
other.split(other.index(other.children(other.root())[2]));
|
||||
other.split(other.child(other.index(other.root()), 2));
|
||||
assert(Octree::is_topology_equal(other, octree));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ bool test_preorder_1_node() {
|
|||
octree.refine(10, 1);
|
||||
|
||||
// Create the range
|
||||
auto nodes = octree.traverse<Preorder_traversal>();
|
||||
auto nodes = octree.traverse_indices<Preorder_traversal>();
|
||||
|
||||
// Check each item in the range
|
||||
auto iter = nodes.begin();
|
||||
assert(*iter == octree.root());
|
||||
assert(*iter == octree.index(octree.root()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -47,14 +47,14 @@ bool test_preorder_9_nodes() {
|
|||
octree.refine(10, 1);
|
||||
|
||||
// Create the range
|
||||
auto nodes = octree.traverse<Preorder_traversal>();
|
||||
auto nodes = octree.traverse_indices<Preorder_traversal>();
|
||||
|
||||
// Check each item in the range
|
||||
auto iter = nodes.begin();
|
||||
assert(*iter == octree.root());
|
||||
assert(*iter == octree.index(octree.root()));
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[i]));
|
||||
assert(*iter == octree.child(octree.index(octree.root()), i));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -72,12 +72,12 @@ bool test_level_9_nodes() {
|
|||
octree.refine(10, 1);
|
||||
|
||||
// Create the range
|
||||
auto nodes = octree.traverse<Level_traversal>(1);
|
||||
auto nodes = octree.traverse_indices<Level_traversal>(1);
|
||||
|
||||
// Check each item in the range
|
||||
auto iter = nodes.begin();
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
assert((*iter == octree.children(octree.root())[i]));
|
||||
assert(*iter == octree.child(octree.index(octree.root()), i));
|
||||
iter++;
|
||||
}
|
||||
|
||||
|
|
@ -98,34 +98,34 @@ bool test_preorder_25_nodes() {
|
|||
octree.refine(10, 1);
|
||||
|
||||
// Create the range
|
||||
auto nodes = octree.traverse<Preorder_traversal>();
|
||||
auto nodes = octree.traverse_indices<Preorder_traversal>();
|
||||
|
||||
// Check each item in the range
|
||||
auto iter = nodes.begin();
|
||||
assert(*iter == octree.root());
|
||||
assert(*iter == octree.index(octree.root()));
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[0]));
|
||||
assert(*iter == octree.child(octree.index(octree.root()), 0));
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[1]));
|
||||
assert(*iter == octree.child(octree.index(octree.root()), 1));
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[2]));
|
||||
assert((*iter == octree.child(octree.index(octree.root()), 2)));
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[3]));
|
||||
assert(*iter == octree.child(octree.index(octree.root()), 3));
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.children(octree.root())[3])[i]));
|
||||
assert(*iter == octree.child(octree.child(octree.index(octree.root()), 3), i));
|
||||
}
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[4]));
|
||||
assert((*iter == octree.child(octree.index(octree.root()), 4)));
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[5]));
|
||||
assert((*iter == octree.child(octree.index(octree.root()), 5)));
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[6]));
|
||||
assert((*iter == octree.child(octree.index(octree.root()), 6)));
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.root())[7]));
|
||||
assert((*iter == octree.child(octree.index(octree.root()), 7)));
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
iter++;
|
||||
assert((*iter == octree.children(octree.children(octree.root())[7])[i]));
|
||||
assert(*iter == octree.child(octree.child(octree.index(octree.root()), 7), i));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue