Example Convex Components
#include <LEDA/core/list.h> #include <LEDA/geo/rat_point.h> #include <LEDA/geo/rat_segment.h> #include <LEDA/geo/rat_gen_polygon.h> #include <LEDA/graphics/window.h> #include <LEDA/geo/geo_alg.h> using namespace leda; int main() { rational x1=10,y1=10,x2=100,y2=100; rat_polygon P1=hilbert(5,x1,y1,x2,y2); GRAPH<rat_point,rat_segment> G; list<edge> inner_edges, boundary_edges, hole_edges; edge edgeOnConvexHull =CONVEX_COMPONENTS(P1,G,inner_edges,boundary_edges,hole_edges); window W; W.init(0,110,0); W.open(); W.display(); W.set_node_width(2); W.draw_polygon(P1.to_polygon()); W.read_mouse(); edge e; forall_edges(e,G) { point p=G[G.source(e)].to_point(); point q=G[G.target(e)].to_point(); W.draw_segment(p,q,red); } W.read_mouse(); W.screenshot("convex_components"); return 0; } |
See also:Generators for Geometric Objects Manual Entries |
Algorithmic Solutions Software GmbH