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

📄 geowin_poly_triang.c

📁 A Library of Efficient Data Types and Algorithms,封装了常用的ADT及其相关算法的软件包
💻 C
字号:
#include <LEDA/geowin.h>#include <LEDA/rat_geo_alg.h>#include <LEDA/bitmaps/button21.h>static void constr_poly(const list<rat_point>& L, list<rat_polygon>& P){   P.clear();  if (L.length() > 1) P.append(rat_polygon(L,rat_polygon::NO_CHECK)); }static void triang_poly1(const list<rat_polygon>& L, list<rat_segment>& S){ S.clear();  rat_polygon P;  forall(P,L)  { if (!P.is_simple()) continue;    GRAPH<rat_point,rat_segment> G;    list<edge> out,in,bound;    TRIANGULATE_POLYGON(P,G,out,in,bound);    edge e;    forall(e,in) S.append(rat_segment(G[source(e)],G[target(e)]));  } }static void triang_poly2(const list<rat_polygon>& L, list<rat_segment>& S){ S.clear();  rat_polygon P;  forall(P,L)  { if (!P.is_simple()) continue;    GRAPH<rat_point,rat_segment> G;    list<edge> out,in,bound;    TRIANGULATE_POLYGON(P,G,out,in,bound);    edge e;    forall(e,out) S.append(rat_segment(G[source(e)],G[target(e)]));  } }int main(){  GeoWin GW("Triangulate Polygons");    // Inputscene  list<rat_point> L;  geo_scene sc_input =  geowin_new_scene(GW, L);   GW.set_color(sc_input,black);  GW.set_fill_color(sc_input,yellow);  GW.set_point_style(sc_input,circle_point);    geowin_update<list<rat_point>,   list<rat_polygon> > construct(constr_poly);  geowin_update<list<rat_polygon>, list<rat_segment> > triang1(triang_poly1);  geowin_update<list<rat_polygon>, list<rat_segment> > triang2(triang_poly2);     geo_scene sc_poly=geowin_new_scene(GW,construct, sc_input, "Polygon");  GW.set_fill_color(sc_poly,grey1);  GW.set_color(sc_poly,black);   GW.set_line_width(sc_poly,2);   GW.set_visible(sc_poly,true);  geo_scene sc_triang1 = geowin_new_scene(GW,triang1,sc_poly,"Triang1");   GW.set_color(sc_triang1,red);    geo_scene sc_triang2 = geowin_new_scene(GW,triang2,sc_poly,"Triang2");   GW.set_color(sc_triang2,blue);  GW.set_all_visible(true);    GW.set_button_width(21); GW.set_button_height(21);    GW.set_bitmap(sc_triang1, triangle_21_bits);  GW.set_bitmap(sc_triang2, triangle_21_bits);      GW.edit(sc_input);    return 0;  }

⌨️ 快捷键说明

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