VastDefs.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __DEFS_H_
00025 #define __DEFS_H_
00026
00027 #include <NodeHandle.h>
00028 #include <Vector2D.h>
00029 #include <math.h>
00030 #include <map>
00031 #include <set>
00032 #include <list>
00033 #include <vector>
00034
00035
00036 #define UNDEF 0
00037 #define THIS 1
00038 #define ENCLOSING 2
00039 #define NEIGHBOR 4
00040 #define BOUNDARY 8
00041 #define NEW 16
00042
00043 #define le 0
00044 #define re 1
00045
00046 #define DELETED -2
00047
00049
00053 class Site
00054 {
00055 public:
00056 Site();
00057 Vector2D coord;
00058 unsigned char type;
00059 bool innerEdge[3], outerEdge, isAdded;
00060 NodeHandle addr;
00061 simtime_t tstamp;
00062 int neighborCount;
00063 friend std::ostream& operator<<(std::ostream& Stream, const Site s);
00064 };
00065
00066 typedef std::map<NodeHandle, Site*> SiteMap;
00067 typedef std::set<Vector2D> PositionSet;
00068 typedef std::list<NodeHandle> StockList;
00069
00070 class Edge
00071 {
00072 public:
00073 Edge();
00074 double a, b, c;
00075 Site *ep[2];
00076 Site *reg[2];
00077 };
00078
00079 class Halfedge
00080 {
00081 public:
00082 Halfedge();
00083 Halfedge *ELleft, *ELright;
00084 Edge *ELedge;
00085 char ELpm;
00086 Site *vertex;
00087 double ystar;
00088 Halfedge *PQnext;
00089 };
00090
00092
00096 class HeapPQ
00097 {
00098 public:
00099 HeapPQ();
00100 void PQinitialize(int sqrt_nsites, double ymin, double deltay);
00101 void PQreset();
00102 void PQinsert(Halfedge *he, Site *v, double offset);
00103 void PQdelete(Halfedge *he);
00104 int PQbucket(Halfedge *he);
00105 int PQempty();
00106 Vector2D PQ_min();
00107 Halfedge* PQextractmin();
00108
00109 protected:
00110 int PQcount, PQmin, PQhashsize;
00111 double ymin, deltay;
00112 Halfedge *PQhash;
00113 };
00114
00116
00120 class Geometry
00121 {
00122 public:
00123 void initialize(double deltax, double deltay, Vector2D center, Vector2D old_pos, Vector2D new_pos, double radius);
00124 void reset();
00125 void setDebug(bool debugOutput);
00126 Edge* bisect(Site *s1, Site *s2);
00127 Site* intersect(Halfedge *el1, Halfedge *el2);
00128 void endpoint(Edge *e, int lr, Site *s);
00129 void processEdge(Edge *e);
00130 double dist(Site *s, Site *t);
00131
00132 protected:
00133 std::vector<Site*> SITEVector;
00134 std::vector<Edge*> EDGEVector;
00135
00136
00137 double deltax, deltay, sq_radius;
00138 Vector2D center[3];
00139 bool debugOutput, doDiscovery;
00140 bool intersectCircleLine(Vector2D start, Vector2D dir, Vector2D center, bool lowerBound, bool upperBound);
00141 bool intersectCircleSite(Site *s, Vector2D center);
00142 };
00143
00145
00149 class EdgeList
00150 {
00151 public:
00153 EdgeList();
00155
00161 void initialize(int sqrt_nsites, double xmin, double deltax, Site *bottomsite);
00163 void reset();
00165
00170 Halfedge* HEcreate(Edge *e, int pm);
00172
00176 void ELinsert(Halfedge *lb, Halfedge *new_he);
00178
00182 Halfedge* ELgethash(int b);
00184
00188 Halfedge* ELleftbnd(Vector2D *p);
00190
00193 void ELdelete(Halfedge *he);
00195
00199 Halfedge* ELright(Halfedge *he);
00201
00205 Halfedge* ELleft(Halfedge *he);
00207
00211 Site* leftreg(Halfedge *he);
00213
00217 Site* rightreg(Halfedge *he);
00219
00224 int right_of(Halfedge *el, Vector2D *p);
00225
00226 Halfedge *ELleftend, *ELrightend;
00227
00228 protected:
00229 int ELhashsize, totalsearch, ntry, HEcount;
00230 double xmin, deltax;
00231 Halfedge **ELhash;
00232 Halfedge **HEmemmap;
00233 Site *bottomsite;
00234 };
00235
00236 #endif