mirror of https://github.com/CGAL/cgal
Add node-access convenience functions, and simplify tests
This commit is contained in:
parent
bfe584590e
commit
774aa1f324
|
|
@ -718,6 +718,18 @@ public:
|
||||||
return m_node_children[node].get() + i;
|
return m_node_children[node].get() + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node_index descendant(Node_index node, std::size_t i) { return child(node, i); }
|
||||||
|
|
||||||
|
template <typename... Indices>
|
||||||
|
Node_index descendant(Node_index node, std::size_t i, Indices... remaining_indices) {
|
||||||
|
return descendant(child(node, i), remaining_indices...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Indices>
|
||||||
|
Node_index node(Indices... indices) {
|
||||||
|
return descendant(root(), indices...);
|
||||||
|
}
|
||||||
|
|
||||||
const Maybe_node_index next_sibling(Node_index n) const {
|
const Maybe_node_index next_sibling(Node_index n) const {
|
||||||
|
|
||||||
// Root node has no siblings
|
// Root node has no siblings
|
||||||
|
|
|
||||||
|
|
@ -50,29 +50,26 @@ int main(void) {
|
||||||
assert(!octree.adjacent_node(octree.root(), 5));
|
assert(!octree.adjacent_node(octree.root(), 5));
|
||||||
|
|
||||||
// Left Top Front node should have siblings to the Right, Down, and Back
|
// Left Top Front node should have siblings to the Right, Down, and Back
|
||||||
auto left_top_back = octree.child(octree.root(), Traits::LEFT_TOP_BACK);
|
auto left_top_back = octree.node(Traits::LEFT_TOP_BACK);
|
||||||
|
|
||||||
assert(octree.child(octree.root(), Traits::RIGHT_TOP_BACK) ==
|
assert(octree.node(Traits::RIGHT_TOP_BACK) ==
|
||||||
octree.adjacent_node(left_top_back, Traits::RIGHT).get());
|
octree.adjacent_node(left_top_back, Traits::RIGHT).get());
|
||||||
assert(octree.child(octree.root(), Traits::LEFT_BOTTOM_BACK) ==
|
assert(octree.node(Traits::LEFT_BOTTOM_BACK) ==
|
||||||
octree.adjacent_node(left_top_back, Traits::DOWN).get());
|
octree.adjacent_node(left_top_back, Traits::DOWN).get());
|
||||||
assert(octree.child(octree.root(), Traits::LEFT_TOP_FRONT) ==
|
assert(octree.node(Traits::LEFT_TOP_FRONT) ==
|
||||||
octree.adjacent_node(left_top_back, Traits::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::LEFT));
|
||||||
assert(!octree.adjacent_node(left_top_back, Traits::UP));
|
assert(!octree.adjacent_node(left_top_back, Traits::UP));
|
||||||
assert(!octree.adjacent_node(left_top_back, Traits::BACK));
|
assert(!octree.adjacent_node(left_top_back, Traits::BACK));
|
||||||
|
|
||||||
//std::cout << octree[octree.child(octree.root(), Traits::LEFT_BOTTOM_BACK)] << std::endl;
|
auto right_top_back_of_left_bottom_back = octree.node(Traits::LEFT_BOTTOM_BACK, Traits::RIGHT_TOP_BACK);
|
||||||
|
|
||||||
auto right_top_back_of_left_bottom_back =
|
|
||||||
octree.child(octree.child(octree.root(), Traits::LEFT_BOTTOM_BACK), Traits::RIGHT_TOP_BACK);
|
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
octree.child(octree.child(octree.root(), Traits::LEFT_BOTTOM_BACK), Traits::LEFT_TOP_BACK) ==
|
octree.node(Traits::LEFT_BOTTOM_BACK, Traits::LEFT_TOP_BACK) ==
|
||||||
octree.adjacent_node(right_top_back_of_left_bottom_back, Traits::LEFT)
|
octree.adjacent_node(right_top_back_of_left_bottom_back, Traits::LEFT)
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
octree.child(octree.root(), Traits::RIGHT_BOTTOM_BACK) ==
|
octree.node(Traits::RIGHT_BOTTOM_BACK) ==
|
||||||
octree.adjacent_node(right_top_back_of_left_bottom_back, Traits::RIGHT)
|
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());
|
assert(octree.adjacent_node(right_top_back_of_left_bottom_back, Traits::RIGHT).has_value());
|
||||||
|
|
|
||||||
|
|
@ -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));
|
assert(octree.bbox(octree.root()) == CGAL::Bbox_3(-1.1, -1.1, -1.1, 1.1, 1.1, 1.1));
|
||||||
|
|
||||||
// Compare the child nodes
|
// Compare the child nodes
|
||||||
assert(octree.bbox(octree.child(octree.root(), 0)) == CGAL::Bbox_3(-1.1, -1.1, -1.1, 0, 0, 0));
|
assert(octree.bbox(octree.node(0)) == CGAL::Bbox_3(-1.1, -1.1, -1.1, 0, 0, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 1)) == CGAL::Bbox_3(0, -1.1, -1.1, 1.1, 0, 0));
|
assert(octree.bbox(octree.node(1)) == CGAL::Bbox_3(0, -1.1, -1.1, 1.1, 0, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 2)) == CGAL::Bbox_3(-1.1, 0, -1.1, 0, 1.1, 0));
|
assert(octree.bbox(octree.node(2)) == CGAL::Bbox_3(-1.1, 0, -1.1, 0, 1.1, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 3)) == CGAL::Bbox_3(0, 0, -1.1, 1.1, 1.1, 0));
|
assert(octree.bbox(octree.node(3)) == CGAL::Bbox_3(0, 0, -1.1, 1.1, 1.1, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 4)) == CGAL::Bbox_3(-1.1, -1.1, 0, 0, 0, 1.1));
|
assert(octree.bbox(octree.node(4)) == CGAL::Bbox_3(-1.1, -1.1, 0, 0, 0, 1.1));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 5)) == CGAL::Bbox_3(0, -1.1, 0, 1.1, 0, 1.1));
|
assert(octree.bbox(octree.node(5)) == CGAL::Bbox_3(0, -1.1, 0, 1.1, 0, 1.1));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 6)) == CGAL::Bbox_3(-1.1, 0, 0, 0, 1.1, 1.1));
|
assert(octree.bbox(octree.node(6)) == CGAL::Bbox_3(-1.1, 0, 0, 0, 1.1, 1.1));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 7)) == CGAL::Bbox_3(0, 0, 0, 1.1, 1.1, 1.1));
|
assert(octree.bbox(octree.node(7)) == CGAL::Bbox_3(0, 0, 0, 1.1, 1.1, 1.1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_25_nodes() {
|
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));
|
assert(octree.bbox(octree.root()) == CGAL::Bbox_3(-1.5, -1.5, -1.5, 1.5, 1.5, 1.5));
|
||||||
|
|
||||||
// Compare the child nodes
|
// Compare the child nodes
|
||||||
assert(octree.bbox(octree.child(octree.root(), 0)) == CGAL::Bbox_3(-1.5, -1.5, -1.5, 0, 0, 0));
|
assert(octree.bbox(octree.node(0)) == CGAL::Bbox_3(-1.5, -1.5, -1.5, 0, 0, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 1)) == CGAL::Bbox_3(0, -1.5, -1.5, 1.5, 0, 0));
|
assert(octree.bbox(octree.node(1)) == CGAL::Bbox_3(0, -1.5, -1.5, 1.5, 0, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 2)) == CGAL::Bbox_3(-1.5, 0, -1.5, 0, 1.5, 0));
|
assert(octree.bbox(octree.node(2)) == CGAL::Bbox_3(-1.5, 0, -1.5, 0, 1.5, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 3)) == CGAL::Bbox_3(0, 0, -1.5, 1.5, 1.5, 0));
|
assert(octree.bbox(octree.node(3)) == CGAL::Bbox_3(0, 0, -1.5, 1.5, 1.5, 0));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 4)) == CGAL::Bbox_3(-1.5, -1.5, 0, 0, 0, 1.5));
|
assert(octree.bbox(octree.node(4)) == CGAL::Bbox_3(-1.5, -1.5, 0, 0, 0, 1.5));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 5)) == CGAL::Bbox_3(0, -1.5, 0, 1.5, 0, 1.5));
|
assert(octree.bbox(octree.node(5)) == CGAL::Bbox_3(0, -1.5, 0, 1.5, 0, 1.5));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 6)) == CGAL::Bbox_3(-1.5, 0, 0, 0, 1.5, 1.5));
|
assert(octree.bbox(octree.node(6)) == CGAL::Bbox_3(-1.5, 0, 0, 0, 1.5, 1.5));
|
||||||
assert(octree.bbox(octree.child(octree.root(), 7)) == CGAL::Bbox_3(0, 0, 0, 1.5, 1.5, 1.5));
|
assert(octree.bbox(octree.node(7)) == CGAL::Bbox_3(0, 0, 0, 1.5, 1.5, 1.5));
|
||||||
|
|
||||||
// Compare children of the first child
|
// Compare children of the first child
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 0)) ==
|
assert(octree.bbox(octree.node(0, 0)) ==
|
||||||
CGAL::Bbox_3(-1.5, -1.5, -1.5, -0.75, -0.75, -0.75));
|
CGAL::Bbox_3(-1.5, -1.5, -1.5, -0.75, -0.75, -0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 1)) ==
|
assert(octree.bbox(octree.node(0, 1)) ==
|
||||||
CGAL::Bbox_3(-0.75, -1.5, -1.5, 0, -0.75, -0.75));
|
CGAL::Bbox_3(-0.75, -1.5, -1.5, 0, -0.75, -0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 2)) ==
|
assert(octree.bbox(octree.node(0, 2)) ==
|
||||||
CGAL::Bbox_3(-1.5, -0.75, -1.5, -0.75, 0, -0.75));
|
CGAL::Bbox_3(-1.5, -0.75, -1.5, -0.75, 0, -0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 3)) ==
|
assert(octree.bbox(octree.node(0, 3)) ==
|
||||||
CGAL::Bbox_3(-0.75, -0.75, -1.5, 0, 0, -0.75));
|
CGAL::Bbox_3(-0.75, -0.75, -1.5, 0, 0, -0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 4)) ==
|
assert(octree.bbox(octree.node(0, 4)) ==
|
||||||
CGAL::Bbox_3(-1.5, -1.5, -0.75, -0.75, -0.75, 0));
|
CGAL::Bbox_3(-1.5, -1.5, -0.75, -0.75, -0.75, 0));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 5)) ==
|
assert(octree.bbox(octree.node(0, 5)) ==
|
||||||
CGAL::Bbox_3(-0.75, -1.5, -0.75, 0, -0.75, 0));
|
CGAL::Bbox_3(-0.75, -1.5, -0.75, 0, -0.75, 0));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 6)) ==
|
assert(octree.bbox(octree.node(0, 6)) ==
|
||||||
CGAL::Bbox_3(-1.5, -0.75, -0.75, -0.75, 0, 0));
|
CGAL::Bbox_3(-1.5, -0.75, -0.75, -0.75, 0, 0));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 0), 7)) ==
|
assert(octree.bbox(octree.node(0, 7)) ==
|
||||||
CGAL::Bbox_3(-0.75, -0.75, -0.75, 0, 0, 0));
|
CGAL::Bbox_3(-0.75, -0.75, -0.75, 0, 0, 0));
|
||||||
|
|
||||||
// Compare children of the last child
|
// Compare children of the last child
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 0)) ==
|
assert(octree.bbox(octree.node(7, 0)) ==
|
||||||
CGAL::Bbox_3(0, 0, 0, 0.75, 0.75, 0.75));
|
CGAL::Bbox_3(0, 0, 0, 0.75, 0.75, 0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 1)) ==
|
assert(octree.bbox(octree.node(7, 1)) ==
|
||||||
CGAL::Bbox_3(0.75, 0, 0, 1.5, 0.75, 0.75));
|
CGAL::Bbox_3(0.75, 0, 0, 1.5, 0.75, 0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 2)) ==
|
assert(octree.bbox(octree.node(7, 2)) ==
|
||||||
CGAL::Bbox_3(0, 0.75, 0, 0.75, 1.5, 0.75));
|
CGAL::Bbox_3(0, 0.75, 0, 0.75, 1.5, 0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 3)) ==
|
assert(octree.bbox(octree.node(7, 3)) ==
|
||||||
CGAL::Bbox_3(0.75, 0.75, 0, 1.5, 1.5, 0.75));
|
CGAL::Bbox_3(0.75, 0.75, 0, 1.5, 1.5, 0.75));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 4)) ==
|
assert(octree.bbox(octree.node(7, 4)) ==
|
||||||
CGAL::Bbox_3(0, 0, 0.75, 0.75, 0.75, 1.5));
|
CGAL::Bbox_3(0, 0, 0.75, 0.75, 0.75, 1.5));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 5)) ==
|
assert(octree.bbox(octree.node(7, 5)) ==
|
||||||
CGAL::Bbox_3(0.75, 0, 0.75, 1.5, 0.75, 1.5));
|
CGAL::Bbox_3(0.75, 0, 0.75, 1.5, 0.75, 1.5));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 6)) ==
|
assert(octree.bbox(octree.node(7, 6)) ==
|
||||||
CGAL::Bbox_3(0, 0.75, 0.75, 0.75, 1.5, 1.5));
|
CGAL::Bbox_3(0, 0.75, 0.75, 0.75, 1.5, 1.5));
|
||||||
assert(octree.bbox(octree.child(octree.child(octree.root(), 7), 7)) ==
|
assert(octree.bbox(octree.node(7, 7)) ==
|
||||||
CGAL::Bbox_3(0.75, 0.75, 0.75, 1.5, 1.5, 1.5));
|
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
|
// Check the results
|
||||||
assert(4 == nodes.size());
|
assert(4 == nodes.size());
|
||||||
assert(octree.child(octree.root(), Octree::Traits::RIGHT_TOP_BACK) == nodes[0]);
|
assert(octree.node(Octree::Traits::RIGHT_TOP_BACK) == nodes[0]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::RIGHT_BOTTOM_FRONT) == nodes[1]);
|
assert(octree.node(Octree::Traits::RIGHT_BOTTOM_FRONT) == nodes[1]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::LEFT_TOP_FRONT) == nodes[2]);
|
assert(octree.node(Octree::Traits::LEFT_TOP_FRONT) == nodes[2]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::RIGHT_TOP_FRONT) == nodes[3]);
|
assert(octree.node(Octree::Traits::RIGHT_TOP_FRONT) == nodes[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Intersection with a ray
|
// Intersection with a ray
|
||||||
|
|
@ -86,19 +86,17 @@ int main(void) {
|
||||||
|
|
||||||
// Check the results
|
// Check the results
|
||||||
assert(8 == nodes.size());
|
assert(8 == nodes.size());
|
||||||
assert(octree.child(octree.root(), Octree::Traits::LEFT_BOTTOM_BACK) == nodes[0]);
|
assert(octree.node(Octree::Traits::LEFT_BOTTOM_BACK) == nodes[0]);
|
||||||
assert(
|
assert(
|
||||||
octree.child(octree.child(octree.root(),
|
octree.node(Octree::Traits::RIGHT_BOTTOM_BACK, Octree::Traits::LEFT_TOP_FRONT)
|
||||||
Octree::Traits::RIGHT_BOTTOM_BACK),
|
|
||||||
Octree::Traits::LEFT_TOP_FRONT)
|
|
||||||
== nodes[1]
|
== nodes[1]
|
||||||
);
|
);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::LEFT_TOP_BACK) == nodes[2]);
|
assert(octree.node(Octree::Traits::LEFT_TOP_BACK) == nodes[2]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::RIGHT_TOP_BACK) == nodes[3]);
|
assert(octree.node(Octree::Traits::RIGHT_TOP_BACK) == nodes[3]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::LEFT_BOTTOM_FRONT) == nodes[4]);
|
assert(octree.node(Octree::Traits::LEFT_BOTTOM_FRONT) == nodes[4]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::RIGHT_BOTTOM_FRONT) == nodes[5]);
|
assert(octree.node(Octree::Traits::RIGHT_BOTTOM_FRONT) == nodes[5]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::LEFT_TOP_FRONT) == nodes[6]);
|
assert(octree.node(Octree::Traits::LEFT_TOP_FRONT) == nodes[6]);
|
||||||
assert(octree.child(octree.root(), Octree::Traits::RIGHT_TOP_FRONT) == nodes[7]);
|
assert(octree.node(Octree::Traits::RIGHT_TOP_FRONT) == nodes[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -52,24 +52,24 @@ void test_8_points() {
|
||||||
octree.refine(10, 1);
|
octree.refine(10, 1);
|
||||||
|
|
||||||
// Existing points should end up in the same place
|
// Existing points should end up in the same place
|
||||||
assert(octree.child(octree.root(), 0) == octree.locate({-1, -1, -1}));
|
assert(octree.node(0) == octree.locate({-1, -1, -1}));
|
||||||
assert(octree.child(octree.root(), 1) == octree.locate({1, -1, -1}));
|
assert(octree.node(1) == octree.locate({1, -1, -1}));
|
||||||
assert(octree.child(octree.root(), 2) == octree.locate({-1, 1, -1}));
|
assert(octree.node(2) == octree.locate({-1, 1, -1}));
|
||||||
assert(octree.child(octree.root(), 3) == octree.locate({1, 1, -1}));
|
assert(octree.node(3) == octree.locate({1, 1, -1}));
|
||||||
assert(octree.child(octree.root(), 4) == octree.locate({-1, -1, 1}));
|
assert(octree.node(4) == octree.locate({-1, -1, 1}));
|
||||||
assert(octree.child(octree.root(), 5) == octree.locate({1, -1, 1}));
|
assert(octree.node(5) == octree.locate({1, -1, 1}));
|
||||||
assert(octree.child(octree.root(), 6) == octree.locate({-1, 1, 1}));
|
assert(octree.node(6) == octree.locate({-1, 1, 1}));
|
||||||
assert(octree.child(octree.root(), 7) == octree.locate({1, 1, 1}));
|
assert(octree.node(7) == octree.locate({1, 1, 1}));
|
||||||
|
|
||||||
// Points adjacent to the existing points should also end up in the same place
|
// Points adjacent to the existing points should also end up in the same place
|
||||||
assert(octree.child(octree.root(), 0) == octree.locate({-1.1, -1.1, -1.1}));
|
assert(octree.node(0) == octree.locate({-1.1, -1.1, -1.1}));
|
||||||
assert(octree.child(octree.root(), 1) == octree.locate({1.1, -1.1, -1.1}));
|
assert(octree.node(1) == octree.locate({1.1, -1.1, -1.1}));
|
||||||
assert(octree.child(octree.root(), 2) == octree.locate({-1.1, 1.1, -1.1}));
|
assert(octree.node(2) == octree.locate({-1.1, 1.1, -1.1}));
|
||||||
assert(octree.child(octree.root(), 3) == octree.locate({1.1, 1.1, -1.1}));
|
assert(octree.node(3) == octree.locate({1.1, 1.1, -1.1}));
|
||||||
assert(octree.child(octree.root(), 4) == octree.locate({-1.1, -1.1, 1.1}));
|
assert(octree.node(4) == octree.locate({-1.1, -1.1, 1.1}));
|
||||||
assert(octree.child(octree.root(), 5) == octree.locate({1.1, -1.1, 1.1}));
|
assert(octree.node(5) == octree.locate({1.1, -1.1, 1.1}));
|
||||||
assert(octree.child(octree.root(), 6) == octree.locate({-1.1, 1.1, 1.1}));
|
assert(octree.node(6) == octree.locate({-1.1, 1.1, 1.1}));
|
||||||
assert(octree.child(octree.root(), 7) == octree.locate({1.1, 1.1, 1.1}));
|
assert(octree.node(7) == octree.locate({1.1, 1.1, 1.1}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,28 +93,24 @@ void test_10_points() {
|
||||||
octree.refine(10, 1);
|
octree.refine(10, 1);
|
||||||
|
|
||||||
// Existing points should end up in the same place
|
// Existing points should end up in the same place
|
||||||
assert(octree.child(octree.root(), 0) == octree.locate({-1, -1, -1}));
|
assert(octree.node(0) == octree.locate({-1, -1, -1}));
|
||||||
assert(octree.child(octree.root(), 1) == octree.locate({1, -1, -1}));
|
assert(octree.node(1) == octree.locate({1, -1, -1}));
|
||||||
assert(octree.child(octree.root(), 2) == octree.locate({-1, 1, -1}));
|
assert(octree.node(2) == octree.locate({-1, 1, -1}));
|
||||||
assert(octree.child(octree.child(octree.child(octree.root(), 3), 3), 3) ==
|
assert(octree.node(3, 3, 3) == octree.locate({1, 1, -1}));
|
||||||
octree.locate({1, 1, -1}));
|
assert(octree.node(4, 4, 4) == octree.locate({-1, -1, 1}));
|
||||||
assert(octree.child(octree.child(octree.child(octree.root(), 4), 4), 4) ==
|
assert(octree.node(5) == octree.locate({1, -1, 1}));
|
||||||
octree.locate({-1, -1, 1}));
|
assert(octree.node(6) == octree.locate({-1, 1, 1}));
|
||||||
assert(octree.child(octree.root(), 5) == octree.locate({1, -1, 1}));
|
assert(octree.node(7) == octree.locate({1, 1, 1}));
|
||||||
assert(octree.child(octree.root(), 6) == octree.locate({-1, 1, 1}));
|
|
||||||
assert(octree.child(octree.root(), 7) == octree.locate({1, 1, 1}));
|
|
||||||
|
|
||||||
// Points adjacent to the existing points might end up in different places
|
// Points adjacent to the existing points might end up in different places
|
||||||
assert(octree.child(octree.root(), 0) == octree.locate({-1.1, -1.1, -1.1}));
|
assert(octree.node(0) == octree.locate({-1.1, -1.1, -1.1}));
|
||||||
assert(octree.child(octree.root(), 1) == octree.locate({1.1, -1.1, -1.1}));
|
assert(octree.node(1) == octree.locate({1.1, -1.1, -1.1}));
|
||||||
assert(octree.child(octree.root(), 2) == octree.locate({-1.1, 1.1, -1.1}));
|
assert(octree.node(2) == octree.locate({-1.1, 1.1, -1.1}));
|
||||||
assert(octree.child(octree.child(octree.child(octree.root(), 3), 3), 3) ==
|
assert(octree.node(3, 3, 3) == octree.locate({1.1, 1.1, -1.1}));
|
||||||
octree.locate({1.1, 1.1, -1.1}));
|
assert(octree.node(4, 4, 4) == octree.locate({-1.1, -1.1, 1.1}));
|
||||||
assert(octree.child(octree.child(octree.child(octree.root(), 4), 4), 4) ==
|
assert(octree.node(5) == octree.locate({1.1, -1.1, 1.1}));
|
||||||
octree.locate({-1.1, -1.1, 1.1}));
|
assert(octree.node(6) == octree.locate({-1.1, 1.1, 1.1}));
|
||||||
assert(octree.child(octree.root(), 5) == octree.locate({1.1, -1.1, 1.1}));
|
assert(octree.node(7) == octree.locate({1.1, 1.1, 1.1}));
|
||||||
assert(octree.child(octree.root(), 6) == octree.locate({-1.1, 1.1, 1.1}));
|
|
||||||
assert(octree.child(octree.root(), 7) == octree.locate({1.1, 1.1, 1.1}));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,14 +79,14 @@ void test_4_points() {
|
||||||
// The octree should have been split once on the first level, and twice on the second
|
// The octree should have been split once on the first level, and twice on the second
|
||||||
Octree other(points, points.point_map());
|
Octree other(points, points.point_map());
|
||||||
other.split(other.root());
|
other.split(other.root());
|
||||||
other.split(other.child(other.root(), 3));
|
other.split(other.node(3));
|
||||||
other.split(other.child(other.root(), 7));
|
other.split(other.node(7));
|
||||||
assert(Octree::is_topology_equal(other, octree));
|
assert(Octree::is_topology_equal(other, octree));
|
||||||
assert(2 == octree.depth());
|
assert(2 == octree.depth());
|
||||||
|
|
||||||
// Applying another splitting criterion shouldn't reset the tree.
|
// Applying another splitting criterion shouldn't reset the tree.
|
||||||
octree.refine(Split_nth_child_of_root(2));
|
octree.refine(Split_nth_child_of_root(2));
|
||||||
other.split(other.child(other.root(), 2));
|
other.split(other.node(2));
|
||||||
assert(Octree::is_topology_equal(other, octree));
|
assert(Octree::is_topology_equal(other, octree));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ bool test_preorder_9_nodes() {
|
||||||
assert(*iter == octree.root());
|
assert(*iter == octree.root());
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
iter++;
|
iter++;
|
||||||
assert(*iter == octree.child(octree.root(), i));
|
assert(*iter == octree.node(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -77,7 +77,7 @@ bool test_level_9_nodes() {
|
||||||
// Check each item in the range
|
// Check each item in the range
|
||||||
auto iter = nodes.begin();
|
auto iter = nodes.begin();
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
assert(*iter == octree.child(octree.root(), i));
|
assert(*iter == octree.node(i));
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,28 +104,28 @@ bool test_preorder_25_nodes() {
|
||||||
auto iter = nodes.begin();
|
auto iter = nodes.begin();
|
||||||
assert(*iter == octree.root());
|
assert(*iter == octree.root());
|
||||||
iter++;
|
iter++;
|
||||||
assert(*iter == octree.child(octree.root(), 0));
|
assert(*iter == octree.node(0));
|
||||||
iter++;
|
iter++;
|
||||||
assert(*iter == octree.child(octree.root(), 1));
|
assert(*iter == octree.node(1));
|
||||||
iter++;
|
iter++;
|
||||||
assert((*iter == octree.child(octree.root(), 2)));
|
assert((*iter == octree.node(2)));
|
||||||
iter++;
|
iter++;
|
||||||
assert(*iter == octree.child(octree.root(), 3));
|
assert(*iter == octree.node(3));
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
iter++;
|
iter++;
|
||||||
assert(*iter == octree.child(octree.child(octree.root(), 3), i));
|
assert(*iter == octree.node(3, i));
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
assert((*iter == octree.child(octree.root(), 4)));
|
assert((*iter == octree.node(4)));
|
||||||
iter++;
|
iter++;
|
||||||
assert((*iter == octree.child(octree.root(), 5)));
|
assert((*iter == octree.node(5)));
|
||||||
iter++;
|
iter++;
|
||||||
assert((*iter == octree.child(octree.root(), 6)));
|
assert((*iter == octree.node(6)));
|
||||||
iter++;
|
iter++;
|
||||||
assert((*iter == octree.child(octree.root(), 7)));
|
assert((*iter == octree.node(7)));
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
iter++;
|
iter++;
|
||||||
assert(*iter == octree.child(octree.child(octree.root(), 7), i));
|
assert(*iter == octree.node(7, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue