home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / prog / graphics / polygon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  1.1 KB  |  52 lines

  1. #include <LEDA/plane.h>
  2. #include <LEDA/window.h>
  3.  
  4. main()
  5.  
  6. { window W;
  7.  
  8.   int grid_width = 0;
  9.  
  10.   panel p("polygon");
  11.  
  12.   p.text_item("This program demonstrates the intersection operation   ");
  13.   p.text_item("for simple polygons (data type polygon). Use the left  ");
  14.   p.text_item("mouse button to define the vertex sequence of a simple ");
  15.   p.text_item("polygon P in clockwise order. Terminate the input with ");
  16.   p.text_item("the middle button. Now, for each further polygon Q the ");
  17.   p.text_item("intersection with P (list of polygons) is computed and ");
  18.   p.text_item("and displayed. Terminate the program by clicking the  ");
  19.   p.text_item("right button.                                          ");
  20.  
  21.  
  22.   p.choice_item("GRID MODE",grid_width,
  23.                 "no grid " ,"10 pixel" ,"20 pixel" ,"30 pixel" ,"40 pixel");
  24.  
  25.   p.button("continue");
  26.  
  27.   p.open();
  28.  
  29.   grid_width = 10 * grid_width;
  30.  
  31.  
  32.   W.init(-1200,1200,-1200, grid_width);
  33.  
  34.  
  35.   polygon P,Q,R;
  36.  
  37.   W >> P;
  38.   W << P;
  39.  
  40.  
  41.   W.set_mode(xor_mode);
  42.  
  43.   list(polygon) L;
  44.  
  45.   while (W >> Q)
  46.   { forall(R,L) W.draw_filled_polygon(R);
  47.     L = P.intersection(Q);
  48.     forall(R,L) W.draw_filled_polygon(R);
  49.   }
  50.  
  51. }
  52.