#include <VastDefs.h>
Public Member Functions | |
| EdgeList () | |
| Standard constructor. | |
| void | initialize (int sqrt_nsites, double xmin, double deltax, Site *bottomsite) |
| Initializes the list before building the diagram. | |
| void | reset () |
| Resets the list for further use. | |
| Halfedge * | HEcreate (Edge *e, int pm) |
| Creates a halfedge from a given edge. | |
| void | ELinsert (Halfedge *lb, Halfedge *new_he) |
| Inserts a new halfedge to the list. | |
| Halfedge * | ELgethash (int b) |
| Get an entry from the list by number. | |
| Halfedge * | ELleftbnd (Vector2D *p) |
| Get an entry from the list by point. | |
| void | ELdelete (Halfedge *he) |
| Delete an entry from the list. | |
| Halfedge * | ELright (Halfedge *he) |
| Get right neighbor of an edge. | |
| Halfedge * | ELleft (Halfedge *he) |
| Get left neighbor of an edge. | |
| Site * | leftreg (Halfedge *he) |
| Get site left of an edge. | |
| Site * | rightreg (Halfedge *he) |
| Get site right of an edge. | |
| int | right_of (Halfedge *el, Vector2D *p) |
| Determines if a point is right of an halfedge. | |
Public Attributes | |
| Halfedge * | ELleftend |
| Halfedge * | ELrightend |
Protected Attributes | |
| int | ELhashsize |
| int | totalsearch |
| int | ntry |
| int | HEcount |
| double | xmin |
| double | deltax |
| Halfedge ** | ELhash |
| Halfedge ** | HEmemmap |
| Site * | bottomsite |
Maintains the edges found while building the voronoi diagram.
Definition at line 149 of file VastDefs.h.
| EdgeList::EdgeList | ( | ) |
Standard constructor.
Definition at line 396 of file VastDefs.cc.
00397 { 00398 ELhash = NULL; 00399 }
| void EdgeList::ELdelete | ( | Halfedge * | he | ) |
| Halfedge * EdgeList::ELgethash | ( | int | b | ) |
Get an entry from the list by number.
@param b An integer. @return Returns halfedge number b.
Definition at line 458 of file VastDefs.cc.
Referenced by ELleftbnd().
00459 { 00460 Halfedge *he; 00461 00462 if(b < 0 || b >= ELhashsize) return NULL; 00463 he = ELhash[b]; 00464 if(he == NULL || he->ELedge != (Edge*)DELETED) return he; 00465 00466 /* Hash table points to deleted half edge. */ 00467 ELhash[b] = NULL; 00468 return NULL; 00469 }
Inserts a new halfedge to the list.
@param lb lower bound for this edge. @param new_he A new halfedge to be added to the list.
Definition at line 449 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00450 { 00451 new_he->ELleft = lb; 00452 new_he->ELright = lb->ELright; 00453 (lb->ELright)->ELleft = new_he; 00454 lb->ELright = new_he; 00455 }
Get left neighbor of an edge.
@param he A halfedge. @return Returns left neighbor of halfedge he.
Definition at line 558 of file VastDefs.cc.
Referenced by Vast::buildVoronoi(), and ELinsert().
00559 { 00560 return he->ELleft; 00561 }
Get an entry from the list by point.
@param p A pointer to a point. @return Returns halfedge nearest to p.
Definition at line 514 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00515 { 00516 int i, bucket; 00517 Halfedge *he; 00518 00519 /* Use hash table to get close to desired halfedge */ 00520 bucket = (int)((p->x - xmin) / deltax) * ELhashsize; 00521 if(bucket < 0) bucket =0; 00522 if(bucket >= ELhashsize) bucket = ELhashsize - 1; 00523 he = ELgethash(bucket); 00524 if(he == NULL) { 00525 for(i=1; 1; i++) { 00526 if((he = ELgethash(bucket-i)) != NULL) break; 00527 if((he = ELgethash(bucket+i)) != NULL) break; 00528 } 00529 totalsearch++; 00530 } 00531 ntry++; 00532 /* Now search linear list of halfedges for the corect one */ 00533 if(he == ELleftend || (he != ELrightend && right_of(he, p))) { 00534 do {he = he->ELright;} while(he != ELrightend && right_of(he, p)); 00535 he = he->ELleft; 00536 } 00537 else do {he = he->ELleft;} while(he != ELleftend && !right_of(he, p)); 00538 00539 /* Update hash table and reference counts */ 00540 if(bucket > 0 && bucket < ELhashsize-1) { 00541 ELhash[bucket] = he; 00542 } 00543 return he; 00544 }
Get right neighbor of an edge.
@param he A halfedge. @return Returns right neighbor of halfedge he.
Definition at line 553 of file VastDefs.cc.
Referenced by Vast::buildVoronoi(), and ELdelete().
00554 { 00555 return he->ELright; 00556 }
Creates a halfedge from a given edge.
@param e A pointer to an edge. @param pm Determins wether the halfedge represents the left or right "side" of the given edge (le/re). @return Returns the created halfedge.
Definition at line 433 of file VastDefs.cc.
Referenced by Vast::buildVoronoi(), and initialize().
00434 { 00435 Halfedge *answer = new Halfedge; 00436 answer->ELedge = e; 00437 answer->ELpm = pm; 00438 00439 HEmemmap[HEcount++] = answer; 00440 if(HEcount%ELhashsize == 0) { 00441 Halfedge **Temp = new Halfedge*[HEcount + ELhashsize]; 00442 for(int i=0; i<HEcount; i++) Temp[i] = HEmemmap[i]; 00443 delete[] HEmemmap; 00444 HEmemmap = Temp; 00445 } 00446 return answer; 00447 }
| void EdgeList::initialize | ( | int | sqrt_nsites, | |
| double | xmin, | |||
| double | deltax, | |||
| Site * | bottomsite | |||
| ) |
Initializes the list before building the diagram.
@param sqrt_nsites Squareroot of the total number of sites. @param xmin Min x coordinate of all sites. @param deltax xmin+deltax is max x coordinate of all sites. @param bottomsite A pointer to the bottom site of the sites list.
Definition at line 401 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00402 { 00403 int i; 00404 00405 HEcount = 0; 00406 ELhashsize = 2 * sqrt_nsites; 00407 00408 HEmemmap = new Halfedge*[ELhashsize]; 00409 00410 ELhash = new Halfedge*[ELhashsize]; 00411 for(i=0; i<ELhashsize; i++) ELhash[i] = NULL; 00412 ELleftend = HEcreate(NULL, 0); 00413 ELrightend = HEcreate(NULL, 0); 00414 ELleftend->ELleft = NULL; 00415 ELleftend->ELright = ELrightend; 00416 ELrightend->ELleft = ELleftend; 00417 ELrightend->ELright = NULL; 00418 ELhash[0] = ELleftend; 00419 ELhash[ELhashsize-1] = ELrightend; 00420 this->xmin = xmin; 00421 this->deltax = deltax; 00422 this->bottomsite = bottomsite; 00423 }
Get site left of an edge.
@param he A halfedge. @return Returns site left of halfedge he.
Definition at line 564 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00565 { 00566 if(he->ELedge == NULL) return(bottomsite); 00567 return he->ELpm == le ? he->ELedge->reg[le] : he->ELedge->reg[re]; 00568 }
| void EdgeList::reset | ( | ) |
Resets the list for further use.
Definition at line 425 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00426 { 00427 delete[] ELhash; 00428 // free all allocated memory 00429 for(int i=0; i<HEcount; i++) delete HEmemmap[i]; 00430 delete[] HEmemmap; 00431 }
Determines if a point is right of an halfedge.
@param he A halfedge. @param p A point. @return Returns 1 if point p is right of halfedge el, 0 otherwise.
Definition at line 472 of file VastDefs.cc.
Referenced by ELleftbnd().
00473 { 00474 Edge *e; 00475 Site *topsite; 00476 int right_of_site, above, fast; 00477 double dxp, dyp, dxs, t1, t2, t3, yl; 00478 00479 e = el->ELedge; 00480 topsite = e->reg[1]; 00481 right_of_site = p->x > topsite->coord.x; 00482 if(right_of_site && el->ELpm == le) return 1; 00483 if(!right_of_site && el->ELpm == re) return 0; 00484 00485 if(e->a == 1.0) { 00486 dyp = p->y - topsite->coord.y; 00487 dxp = p->x - topsite->coord.x; 00488 fast = 0; 00489 if((!right_of_site && (e->b < 0.0)) || (right_of_site && (e->b >= 0.0))) { 00490 above = dyp >= e->b * dxp; 00491 fast = above; 00492 } 00493 else { 00494 above = p->x + p->y * e->b > e->c; 00495 if(e->b < 0.0) above = !above; 00496 if(!above) fast = 1; 00497 } 00498 if(!fast) { 00499 dxs = topsite->coord.x - (e->reg[0])->coord.x; 00500 above = e->b * (dxp*dxp - dyp*dyp) < dxs * dyp * (1.0 + 2.0*dxp/dxs + e->b*e->b); 00501 if(e->b < 0.0) above = !above; 00502 } 00503 } 00504 else { 00505 yl = e->c - e->a * p->x; 00506 t1 = p->y - yl; 00507 t2 = p->x - topsite->coord.x; 00508 t3 = yl - topsite->coord.y; 00509 above = t1*t1 > t2*t2 + t3*t3; 00510 } 00511 return el->ELpm == le ? above : !above; 00512 }
Get site right of an edge.
@param he A halfedge. @return Returns site right of halfedge he.
Definition at line 570 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00571 { 00572 if(he->ELedge == NULL) return(bottomsite); 00573 return he->ELpm == le ? he->ELedge->reg[re] : he->ELedge->reg[le]; 00574 }
Site* EdgeList::bottomsite [protected] |
double EdgeList::deltax [protected] |
Halfedge** EdgeList::ELhash [protected] |
Definition at line 231 of file VastDefs.h.
Referenced by EdgeList(), ELgethash(), ELleftbnd(), initialize(), and reset().
int EdgeList::ELhashsize [protected] |
Definition at line 229 of file VastDefs.h.
Referenced by ELgethash(), ELleftbnd(), HEcreate(), and initialize().
Definition at line 226 of file VastDefs.h.
Referenced by Vast::buildVoronoi(), ELleftbnd(), and initialize().
Definition at line 226 of file VastDefs.h.
Referenced by Vast::buildVoronoi(), ELleftbnd(), and initialize().
int EdgeList::HEcount [protected] |
Halfedge** EdgeList::HEmemmap [protected] |
int EdgeList::ntry [protected] |
int EdgeList::totalsearch [protected] |
double EdgeList::xmin [protected] |
1.5.8