QuonPRDefs.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #ifndef __QUONPRDEFS_H_
00025 #define __QUONPRDEFS_H_
00026 
00027 #include <map>
00028 #include <QuonDefs.h>
00029 
00030 // constants for directions
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; //top left, bottom right, 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

Generated on Wed Mar 25 16:32:49 2009 for OverSim by  doxygen 1.5.5