OverSim
VastDefs.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #ifndef __DEFS_H_
25 #define __DEFS_H_
26 
27 #include <NodeHandle.h>
28 #include <Vector2D.h>
29 #include <math.h>
30 #include <map>
31 #include <set>
32 #include <list>
33 #include <vector>
34 
35 // constants for node types
36 #define UNDEF 0
37 #define THIS 1
38 #define ENCLOSING 2
39 #define NEIGHBOR 4
40 #define BOUNDARY 8
41 #define NEW 16
42 
43 #define le 0
44 #define re 1
45 
46 #define DELETED -2
47 
49 
53 typedef std::set<Vector2D> PositionSet;
54 typedef std::set<NodeHandle> EnclosingSet;
55 typedef std::list<NodeHandle> StockList;
56 
57 class Site
58 {
59  public:
60  Site();
62  unsigned char type;
65  simtime_t tstamp;
67  EnclosingSet enclosingSet; // enhanced enclosing test
68  EnclosingSet oldEnclosingSet; // enhanced enclosing test
69  friend std::ostream& operator<<(std::ostream& Stream, const Site s);
70 };
71 
72 typedef std::map<NodeHandle, Site*> SiteMap;
73 
74 class Edge
75 {
76  public:
77  Edge();
78  double a, b, c;
79  Site *ep[2];
80  Site *reg[2];
81 };
82 
83 class Halfedge
84 {
85  public:
86  Halfedge();
89  char ELpm;
91  double ystar;
93 };
94 
96 
100 class HeapPQ
101 {
102  public:
103  HeapPQ();
104  void PQinitialize(int sqrt_nsites, double ymin, double deltay);
105  void PQreset();
106  void PQinsert(Halfedge *he, Site *v, double offset);
107  void PQdelete(Halfedge *he);
108  int PQbucket(Halfedge *he);
109  int PQempty();
110  Vector2D PQ_min();
112 
113  protected:
115  double ymin, deltay;
117 };
118 
120 
124 class Geometry
125 {
126  public:
127  void initialize(double deltax, double deltay, Vector2D center, Vector2D old_pos, Vector2D new_pos, double radius);
128  void reset();
129  void setDebug(bool debugOutput);
130  Edge* bisect(Site *s1, Site *s2);
131  Site* intersect(Halfedge *el1, Halfedge *el2);
132  void endpoint(Edge *e, int lr, Site *s);
133  void processEdge(Edge *e);
134  double dist(Site *s, Site *t);
135 
136  protected:
137  std::vector<Site*> SITEVector;
138  std::vector<Edge*> EDGEVector;
139  //int SITEcount, EDGEcount;
140 
142  Vector2D center[3];
144  bool intersectCircleLine(Vector2D start, Vector2D dir, Vector2D center, bool lowerBound, bool upperBound);
145  bool intersectCircleSite(Site *s, Vector2D center);
146 };
147 
149 
153 class EdgeList
154 {
155  public:
157  EdgeList();
159 
165  void initialize(int sqrt_nsites, double xmin, double deltax, Site *bottomsite);
167  void reset();
169 
174  Halfedge* HEcreate(Edge *e, int pm);
176 
180  void ELinsert(Halfedge *lb, Halfedge *new_he);
182 
186  Halfedge* ELgethash(int b);
188 
194 
197  void ELdelete(Halfedge *he);
199 
203  Halfedge* ELright(Halfedge *he);
205 
209  Halfedge* ELleft(Halfedge *he);
211 
215  Site* leftreg(Halfedge *he);
217 
221  Site* rightreg(Halfedge *he);
223 
228  int right_of(Halfedge *el, Vector2D *p);
229 
231 
232  protected:
234  double xmin, deltax;
238 };
239 
240 #endif