42 if(s.
type &
UNDEF) Stream <<
"Undefined ";
47 if(s.
type &
NEW) Stream <<
"Discovered ";
48 return Stream <<
" IP: " << s.
addr.
getIp();
127 if(bucket < 0) bucket = 0;
164 this->center[1] = old_pos;
165 this->center[2] = new_pos;
166 if((old_pos.
x != new_pos.
x) || (old_pos.
y != new_pos.
y))
doDiscovery =
true;
173 for(std::vector<Site*>::iterator itTemp =
SITEVector.begin(); itTemp !=
SITEVector.end(); ++itTemp) {
176 for(std::vector<Edge*>::iterator itTemp =
EDGEVector.begin(); itTemp !=
EDGEVector.end(); ++itTemp) {
194 sq_distance = temp.
x*temp.
x + temp.
y*temp.
y;
195 return sq_distance <
sq_radius ?
true :
false;
201 double DirDotStartMinusCenter, DirSq, StartMinusCenterSq, discriminant;
202 StartMinusCenter.
x = start.
x - center.
x;
203 StartMinusCenter.
y = start.
y - center.
y;
204 StartMinusCenterSq = StartMinusCenter.
x * StartMinusCenter.
x + StartMinusCenter.
y * StartMinusCenter.
y;
206 DirDotStartMinusCenter = dir.
x * StartMinusCenter.
x + dir.
y * StartMinusCenter.
y;
207 DirSq = dir.
x * dir.
x + dir.
y * dir.
y;
209 discriminant = DirDotStartMinusCenter * DirDotStartMinusCenter - DirSq * (StartMinusCenterSq -
sq_radius);
211 if(discriminant <= 0.0f)
return false;
212 else if(lowerBound) {
213 double s = (-DirDotStartMinusCenter - sqrtf(discriminant)) / DirSq;
214 if(s < 0.0f)
return false;
215 else if(upperBound && s > 1.0f)
return false;
222 bool leftEndpoint_In[3], rightEndpoint_In[3];
227 for(i = 0; i < numTest; i++) {
229 else leftEndpoint_In[i] =
false;
231 else rightEndpoint_In[i] =
false;
233 for(i = 0; i < numTest; i++) {
234 if(leftEndpoint_In[i] || rightEndpoint_In[i]) {
239 if(!leftEndpoint_In[0] || !rightEndpoint_In[0]) {
243 for(i = 0; i < numTest; i++) {
244 if(!(leftEndpoint_In[i] || rightEndpoint_In[i])) {
245 bool lineTest =
false;
264 if(t_dir.
x >= 0.0f) {
274 t_start.
x = e->
c / e->
a;
279 t_start.
y = e->
c / e->
b;
300 if(
debugOutput) EV <<
"[Geometry::processEdge()]\n"
307 if(
debugOutput) EV <<
"[Geometry::processEdge()]\n"
315 double dx, dy, adx, ady;
320 newedge->
reg[0] = s1;
321 newedge->
reg[1] = s2;
322 newedge->
ep[0] = NULL;
323 newedge->
ep[1] = NULL;
327 adx = dx > 0 ? dx : -dx;
328 ady = dy > 0 ? dy : -dy;
329 newedge->
c = s1->
coord.
x * dx + s1->
coord.
y * dy + (dx*dx + dy*dy)*0.5;
349 double d, xint, yint;
355 if(e1 == NULL || e2 == NULL)
return NULL;
356 if(e1->
reg[1] == e2->
reg[1])
return NULL;
358 d = e1->
a * e2->
b - e1->
b * e2->
a;
359 if(-1.0e-10 < d && d < 1.0e-10)
return NULL;
361 xint = (e1->
c * e2->
b - e2->
c * e1->
b)/d;
362 yint = (e2->
c * e1->
a - e1->
c * e2->
a)/d;
373 right_of_site = xint >= e->
reg[1]->
coord.
x;
374 if((right_of_site && el->
ELpm ==
le) || (!right_of_site && el->
ELpm ==
re))
return NULL;
388 if(e->
ep[
re-lr] == NULL)
return;
397 return sqrt(dx*dx + dy*dy);
480 int right_of_site, above, fast;
481 double dxp, dyp, dxs, t1, t2, t3, yl;
485 right_of_site = p->
x > topsite->
coord.
x;
486 if(right_of_site && el->
ELpm ==
le)
return 1;
487 if(!right_of_site && el->
ELpm ==
re)
return 0;
493 if((!right_of_site && (e->
b < 0.0)) || (right_of_site && (e->
b >= 0.0))) {
494 above = dyp >= e->
b * dxp;
498 above = p->
x + p->
y * e->
b > e->
c;
499 if(e->
b < 0.0) above = !above;
503 dxs = topsite->
coord.
x - (e->
reg[0])->coord.x;
504 above = e->
b * (dxp*dxp - dyp*dyp) < dxs * dyp * (1.0 + 2.0*dxp/dxs + e->
b*e->
b);
505 if(e->
b < 0.0) above = !above;
509 yl = e->
c - e->
a * p->
x;
512 t3 = yl - topsite->
coord.
y;
513 above = t1*t1 > t2*t2 + t3*t3;
515 return el->
ELpm ==
le ? above : !above;
525 if(bucket < 0) bucket =0;
530 if((he =
ELgethash(bucket-i)) != NULL)
break;
531 if((he =
ELgethash(bucket+i)) != NULL)
break;