I went for the way of the canada guy, I enjoyed it.
However, now I have a severe problem in print function.
It crashes, after printing me all the nodes that are created. I mean I have the tree, all its nodes are printed and then it crashes.. What am I missing?
Here is the function:
Code:
/**
* Print the tree.
*/
void Quadtree::print() const
{
std::cout << "Octree" << std::endl;
print(root);
cout<<"I am out"<<endl;
}
/**
* Print the current node.
* @param node - the node to be printed.
*/
void Quadtree::print(const Pointer* node) const
{
/*
* Example: take an octree with one level of children.
* It will print, the first child first, then the root
* and then the rest of the children in increasing order.
*/
cout<<"line1"<<endl;
if(node)
{ cout<<"line2"<<endl;
if(node->type() == TYPE_INNER)
{ cout<<"line3"<<endl;
print(node->child()[0]);
cout<<"line4"<<endl;
std::cout << "Inner node with "
"split point " << *(node->split());
cout<<"line5"<<endl;
print(node->child()[1]);
cout<<"line6"<<endl;
print(node->child()[2]);
cout<<"line7"<<endl;
print(node->child()[3]);
cout<<"line8"<<endl;
print(node->child()[4]);
cout<<"line9"<<endl;
print(node->child()[5]);
cout<<"line10"<<endl;
print(node->child()[6]);
cout<<"line11"<<endl;
print(node->child()[7]);
cout<<"line12"<<endl;
}
if(node && !node->relevantH()->size())
{
cout<<"line13"<<endl;
std::cout << "Leaf with empty vector, thus no"
" interesting halfspaces can be found here." << std::endl;
}
else if(node)
{
cout<<"line14"<<endl;
std::cout << "Leaf with vector "; printVector(node->relevantH());
}
}
cout<<"line15"<<endl;
}
and my output
Code:
Octree
line1
line2
line3
line1
line2
line14
Leaf with vector 3
line15
line4
Inner node with split point 0.500000000500000,0.500000000500000,0.500000000500000
line5
line1
line2
line14
Leaf with vector 3
line15
line6
line1
line2
line14
Leaf with vector 3
line15
line7
line1
line2
line14
Leaf with vector 3
line15
line8
line1
line2
line14
Leaf with vector 3
line15
line9
line1
line2
line14
Leaf with vector 3
line15
line10
line1
line2
line14
Leaf with vector 3
line15
line11
line1
line2
line13
Leaf with empty vector, thus no interesting halfspaces can be found here.
line15
line12