예제 #1
0
 void do_insert_data(T data, Envelope<double> const& box, node * n, unsigned int& depth)
 {
    if (++depth >= max_depth_)
    {
       n->cont_.push_back(data);
    }
    else 
    {
       Envelope<double> const& node_extent = n->extent();
       Envelope<double> ext[4];
       split_box(node_extent,ext);		
       for (int i=0;i<4;++i)
       {
          if (ext[i].contains(box))
          {
             if (!n->children_[i])
             {
                nodes_.push_back(new node(ext[i]));
                n->children_[i]=&nodes_.back();
             }
             do_insert_data(data,box,n->children_[i],depth);
             return;
          }
       }
       n->cont_.push_back(data);
    }
 }
예제 #2
0
 void clear () 
 {
    Envelope<double> ext = root_->extent_;
    nodes_.clear();
    nodes_.push_back(new node(ext));
    root_ = &nodes_[0];
 }
예제 #3
0
 explicit quad_tree(Envelope<double> const& ext, 
                    unsigned int max_depth = 8, 
                    double ratio = 0.55) 
    : max_depth_(max_depth),
      ratio_(ratio)
 {
    nodes_.push_back(new node(ext));
    root_ = &nodes_[0];
 }
예제 #4
0
inline void tree::add_child( node* n )
{
    nodes.push_back( n );
}