⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geowin_voro.c

📁 A Library of Efficient Data Types and Algorithms,封装了常用的ADT及其相关算法的软件包
💻 C
字号:
#include<LEDA/geowin.h>#include<LEDA/rat_geo_alg.h>#include<LEDA/float_geo_alg.h>#include <LEDA/bitmaps/button21.h>typedef list<rat_point>             point_list;typedef list<rat_polygon>           polygon_list;typedef list<rat_circle>            circle_list;typedef GRAPH<rat_circle, rat_point> voronoi_graph;typedef GRAPH<rat_point,int>       delaunay_graph;geowin_update<point_list, polygon_list>         hull(CONVEX_HULL_POLY);geowin_graph_update<point_list, voronoi_graph>  voronoi(VORONOI);geowin_graph_update<point_list, voronoi_graph>  f_voro(F_VORONOI);geowin_graph_update<point_list, delaunay_graph> delaunay(DELAUNAY_TRIANG);geowin_graph_update<point_list, delaunay_graph> f_delau(F_DELAUNAY_TRIANG);geowin_graph_update<point_list, delaunay_graph> ms_tree(MIN_SPANNING_TREE);geowin_graph_update<point_list, delaunay_graph> crust(CRUST);class voro_circles : public geowin_update<point_list, circle_list>, public geowin_redraw{  circle_list LC;  void draw(window& W,color c1,color c2,double x1,double y1,double x2,double y2)  {    color cold = W.set_color(c1);    rat_circle iter;    forall(iter,LC) {     W.set_color(c1);     W << iter;     // draw arrows to center ...     rat_point p = iter.point1(), c = iter.center();     W.set_color(red);     W.draw_arrow(p.xcoord().to_double(), p.ycoord().to_double(), \                  c.xcoord().to_double(), c.ycoord().to_double());    }    W.set_color(cold);  }  void update(const point_list& LP, circle_list&)  {    LC.clear();    voronoi_graph VG;    VORONOI(LP,VG);    node v;    forall_nodes(v,VG) if (! (VG[v].is_degenerate())) LC.append(VG[v]);  }public:  virtual ~voro_circles() {}};int main(){  GeoWin gw("Voronoi Demo");  list<rat_point> L;  GeoEditScene<list<rat_point> >* sc_input =  geowin_new_scene(gw,L);     gw.set_point_style(sc_input,circle_point);  gw.set_color(sc_input,black);  gw.set_z_order(sc_input,0);  geo_scene sc1 = geowin_new_scene(gw,voronoi, sc_input, "VORONOI");   gw.set_color(sc1,blue);  gw.set_visible(sc1,true);  gw.set_z_order(sc1,1);    geo_scene sc2 = geowin_new_scene(gw,f_voro,  sc_input, "F_VORONOI");  gw.set_color(sc2,green);  gw.set_z_order(sc2,2);  geo_scene sc3 = geowin_new_scene(gw,ms_tree, sc_input, "MINSPAN_TREE");  gw.set_color(sc3,black);  gw.set_line_width(sc3,2);  gw.set_z_order(sc3,3);  geo_scene sc4 = geowin_new_scene(gw,delaunay,sc_input, "DELAUNAY");  gw.set_color(sc4,orange);  gw.set_z_order(sc4,4);  geo_scene sc5 = geowin_new_scene(gw,f_delau, sc_input, "F_DELAUNAY");  gw.set_color(sc5,red);  gw.set_z_order(sc5,5);  geo_scene sc6 = geowin_new_scene(gw,hull,    sc_input, "CONVEX HULL");  gw.set_color(sc6,grey2);  gw.set_fill_color(sc6,grey1);  gw.set_z_order(sc6,6);  geo_scene sc7 = geowin_new_scene(gw,crust,   sc_input, "Crust");   gw.set_color(sc7,pink);  gw.set_z_order(sc7,7);    voro_circles vc;  geo_scene sc8 = geowin_new_scene(gw, vc, vc, sc_input, "Circles in voronoi diagramm");  gw.set_color(sc8,green2);  gw.set_fill_color(sc8,invisible);  gw.set_line_width(sc8,2);  gw.set_z_order(sc8,8);  gw.set_button_width(21);   gw.set_button_height(21);  gw.set_bitmap(sc1, voro_21_bits);  gw.set_bitmap(sc2, f_voro_21_bits);  gw.set_bitmap(sc3, tree_21_bits);  gw.set_bitmap(sc4, triang_21_bits);  gw.set_bitmap(sc5, f_triang_21_bits);  gw.set_bitmap(sc6, hull_21_bits);   gw.add_help_text("geowin_voro");  gw.display(window::center,window::center);  gw.edit(sc_input);    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -