|
From: Gerard C. <ca...@kn...> - 2008-01-11 13:47:55
|
LS, I encountered a problem when I tried to fill a closed polygon which extended beyond the xrange, yrange. This is conform the documentation, which says: "Zoom of a filled curve drawn from a datafile may produce empty or incorrect area because gnuplot is clipping points and lines, and not areas." I use Version 4.2 patchlevel 2. I guess that it is desirable to remove this "feature" from gnuplot. A well-known algorithm to clip a filled polygon is by Sutherland and Hodgman. Some very ingenious implementations exist, e.g. http://www.codeguru.com/Cpp/misc/misc/graphics/article.php/c8965/, but I wrote a simple one, in Perl, with which I was able to clip my polygons myself, before sending them to gnuplot. The advantage of my code is that it is simple and very fast, but its disadvantage is that it needs to store both the input and the output polygons, so it needs more memory than more sophisticated solutions. Yet, with current memory prices, this should not really be a problem anymore. My implementation is specifically to clip to rectangular areas. I include my Perl program. Perhaps a gnuplot code guru is interested to implement Sutherland/Hodgman clipping; if so, (s)he may find it useful to have a look at my Perl program. I myself cannot write C (easily), but I think conversion of Perl to C code will not be a great challenge. The real challenge lies in adjusting the code to gnuplot data structures. -- <PRE> R G s e ard G R Gerard Cats, KNMI, PO Box 201, 3730 AE De Bilt, The Netherlands. Tel. +31302206442, Fax +31302211371, e-mail ca...@kn... URL: http://www.knmi.nl/~cats </PRE> |