1 #ifndef __FASTJET__VORONOI_H__
2 #define __FASTJET__VORONOI_H__
107 #include "fastjet/LimitedWarning.hh"
117 FASTJET_BEGIN_NAMESPACE
129 VPoint() : x(0.0), y(0.0) {}
132 VPoint(
double _x,
double _y) : x(_x), y(_y) {}
135 inline VPoint operator + (
const VPoint &p)
const{
136 return VPoint(x+p.x, y+p.y);
140 inline VPoint operator - (
const VPoint &p)
const{
141 return VPoint(x-p.x, y-p.y);
145 inline VPoint
operator * (
const double t)
const{
146 return VPoint(x*t, y*t);
155 inline double norm(
const VPoint p){
156 return p.x*p.x+p.y*p.y;
162 return p1.x*p2.y-p1.y*p2.x;
168 return p1.x*p2.x+p1.y*p2.y;
214 class FreeNodeArrayList{
217 FreeNodeArrayList* next;
238 Halfedge *ELleft, *ELright;
243 volatile double ystar;
255 class VoronoiDiagramGenerator{
257 VoronoiDiagramGenerator();
258 ~VoronoiDiagramGenerator();
260 bool generateVoronoi(std::vector<VPoint> *_parent_sites,
261 double minX,
double maxX,
double minY,
double maxY,
264 inline void resetIterator(){
265 iteratorEdges = allEdges;
268 bool getNext(GraphEdge **e){
269 if(iteratorEdges == 0)
273 iteratorEdges = iteratorEdges->next;
277 std::vector<VPoint> *parent_sites;
283 char *getfree(Freelist *fl);
288 Halfedge *HEcreate(), *ELleft(), *ELright(), *ELleftbnd();
289 Halfedge *HEcreate(Edge *e,
int pm);
292 Halfedge *PQextractmin();
293 void freeinit(Freelist *fl,
int size);
294 void makefree(Freenode *curr,Freelist *fl);
302 void endpoint(Edge *e,
int lr,Site * s);
304 void ELdelete(Halfedge *he);
305 Halfedge *ELleftbnd(VPoint *p);
306 Halfedge *ELright(Halfedge *he);
307 void makevertex(Site *v);
309 void PQinsert(Halfedge *he,Site * v,
double offset);
310 void PQdelete(Halfedge *he);
312 void ELinsert(Halfedge *lb, Halfedge *newHe);
313 Halfedge * ELgethash(
int b);
314 Halfedge *ELleft(Halfedge *he);
315 Site *leftreg(Halfedge *he);
317 int PQbucket(Halfedge *he);
318 void clip_line(Edge *e);
319 char *myalloc(
unsigned n);
320 int right_of(Halfedge *el,VPoint *p);
322 Site *rightreg(Halfedge *he);
323 Edge *bisect(Site *s1, Site *s2);
324 double dist(Site *s,Site *t);
328 Site *intersect(Halfedge *el1, Halfedge *el2 );
332 void pushGraphEdge(
double x1,
double y1,
double x2,
double y2,
348 Halfedge *ELleftend, *ELrightend;
352 double xmin, xmax, ymin, ymax, deltax, deltay;
369 int ntry, totalsearch;
370 double pxmin, pxmax, pymin, pymax, cradius;
373 double borderMinX, borderMaxX, borderMinY, borderMaxY;
375 FreeNodeArrayList* allMemoryList;
376 FreeNodeArrayList* currentMemoryBlock;
379 GraphEdge* iteratorEdges;
381 double minDistanceBetweenSites;
383 static LimitedWarning _warning_degeneracy;
386 int scomp(
const void *p1,
const void *p2);
389 FASTJET_END_NAMESPACE
double norm(const VPoint p)
norm of a vector
Selector operator*(const Selector &s1, const Selector &s2)
successive application of 2 selectors
double scalar_product(const VPoint &p1, const VPoint &p2)
scalar product
double vector_product(const VPoint &p1, const VPoint &p2)
2D vector product