#include <QuonPDefs.h>
Definition at line 70 of file QuonPDefs.h.
Public Member Functions | |
| PTreeNode (PTreeNode *parent) | |
| void | add (QPSite *site) |
| void | reset () |
| QPSite * | findNearestNeighbor (const Vector2D p) const |
Public Attributes | |
| QPSite * | contents |
| PTreeNode * | parent |
| PTreeNode * | child [4] |
Private Member Functions | |
| int | getQuadrant (const Vector2D p) const |
| PTreeNode::PTreeNode | ( | PTreeNode * | parent | ) |
| void PTreeNode::add | ( | QPSite * | site | ) |
Definition at line 147 of file QuonPDefs.cc.
Referenced by add(), and QuonP::classifySites().
00148 { 00149 if(contents == NULL) { 00150 contents = site; 00151 } 00152 else { 00153 int i = getQuadrant(site->position); 00154 if(child[i] == NULL) { 00155 child[i] = new PTreeNode(this); 00156 } 00157 child[i]->add(site); 00158 } 00159 }
| void PTreeNode::reset | ( | ) |
Definition at line 161 of file QuonPDefs.cc.
Referenced by QuonP::classifySites(), and reset().
00162 { 00163 for(int i=0; i<4; i++) { 00164 if(child[i] != NULL) { 00165 child[i]->reset(); 00166 delete child[i]; 00167 child[i] = NULL; 00168 } 00169 } 00170 contents = NULL; 00171 }
Definition at line 173 of file QuonPDefs.cc.
Referenced by QuonP::classifySites(), and findNearestNeighbor().
00174 { 00175 QPSite* temp = NULL; 00176 QPSite* best = contents; 00177 double distance = contents->position.distanceSqr(p); 00178 for(int i=0; i<4; i++) { 00179 if(child[i] != NULL) { 00180 temp = child[i]->findNearestNeighbor(p); 00181 if(temp->position.distanceSqr(p) < distance) { 00182 best = temp; 00183 distance = temp->position.distanceSqr(p); 00184 } 00185 } 00186 } 00187 return best; 00188 }
| int PTreeNode::getQuadrant | ( | const Vector2D | p | ) | const [private] |
Definition at line 190 of file QuonPDefs.cc.
Referenced by add().
00191 { 00192 int quadrant; 00193 if(p.x > contents->position.x) { 00194 if(p.y < contents->position.y) { 00195 quadrant = 2; 00196 } 00197 else { 00198 quadrant = 1; 00199 } 00200 } 00201 else { 00202 if(p.y < contents->position.y) { 00203 quadrant = 3; 00204 } 00205 else { 00206 quadrant = 0; 00207 } 00208 } 00209 return quadrant; 00210 }
Definition at line 74 of file QuonPDefs.h.
Referenced by add(), findNearestNeighbor(), getQuadrant(), PTreeNode(), and reset().
Definition at line 75 of file QuonPDefs.h.
Definition at line 76 of file QuonPDefs.h.
Referenced by add(), QuonP::classifySites(), findNearestNeighbor(), PTreeNode(), and reset().
1.5.5