Menu

#1237 Polygon clipping

closed-accepted
nobody
None
5
2015-03-23
2013-04-24
No

Hi,

the current implementation of polygon clipping, like it is used for e.g. for ellipse, circle and polygon objects, does not work properly.

I added a patch, which implements the Sutherland-Hodgman algorithm for generic polygon clipping against a rectangular bounding box (following the pseudo code from http://www.cs.rit.edu/~icss571/clipTrans/PolyClipBack.html).

The gnuplot script shows some test cases, which do not work with the current implementation (compare -old files with -new files).

The patch also add a routine for drawing a clipped polygon path with a minimum amount of move() calls. This allows the terminal drivers to use proper line joins, as the arrow in the gnuplot script show.

I guess, the generic polygon clipping may also be useful for plot style filledcurves.

Christoph

1 Attachments

Discussion

  • Bastian Märkisch

    Nice. I have been working on a solution for circles - but your solution is far more general!

     
  • Ethan Merritt

    Ethan Merritt - 2013-04-25

    Looks very good. Shall I add it to CVS or are you still working on it?

     
  • Christoph Bersch

    No, I am not working on it, you can add it.

    Thank you

     
  • Ethan Merritt

    Ethan Merritt - 2013-04-25

    Added to CVS for 4.7
    thanks for the nice improvement.

     
  • Ethan Merritt

    Ethan Merritt - 2013-04-25
    • status: open --> closed-accepted
     

Log in to post a comment.