Public Member Functions

ANNbd_shrink Class Reference

#include <bd_tree.h>

Inheritance diagram for ANNbd_shrink:
Inheritance graph
[legend]
Collaboration diagram for ANNbd_shrink:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ANNbd_shrink (int nb, ANNorthHSArray bds, ANNkd_ptr ic=NULL, ANNkd_ptr oc=NULL)
 ~ANNbd_shrink ()
virtual void getStats (int dim, ANNkdStats &st, ANNorthRect &bnd_box)
virtual void print (int level, ostream &out)
virtual void dump (ostream &out)
virtual void ann_search (ANNdist)
virtual void ann_pri_search (ANNdist)
virtual void ann_FR_search (ANNdist)

Detailed Description

Definition at line 61 of file bd_tree.h.


Constructor & Destructor Documentation

ANNbd_shrink::ANNbd_shrink ( int  nb,
ANNorthHSArray  bds,
ANNkd_ptr  ic = NULL,
ANNkd_ptr  oc = NULL 
) [inline]

Definition at line 67 of file bd_tree.h.

References ANN_IN, and ANN_OUT.

                {
                        n_bnds                  = nb;                           // cutting dimension
                        bnds                    = bds;                          // assign bounds
                        child[ANN_IN]   = ic;                           // set children
                        child[ANN_OUT]  = oc;
                }
ANNbd_shrink::~ANNbd_shrink (  ) [inline]

Definition at line 78 of file bd_tree.h.

References ANN_IN, ANN_OUT, and KD_TRIVIAL.

                {
                        if (child[ANN_IN]!= NULL && child[ANN_IN]!=  KD_TRIVIAL) 
                                delete child[ANN_IN];
                        if (child[ANN_OUT]!= NULL&& child[ANN_OUT]!= KD_TRIVIAL) 
                                delete child[ANN_OUT];
                        if (bnds != NULL)
                                delete [] bnds;                 // delete bounds
                }

Member Function Documentation

void ANNbd_shrink::ann_FR_search ( ANNdist  box_dist ) [virtual]

Implements ANNkd_node.

Definition at line 39 of file bd_fix_rad_search.cpp.

References ANN_FLOP, ANNkd_node::ann_FR_search(), ANN_IN, ANN_OUT, ANN_SHR, ANN_SUM, ANNkdFRQ, ANNmaxPtsVisited, ANNptsVisited, and QuadProgPP::dist().

{
                                                                                                // check dist calc term cond.
        if (ANNmaxPtsVisited != 0 && ANNptsVisited > ANNmaxPtsVisited) return;

        ANNdist inner_dist = 0;                                         // distance to inner box
        for (int i = 0; i < n_bnds; i++) {                      // is query point in the box?
                if (bnds[i].out(ANNkdFRQ)) {                    // outside this bounding side?
                                                                                                // add to inner distance
                        inner_dist = (ANNdist) ANN_SUM(inner_dist, bnds[i].dist(ANNkdFRQ));
                }
        }
        if (inner_dist <= box_dist) {                           // if inner box is closer
                child[ANN_IN]->ann_FR_search(inner_dist);// search inner child first
                child[ANN_OUT]->ann_FR_search(box_dist);// ...then outer child
        }
        else {                                                                          // if outer box is closer
                child[ANN_OUT]->ann_FR_search(box_dist);// search outer child first
                child[ANN_IN]->ann_FR_search(inner_dist);// ...then outer child
        }
        ANN_FLOP(3*n_bnds)                                                      // increment floating ops
        ANN_SHR(1)                                                                      // one more shrinking node
}
void ANNbd_shrink::ann_pri_search ( ANNdist  box_dist ) [virtual]

Implements ANNkd_node.

Definition at line 39 of file bd_pr_search.cpp.

References ANN_FLOP, ANN_IN, ANN_OUT, ANNkd_node::ann_pri_search(), ANN_SHR, ANN_SUM, ANNprBoxPQ, ANNprQ, QuadProgPP::dist(), ANNpr_queue::insert(), and KD_TRIVIAL.

{
        ANNdist inner_dist = 0;                                         // distance to inner box
        for (int i = 0; i < n_bnds; i++) {                      // is query point in the box?
                if (bnds[i].out(ANNprQ)) {                              // outside this bounding side?
                                                                                                // add to inner distance
                        inner_dist = (ANNdist) ANN_SUM(inner_dist, bnds[i].dist(ANNprQ));
                }
        }
        if (inner_dist <= box_dist) {                           // if inner box is closer
                if (child[ANN_OUT] != KD_TRIVIAL)               // enqueue outer if not trivial
                        ANNprBoxPQ->insert(box_dist,child[ANN_OUT]);
                                                                                                // continue with inner child
                child[ANN_IN]->ann_pri_search(inner_dist);
        }
        else {                                                                          // if outer box is closer
                if (child[ANN_IN] != KD_TRIVIAL)                // enqueue inner if not trivial
                        ANNprBoxPQ->insert(inner_dist,child[ANN_IN]);
                                                                                                // continue with outer child
                child[ANN_OUT]->ann_pri_search(box_dist);
        }
        ANN_FLOP(3*n_bnds)                                                      // increment floating ops
        ANN_SHR(1)                                                                      // one more shrinking node
}
void ANNbd_shrink::ann_search ( ANNdist  box_dist ) [virtual]

