delaunay_tree.h
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 6k
Development Platform:

MultiPlatform

  1. /*******************************************************************************
  2. +
  3. +  LEDA-R  3.2.3
  4. +
  5. +  delaunay_tree.h
  6. +
  7. +  Copyright (c) 1995  by  Max-Planck-Institut fuer Informatik
  8. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  9. +  All rights reserved.
  10. *******************************************************************************/
  11. #ifndef LEDA_DELAUNAY_H
  12. #define LEDA_DELAUNAY_H
  13. /*****************************************************************************
  14. +
  15. + Delaunay tree    by Olivier Devillers
  16. +
  17. + Fully dynamic construction of the Delaunay triangulation with
  18. + good randomized complexity
  19. +
  20. + Copyright (c) 1990
  21. + INRIA, 2004 route des Lucioles, 06 565 Valbonne Cedex, France
  22. +
  23. + for LEDA
  24. + Copyright (c) 1990  by  Max Planck Institut f"ur Informatik
  25. + Im Stadtwald, 6600 Saarbruecken, FRG
  26. +  All rights reserved.
  27. +
  28. ******************************************************************************/
  29. #include <LEDA/point.h>
  30. typedef double coord;
  31. struct NOEUD;
  32. typedef NOEUD* noeud;
  33. struct STAR;
  34. typedef STAR* star;
  35. struct REINSERER;
  36. typedef REINSERER* reinserer;
  37. struct LISTENOEUD;
  38. typedef LISTENOEUD* listenoeud;
  39. struct DT_POINT{
  40. coord x,y;
  41.         void* i;
  42. int  n;            /* un flag dont l'ordre est compatible avec
  43.               l'ordre d'insertion */
  44. int  visite;    /* un flag de visite */
  45. NOEUD* cree;    /*un noeud cree par l'insertion de ce point*/
  46. }; 
  47. typedef DT_POINT* DT_item;
  48. typedef void delaunay_f2(double,double);
  49. typedef void delaunay_f4(double,double,double,double);
  50. typedef void delaunay_f6(double,double,double,double,double,double);
  51. typedef void delaunay_F6(double,double,double,double,double*,double*);
  52. class delaunay_tree{
  53.         int flag; /* numero de l'operation en cours */
  54.         noeud nouveau; /* dernier noeud cree */
  55.         
  56.         star Star; /* pour la suppression */
  57.         reinserer Reinsert;
  58. NOEUD * arbre ; /* la racinne du Delaunay tree */
  59. NOEUD * last ; /* dernier noeud cree */
  60.         int counter;            /* total number of items (s.n.) */
  61. char*      used_blocks;
  62. DT_item    Poubelle_point;
  63. listenoeud Poubelle_listenoeud;
  64. noeud      Poubelle_noeud;
  65. noeud      Libre_noeud;
  66. star       Poubelle_star;
  67. reinserer  Poubelle_reinserer;
  68. int fl;
  69. int item_nombre;
  70. DT_item item_next;
  71. int listenoeud_nombre;
  72. listenoeud listenoeud_next;
  73. int noeud_nombre;
  74. noeud noeud_next;
  75. int star_nombre;
  76. star star_next;
  77. int reinserer_nombre;
  78. reinserer reinserer_next;
  79. star first_star;
  80. char*      alloc_block(int size);
  81. void       free_blocks();
  82. void       poubelle_point(DT_item p);
  83. DT_item    vrai_alloc_point();
  84. DT_item    alloc_point();
  85. void       poubelle_listenoeud(listenoeud p);
  86. listenoeud vrai_alloc_listenoeud();
  87. listenoeud alloc_listenoeud();
  88. void       poubelle_noeud(noeud p);
  89. noeud      vrai_alloc_noeud();
  90. noeud      alloc_noeud();
  91. void       poubelle_star(star p);
  92. star       vrai_alloc_star();
  93. star       alloc_star();
  94. void       poubelle_reinserer( reinserer p);
  95. reinserer  vrai_alloc_reinserer();
  96. reinserer  alloc_reinserer();
  97. void  beaufils( noeud bf, noeud bp);
  98. void  plusbeaufils( noeud bf, noeud bp);
  99. void  demiplan( noeud t);
  100. void  cercle( noeud t);
  101. int   confondu( DT_item a, DT_item b);
  102. int   direct( noeud n);
  103. int   conflit( noeud n, DT_item p);
  104. noeud Insert( noeud n, DT_item p);
  105. noeud creenoeud( noeud pere, int i, DT_item p);
  106. int   creation( noeud detruit, DT_item p);
  107. DT_item localise( noeud detecte, DT_item p);
  108. void  add_x1x2( reinserer r, noeud v, DT_item p);
  109. void  add_decroche( reinserer r, noeud v);
  110. void  destroy( noeud u, DT_item p);
  111. void  recherche( DT_item p);
  112. void  reinsertion( reinserer n, DT_item p);
  113. void  parcours( reinserer n, DT_item p);
  114. void  trace_items(noeud, delaunay_f2*);
  115. void  list_items(noeud n, list<DT_item>& L);
  116. void  clear_items(noeud n);
  117. void  del_noeud( noeud n, delaunay_f4* trace_segment,int both);
  118. void  vor( noeud n, delaunay_f6* trace_segment, delaunay_F6* pt_infi, int both);
  119. virtual void copy_inf(GenPtr& p)  { p=p; }
  120. virtual void clear_inf(GenPtr& p) { p=0; }
  121. public:
  122. delaunay_tree();
  123. virtual ~delaunay_tree();
  124. reinserer locate( reinserer n, DT_item x);
  125. void clear_Reinsert( reinserer n);
  126. void clear_Star();
  127. void init_Star( noeud n, int i, int j, int k);
  128. star loc_Star( DT_item xx);
  129. void split_Star( star n1,star n2);
  130. DT_item insert(double, double, void*);
  131. DT_item insert(point p, void* inf) { return insert(p.xcoord(),p.ycoord(),inf); }
  132. DT_item neighbor(double, double);
  133. DT_item neighbor(point p)          { return neighbor(p.xcoord(),p.ycoord()); }
  134. void    del(double, double);
  135. void    del(point p)               { del(p.xcoord(),p.ycoord()); }
  136. void    del_item( DT_item);
  137. point    key(DT_item p)  { return point(p->x,p->y); } 
  138. void*    inf(DT_item p)  { return p->i; } 
  139. void     change_inf(DT_item p, void* i)  { copy_inf(i);  
  140.                                            clear_inf(p->i); 
  141.                                            p->i = i; } 
  142. void     trace_voronoi_sites( delaunay_f2*);
  143. void     trace_voronoi_edges( delaunay_f6*, delaunay_F6*, int both = 0);
  144. void     trace_triang_edges( delaunay_f4* , int both = 0);
  145. void     all_items(list<DT_item>&);
  146. void     convex_hull(list<DT_item>&);
  147. void     clear();
  148. void     init();
  149. };
  150. template<class itype>
  151. class DELAUNAY_TREE : public delaunay_tree {
  152. void copy_inf(GenPtr& p)  { Copy(*(itype*)&p); }
  153. void clear_inf(GenPtr& p) { Clear(*(itype*)&p); }
  154. public:
  155. DT_item insert(point site, itype i)
  156.                           { return delaunay_tree::insert(site,Convert(i)); }
  157. itype  inf(DT_item p)    { return LEDA_ACCESS(itype,delaunay_tree::inf(p)); } 
  158.  DELAUNAY_TREE() {}
  159. ~DELAUNAY_TREE() {}
  160. };
  161. #endif