EdgeList Class Reference

EdgeList class. More...

#include <VastDefs.h>

List of all members.

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.
HalfedgeHEcreate (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.
HalfedgeELgethash (int b)
 Get an entry from the list by number.
HalfedgeELleftbnd (Vector2D *p)
 Get an entry from the list by point.
void ELdelete (Halfedge *he)
 Delete an entry from the list.
HalfedgeELright (Halfedge *he)
 Get right neighbor of an edge.
HalfedgeELleft (Halfedge *he)
 Get left neighbor of an edge.
Siteleftreg (Halfedge *he)
 Get site left of an edge.
Siterightreg (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

HalfedgeELleftend
HalfedgeELrightend

Protected Attributes

int ELhashsize
int totalsearch
int ntry
int HEcount
double xmin
double deltax
Halfedge ** ELhash
Halfedge ** HEmemmap
Sitebottomsite

Detailed Description

EdgeList class.

Maintains the edges found while building the voronoi diagram.

Definition at line 153 of file VastDefs.h.


Constructor & Destructor Documentation

EdgeList::EdgeList (  ) 

Standard constructor.

Definition at line 400 of file VastDefs.cc.

00401 {
00402     ELhash = NULL;
00403 }


Member Function Documentation

void EdgeList::ELdelete ( Halfedge he  ) 

Delete an entry from the list.

@param he Halfedge to be removed.

Definition at line 550 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00551 {
00552     (he->ELleft)->ELright = he->ELright;
00553     (he->ELright)->ELleft = he->ELleft;
00554     he->ELedge = (Edge*)DELETED;
00555 }

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 462 of file VastDefs.cc.

Referenced by ELleftbnd().

00463 {
00464     Halfedge *he;
00465 
00466     if(b < 0 || b >= ELhashsize) return NULL;
00467     he = ELhash[b];
00468     if(he == NULL || he->ELedge != (Edge*)DELETED) return he;
00469 
00470     /* Hash table points to deleted half edge. */
00471     ELhash[b] = NULL;
00472     return NULL;
00473 }

void EdgeList::ELinsert ( Halfedge lb,
Halfedge new_he 
)

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 453 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00454 {
00455     new_he->ELleft = lb;
00456     new_he->ELright = lb->ELright;
00457     (lb->ELright)->ELleft = new_he;
00458     lb->ELright = new_he;
00459 }

Halfedge * EdgeList::ELleft ( Halfedge he  ) 

Get left neighbor of an edge.

@param he A halfedge. @return Returns left neighbor of halfedge he.

Definition at line 562 of file VastDefs.cc.

Referenced by Vast::buildVoronoi(), and ELinsert().

00563 {
00564     return he->ELleft;
00565 }

Halfedge * EdgeList::ELleftbnd ( Vector2D p  ) 

Get an entry from the list by point.

@param p A pointer to a point. @return Returns halfedge nearest to p.

Definition at line 518 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00519 {
00520     int i, bucket;
00521     Halfedge *he;
00522 
00523     /* Use hash table to get close to desired halfedge */
00524     bucket = (int)((p->x - xmin) / deltax) * ELhashsize;
00525     if(bucket < 0) bucket =0;
00526     if(bucket >= ELhashsize) bucket = ELhashsize - 1;
00527     he = ELgethash(bucket);
00528     if(he == NULL) {
00529         for(i=1; 1; i++) {
00530             if((he = ELgethash(bucket-i)) != NULL) break;
00531             if((he = ELgethash(bucket+i)) != NULL) break;
00532         }
00533     totalsearch++;
00534     }
00535     ntry++;
00536     /* Now search linear list of halfedges for the corect one */
00537     if(he == ELleftend  || (he != ELrightend && right_of(he, p))) {
00538         do {he = he->ELright;} while(he != ELrightend && right_of(he, p));
00539         he = he->ELleft;
00540     }
00541     else do {he = he->ELleft;} while(he != ELleftend && !right_of(he, p));
00542 
00543     /* Update hash table and reference counts */
00544     if(bucket > 0 && bucket < ELhashsize-1) {
00545         ELhash[bucket] = he;
00546     }
00547     return he;
00548 }

Halfedge * EdgeList::ELright ( Halfedge he  ) 

Get right neighbor of an edge.

@param he A halfedge. @return Returns right neighbor of halfedge he.

Definition at line 557 of file VastDefs.cc.

Referenced by Vast::buildVoronoi(), and ELdelete().

00558 {
00559     return he->ELright;
00560 }

Halfedge * EdgeList::HEcreate ( Edge e,
int  pm 
)

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 437 of file VastDefs.cc.

Referenced by Vast::buildVoronoi(), and initialize().

00438 {
00439     Halfedge *answer = new Halfedge;
00440     answer->ELedge = e;
00441     answer->ELpm = pm;
00442 
00443     HEmemmap[HEcount++] = answer;
00444     if(HEcount%ELhashsize == 0) {
00445         Halfedge **Temp = new Halfedge*[HEcount + ELhashsize];
00446         for(int i=0; i<HEcount; i++) Temp[i] = HEmemmap[i];
00447         delete[] HEmemmap;
00448         HEmemmap = Temp;
00449     }
00450     return answer;
00451 }

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 405 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00406 {
00407     int i;
00408 
00409     HEcount = 0;
00410     ELhashsize = 2 * sqrt_nsites;
00411 
00412     HEmemmap = new Halfedge*[ELhashsize];
00413 
00414     ELhash = new Halfedge*[ELhashsize];
00415     for(i=0; i<ELhashsize; i++) ELhash[i] = NULL;
00416     ELleftend = HEcreate(NULL, 0);
00417     ELrightend = HEcreate(NULL, 0);
00418     ELleftend->ELleft = NULL;
00419     ELleftend->ELright = ELrightend;
00420     ELrightend->ELleft = ELleftend;
00421     ELrightend->ELright = NULL;
00422     ELhash[0] = ELleftend;
00423     ELhash[ELhashsize-1] = ELrightend;
00424     this->xmin = xmin;
00425     this->deltax = deltax;
00426     this->bottomsite = bottomsite;
00427 }

Site * EdgeList::leftreg ( Halfedge he  ) 

Get site left of an edge.

@param he A halfedge. @return Returns site left of halfedge he.

Definition at line 568 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00569 {
00570     if(he->ELedge == NULL) return(bottomsite);
00571     return he->ELpm == le ? he->ELedge->reg[le] : he->ELedge->reg[re];
00572 }

void EdgeList::reset (  ) 

Resets the list for further use.

Definition at line 429 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00430 {
00431     delete[] ELhash;
00432     // free all allocated memory
00433     for(int i=0; i<HEcount; i++) delete HEmemmap[i];
00434     delete[] HEmemmap;
00435 }

int EdgeList::right_of ( Halfedge el,
Vector2D p 
)

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 476 of file VastDefs.cc.

Referenced by ELleftbnd().

00477 {
00478     Edge *e;
00479     Site *topsite;
00480     int right_of_site, above, fast;
00481     double dxp, dyp, dxs, t1, t2, t3, yl;
00482 
00483     e = el->ELedge;
00484     topsite = e->reg[1];
00485     right_of_site = p->x > topsite->coord.x;
00486     if(right_of_site && el->ELpm == le) return 1;
00487     if(!right_of_site && el->ELpm == re) return 0;
00488 
00489     if(e->a == 1.0) {
00490         dyp = p->y - topsite->coord.y;
00491         dxp = p->x - topsite->coord.x;
00492         fast = 0;
00493         if((!right_of_site && (e->b < 0.0)) || (right_of_site && (e->b >= 0.0))) {
00494             above = dyp >= e->b * dxp;
00495             fast = above;
00496         }
00497         else {
00498             above = p->x + p->y * e->b > e->c;
00499             if(e->b < 0.0) above = !above;
00500             if(!above) fast = 1;
00501         }
00502         if(!fast) {
00503             dxs = topsite->coord.x - (e->reg[0])->coord.x;
00504             above = e->b * (dxp*dxp - dyp*dyp) < dxs * dyp * (1.0 + 2.0*dxp/dxs + e->b*e->b);
00505             if(e->b < 0.0) above = !above;
00506         }
00507     }
00508     else {
00509         yl = e->c - e->a * p->x;
00510         t1 = p->y - yl;
00511         t2 = p->x - topsite->coord.x;
00512         t3 = yl - topsite->coord.y;
00513         above = t1*t1 > t2*t2 + t3*t3;
00514     }
00515     return el->ELpm == le ? above : !above;
00516 }

Site * EdgeList::rightreg ( Halfedge he  ) 

Get site right of an edge.

@param he A halfedge. @return Returns site right of halfedge he.

Definition at line 574 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00575 {
00576     if(he->ELedge == NULL) return(bottomsite);
00577     return he->ELpm == le ? he->ELedge->reg[re] : he->ELedge->reg[le];
00578 }


Member Data Documentation

Site* EdgeList::bottomsite [protected]

Definition at line 237 of file VastDefs.h.

Referenced by leftreg(), and rightreg().

double EdgeList::deltax [protected]

Definition at line 234 of file VastDefs.h.

Referenced by ELleftbnd().

Halfedge** EdgeList::ELhash [protected]

Definition at line 235 of file VastDefs.h.

Referenced by EdgeList(), ELgethash(), ELleftbnd(), initialize(), and reset().

int EdgeList::ELhashsize [protected]

Definition at line 233 of file VastDefs.h.

Referenced by ELgethash(), ELleftbnd(), HEcreate(), and initialize().

Definition at line 230 of file VastDefs.h.

Referenced by Vast::buildVoronoi(), ELleftbnd(), and initialize().

Definition at line 230 of file VastDefs.h.

Referenced by Vast::buildVoronoi(), ELleftbnd(), and initialize().

int EdgeList::HEcount [protected]

Definition at line 233 of file VastDefs.h.

Referenced by HEcreate(), initialize(), and reset().

Definition at line 236 of file VastDefs.h.

Referenced by HEcreate(), initialize(), and reset().

int EdgeList::ntry [protected]

Definition at line 233 of file VastDefs.h.

Referenced by ELleftbnd().

int EdgeList::totalsearch [protected]

Definition at line 233 of file VastDefs.h.

Referenced by ELleftbnd().

double EdgeList::xmin [protected]

Definition at line 234 of file VastDefs.h.

Referenced by ELleftbnd().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3