00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __QUONPRDEFS_H_
00025 #define __QUONPRDEFS_H_
00026
00027 #include <map>
00028 #include <QuonDefs.h>
00029
00030
00031
00033
00034 enum PRDirection {
00035 NW, N, NE, E, SE, S, SW, W
00036 };
00037
00038 class QPRBoundingBox
00039 {
00040 public:
00041 QPRBoundingBox();
00042 QPRBoundingBox(Vector2D tl, Vector2D br);
00043 QPRBoundingBox(double tlx, double tly, double brx, double bry);
00044 QPRBoundingBox(Vector2D center, double width);
00045 void resize(double width);
00046 bool collide(const QPRBoundingBox box) const;
00047 bool collide(const Vector2D p) const;
00048 int getChildNum(const Vector2D p) const;
00049 QPRBoundingBox getQuadrant(int i) const;
00050 Vector2D shiftCenter(PRDirection direction) const;
00051 Vector2D tl, br, center;
00052 friend std::ostream& operator<<(std::ostream& Stream, const QPRBoundingBox& box);
00053 };
00054
00055 class PRTreeNode;
00056
00057 class QPRSite
00058 {
00059 public:
00060 QPRSite();
00061 Vector2D position;
00062 PRTreeNode* PRNode;
00063 QNeighborType type;
00064 NodeHandle address;
00065 double AOIwidth;
00066 bool dirty;
00067 bool alive;
00068 friend std::ostream& operator<<(std::ostream& Stream, const QPRSite& s);
00069 };
00070
00071 class PRTreeNode
00072 {
00073 public:
00074 PRTreeNode(QPRBoundingBox region, PRTreeNode* parent);
00075 QPRBoundingBox region;
00076 QPRSite* contents;
00077 PRTreeNode* parent;
00078 PRTreeNode* child[4];
00079 void add(QPRSite* site);
00080 void remove(const Vector2D p);
00081 QPRSite* findBindingNeighbor(const Vector2D p, int direction, int maxdepth);
00082 QPRSite* findNearestNeighbor(const Vector2D p) const;
00083 int getDepth(const Vector2D p, int depth = 0) const;
00084 int getDepth(const PRTreeNode* node, int depth = 0) const;
00085 friend std::ostream& operator<<(std::ostream& Stream, const PRTreeNode& node);
00086
00087 private:
00088 void collapse();
00089 std::ostream& print(std::ostream& Stream, int depth = 0) const;
00090 };
00091
00092 typedef std::map<OverlayKey, QPRSite*> PRSiteMap;
00093
00094 #endif