VastDefs.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 __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 // constants for node types
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 typedef std::set<Vector2D> PositionSet;
00054 typedef std::set<NodeHandle> EnclosingSet;
00055 typedef std::list<NodeHandle> StockList;
00056 
00057 class Site
00058 {
00059     public:
00060         Site();
00061         Vector2D        coord;
00062         unsigned char   type;
00063         bool            innerEdge[3], outerEdge, isAdded;
00064         NodeHandle      addr;
00065         simtime_t       tstamp;
00066         int             neighborCount;
00067         EnclosingSet    enclosingSet;       // enhanced enclosing test
00068         EnclosingSet    oldEnclosingSet;    // enhanced enclosing test
00069         friend std::ostream& operator<<(std::ostream& Stream, const Site s);
00070 };
00071 
00072 typedef std::map<NodeHandle, Site*> SiteMap;
00073 
00074 class Edge
00075 {
00076     public:
00077         Edge();
00078         double  a, b, c;
00079         Site    *ep[2];
00080         Site    *reg[2];
00081 };
00082 
00083 class Halfedge
00084 {
00085     public:
00086         Halfedge();
00087         Halfedge    *ELleft, *ELright;
00088         Edge        *ELedge;
00089         char        ELpm;
00090         Site        *vertex;
00091         double      ystar;
00092         Halfedge    *PQnext;
00093 };
00094 
00096 
00100 class HeapPQ
00101 {
00102     public:
00103         HeapPQ();
00104         void PQinitialize(int sqrt_nsites, double ymin, double deltay);
00105         void PQreset();
00106         void PQinsert(Halfedge *he, Site *v, double offset);
00107         void PQdelete(Halfedge *he);
00108         int PQbucket(Halfedge *he);
00109         int PQempty();
00110         Vector2D PQ_min();
00111         Halfedge* PQextractmin();
00112 
00113     protected:
00114         int PQcount, PQmin, PQhashsize;
00115         double ymin, deltay;
00116         Halfedge *PQhash;
00117 };
00118 
00120 
00124 class Geometry
00125 {
00126     public:
00127         void initialize(double deltax, double deltay, Vector2D center, Vector2D old_pos, Vector2D new_pos, double radius);
00128         void reset();
00129         void setDebug(bool debugOutput);
00130         Edge* bisect(Site *s1, Site *s2);
00131         Site* intersect(Halfedge *el1, Halfedge *el2);
00132         void endpoint(Edge *e, int lr, Site *s);
00133         void processEdge(Edge *e);
00134         double dist(Site *s, Site *t);
00135 
00136     protected:
00137         std::vector<Site*> SITEVector;
00138         std::vector<Edge*> EDGEVector;
00139         //int SITEcount, EDGEcount;
00140 
00141         double deltax, deltay, sq_radius;
00142         Vector2D center[3];
00143         bool debugOutput, doDiscovery;
00144         bool intersectCircleLine(Vector2D start, Vector2D dir, Vector2D center, bool lowerBound, bool upperBound);
00145         bool intersectCircleSite(Site *s, Vector2D center);
00146 };
00147 
00149 
00153 class EdgeList
00154 {
00155     public:
00157         EdgeList();
00159 
00165         void initialize(int sqrt_nsites, double xmin, double deltax, Site *bottomsite);
00167         void reset();
00169 
00174         Halfedge* HEcreate(Edge *e, int pm);
00176 
00180         void ELinsert(Halfedge *lb, Halfedge *new_he);
00182 
00186         Halfedge* ELgethash(int b);
00188 
00192         Halfedge* ELleftbnd(Vector2D *p);
00194 
00197         void ELdelete(Halfedge *he);
00199 
00203         Halfedge* ELright(Halfedge *he);
00205 
00209         Halfedge* ELleft(Halfedge *he);
00211 
00215         Site* leftreg(Halfedge *he);
00217 
00221         Site* rightreg(Halfedge *he);
00223 
00228         int right_of(Halfedge *el, Vector2D *p);
00229 
00230         Halfedge *ELleftend, *ELrightend;
00231 
00232     protected:
00233         int ELhashsize, totalsearch, ntry, HEcount;
00234         double xmin, deltax;
00235         Halfedge **ELhash;
00236         Halfedge **HEmemmap;
00237         Site *bottomsite;
00238 };
00239 
00240 #endif
Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3