home *** CD-ROM | disk | FTP | other *** search
- #include <LEDA/plane.h>
- #include <LEDA/window.h>
-
- main()
-
- { window W;
-
- int grid_width = 0;
-
- panel p("polygon");
-
- p.text_item("This program demonstrates the intersection operation ");
- p.text_item("for simple polygons (data type polygon). Use the left ");
- p.text_item("mouse button to define the vertex sequence of a simple ");
- p.text_item("polygon P in clockwise order. Terminate the input with ");
- p.text_item("the middle button. Now, for each further polygon Q the ");
- p.text_item("intersection with P (list of polygons) is computed and ");
- p.text_item("and displayed. Terminate the program by clicking the ");
- p.text_item("right button. ");
-
-
- p.choice_item("GRID MODE",grid_width,
- "no grid " ,"10 pixel" ,"20 pixel" ,"30 pixel" ,"40 pixel");
-
- p.button("continue");
-
- p.open();
-
- grid_width = 10 * grid_width;
-
-
- W.init(-1200,1200,-1200, grid_width);
-
-
- polygon P,Q,R;
-
- W >> P;
- W << P;
-
-
- W.set_mode(xor_mode);
-
- list(polygon) L;
-
- while (W >> Q)
- { forall(R,L) W.draw_filled_polygon(R);
- L = P.intersection(Q);
- forall(R,L) W.draw_filled_polygon(R);
- }
-
- }
-