Implements ANNkd_node.

Definition at line 39 of file bd_search.cpp.

References ANN_FLOP, ANN_IN, ANN_OUT, ANNkd_node::ann_search(), ANN_SHR, ANN_SUM, ANNkdQ, ANNmaxPtsVisited, ANNptsVisited, and QuadProgPP::dist().

{
                                                                                                // check dist calc term cond.
        if (ANNmaxPtsVisited != 0 && ANNptsVisited > ANNmaxPtsVisited) return;

        ANNdist inner_dist = 0;                                         // distance to inner box
        for (int i = 0; i < n_bnds; i++) {                      // is query point in the box?
                if (bnds[i].out(ANNkdQ)) {                              // outside this bounding side?
                                                                                                // add to inner distance
                        inner_dist = (ANNdist) ANN_SUM(inner_dist, bnds[i].dist(ANNkdQ));
                }
        }
        if (inner_dist <= box_dist) {                           // if inner box is closer
                child[ANN_IN]->ann_search(inner_dist);  // search inner child first
                child[ANN_OUT]->ann_search(box_dist);   // ...then outer child
        }
        else {                                                                          // if outer box is closer
                child[ANN_OUT]->ann_search(box_dist);   // search outer child first
                child[ANN_IN]->ann_search(inner_dist);  // ...then outer child
        }
        ANN_FLOP(3*n_bnds)                                                      // increment floating ops
        ANN_SHR(1)                                                                      // one more shrinking node
}
void ANNbd_shrink::dump ( ostream &  out ) [virtual]

Implements ANNkd_node.

Definition at line 161 of file kd_dump.cpp.

References ANN_IN, and ANN_OUT.

{
        out << "shrink " << n_bnds << "\n";
        for (int j = 0; j < n_bnds; j++) {
                out << bnds[j].cd << " " << bnds[j].cv << " " << bnds[j].sd << "\n";
        }
        child[ANN_IN]->dump(out);                       // print in-child
        child[ANN_OUT]->dump(out);                      // print out-child
}
void ANNbd_shrink::getStats ( int  dim,
ANNkdStats st,
ANNorthRect bnd_box 
) [virtual]

Implements ANNkd_node.

Definition at line 71 of file bd_tree.cpp.

References ANN_IN, ANN_OUT, annBnds2Box(), ANNkdStats::depth, ANNkd_node::getStats(), ANNkdStats::merge(), ANNkdStats::n_shr, and ANNkdStats::reset().

{
        ANNkdStats ch_stats;                                            // stats for children
        ANNorthRect inner_box(dim);                                     // inner box of shrink

        annBnds2Box(bnd_box,                                            // enclosing box
                                dim,                                                    // dimension
                                n_bnds,                                                 // number of bounds
                                bnds,                                                   // bounds array
                                inner_box);                                             // inner box (modified)
                                                                                                // get stats for inner child
        ch_stats.reset();                                                       // reset
        child[ANN_IN]->getStats(dim, ch_stats, inner_box);
        st.merge(ch_stats);                                                     // merge them
                                                                                                // get stats for outer child
        ch_stats.reset();                                                       // reset
        child[ANN_OUT]->getStats(dim, ch_stats, bnd_box);
        st.merge(ch_stats);                                                     // merge them

        st.depth++;                                                                     // increment depth
        st.n_shr++;                                                                     // increment number of shrinks
}
void ANNbd_shrink::print ( int  level,
ostream &  out 
) [virtual]

Implements ANNkd_node.

Definition at line 41 of file bd_tree.cpp.

References ANN_IN, ANN_OUT, ANNorthHalfSpace::cd, ANNkd_node::print(), and ANNorthHalfSpace::sd.

{
        child[ANN_OUT]->print(level+1, out);            // print out-child

        out << "    ";
        for (int i = 0; i < level; i++)                         // print indentation
                out << "..";
        out << "Shrink";
        for (int j = 0; j < n_bnds; j++) {                      // print sides, 2 per line
                if (j % 2 == 0) {
                        out << "\n";                                            // newline and indentation
                        for (int i = 0; i < level+2; i++) out << "  ";
                }
                out << "  ([" << bnds[j].cd << "]"
                         << (bnds[j].sd > 0 ? ">=" : "< ")
                         << bnds[j].cv << ")";
        }
        out << "\n";

        child[ANN_IN]->print(level+1, out);                     // print in-child
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines