## Re: [Plplot-devel] Problem with filling a clipped polygon

 Re: [Plplot-devel] Problem with filling a clipped polygon From: Arjen Markus - 2005-04-22 06:47:16 ```"Alan W. Irwin" wrote: > > On 2005-04-20 16:07+0200 Arjen Markus wrote: > > > Hello, > > > > I thought we had solved it, but there is still a problem > > with filling clipped polygons. This is exhibited by the > > small example below: > > > > A small triangle is filled rather than the complete rectangle without > > that triangle. If you use the second call to plwind() instead of > > the first you will see the complete polygon. > Could > somebody who knows where those decisions are made have a look to see if my > hypothesis is correct? > Before embarking on a change of the code to stop the logical gap, I did some experiments with an extra indentation in the polygon: - a second indentation in another side gives the correct picture - a second indentation in the same side gives two "fangs" rather than a filled rectangle with a bite mark. So it looks as if the missing logic is the case where only one side of the viewport is crossed. Regards, Arjen ```

 [Plplot-devel] Re: [Plplot-general] making vector plots From: Andrew Ross - 2005-04-18 08:27:02 ```Moved from plplot-general as this is more a development issue. On Mon, Apr 18, 2005 at 08:40:28AM +0200, Arjen Markus wrote: > Andrew Ross wrote: > > > > I propose a very simple algorithm: > - Determine a bounding box for the grid points/data points > - Divide its area by the total number of points - this gives a raw > indication > of the average grid cell > - Take the square root to get a typical size > > This ought to be efficient and effective for most situations, except > where > you have very small clusters. I did consider this but in the end I have just gone with the brute force approach of working out the distance between all pairs of points. For a vector plot any more than about 50x50 becomes unreadable and so the overhead is not really that large. This will at least cope with the clustered points case. We'll see how this turns out. If anyone has any particularly difficult cases that don't work can you let me know. Andrew ```
 Re: [Plplot-devel] Problem with filling a clipped polygon From: Alan W. Irwin - 2005-04-20 16:08:34 ```On 2005-04-20 16:07+0200 Arjen Markus wrote: > Hello, > > I thought we had solved it, but there is still a problem > with filling clipped polygons. This is exhibited by the > small example below: > > A small triangle is filled rather than the complete rectangle without > that triangle. If you use the second call to plwind() instead of > the first you will see the complete polygon. I confirm the bug with latest cvs version on my Debian testing platform. Here is how I would summarize it. If all the polyline is inside the viewport all is well and the same if all the polyline is outside the viewport. (The entire viewport is filled if you use plwind(108., 109.0, 108., 109.); below.) But there are problems (the outside of the polyline is filled rather than the inside) if part of the polyline is outside and part inside the viewport. Note, that when a polyline is clipped at the boundary there are two choices for how it is reconnected. You can connect it the short way along the viewport boundary or the long way around the viewport boundary. For the example below the incorrect "short way" choice was made so that the fill occurred on the wrong side of the clipped polyline. So I think I know exactly what the problem is, but I have no idea where in the code these viewport boundary/polyline clipping decisions are made. Could somebody who knows where those decisions are made have a look to see if my hypothesis is correct? Nice demo of the bug, Arjen! Alan > /* \$Id: x12c.c,v 1.14 2002/12/03 08:39:24 airwin Exp \$ > > Bar chart demo. > */ > > #include "plcdemos.h" > > void > plfbox(PLFLT x0, PLFLT y0); > > /*--------------------------------------------------------------------------*\ > * main > * > * Try and demonstrate that filling polygons that partly fall outside > * the viewport fails. > \*--------------------------------------------------------------------------*/ > > int > main(int argc, char *argv[]) > { > int i; > char string[20]; > PLFLT x0[20]; > PLFLT y0[20]; > > /* Parse and process command line arguments */ > > (void) plParseOpts(&argc, argv, PL_PARSE_FULL); > > /* Initialize plplot */ > > plinit(); > > pladv(0); > plvsta(); > #if 1 > plwind(0.0, 100.0, 0.0, 100.0); > #else > plwind(-500.0, 500.0, -500.0, 500.0); > #endif > plbox("bc", 1.0, 0, "bcnv", 10.0, 0); > plcol0(2); > > > x0[0] = -10 ; y0[0] = -10; > x0[1] = -10 ; y0[1] = 110; > x0[2] = 40 ; y0[2] = 110; > x0[3] = 50 ; y0[3] = 50; > x0[4] = 60 ; y0[4] = 110; > x0[5] = 110 ; y0[5] = 110; > x0[6] = 110 ; y0[6] = -10; > x0[7] = -10 ; y0[7] = -10; > > plcol0(1); > plpsty(0); > plfill(8, x0, y0); > plcol0(2); > pllsty(1); > plline(8, x0, y0); > > /* Don't forget to call plend() to finish off! */ > > plend(); > exit(0); > } __________________________ Alan W. Irwin email: irwin@... phone: 250-727-2902 Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ```
 Re: [Plplot-devel] Problem with filling a clipped polygon From: - 2005-04-20 19:57:16 ```Alan W. Irwin writes: > I confirm the bug with latest cvs version on my Debian testing platform. > Here is how I would summarize it. If all the polyline is inside the > viewport all is well and the same if all the polyline is outside the > viewport. (The entire viewport is filled if you use plwind(108., 109.0, > 108., 109.); below.) But there are problems (the outside of the polyline is > filled rather than the inside) if part of the polyline is outside and part > inside the viewport. Note, that when a polyline is clipped at the boundary > there are two choices for how it is reconnected. You can connect it the > short way along the viewport boundary or the long way around the viewport > boundary. For the example below the incorrect "short way" choice was made so > that the fill occurred on the wrong side of the clipped polyline. So I > think I know exactly what the problem is, but I have no idea where in the > code these viewport boundary/polyline clipping decisions are made. Could > somebody who knows where those decisions are made have a look to see if my > hypothesis is correct? That would be in plP_plfclp(), starting line 618 of src/plline.c. Lots of very painstakingly worked out logic, apparently still incomplete. No surprise, it's a very tough problem. Have fun. :) -- Maurice LeBrun mjl@... ```
 Re: [Plplot-devel] Problem with filling a clipped polygon From: Alan W. Irwin - 2005-04-21 00:33:29 ```On 2005-04-20 13:50-0500 mjl@... wrote: > Alan W. Irwin writes: > > ...So I > > think I know exactly what the problem is, but I have no idea where in the > > code these viewport boundary/polyline clipping decisions are made. Could > > somebody who knows where those decisions are made have a look to see if my > > hypothesis is correct? > > That would be in plP_plfclp(), starting line 618 of src/plline.c. Lots of > very painstakingly worked out logic, apparently still incomplete. No > surprise, it's a very tough problem. Have fun. :) Thanks for those directions, Maurice, and I really laughed hard at that smooth redirection at the end. :-) My own redirection will not be quite as smooth as Maurice's, but frankly, there is no chance for me for quite a long time so I hope Arjen or somebody else will try to verify my hypothesis for what is wrong, and if that is the problem, fix the code logic appropriately. Alan __________________________ Alan W. Irwin email: irwin@... phone: 250-727-2902 Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ```
 Re: [Plplot-devel] Problem with filling a clipped polygon From: Arjen Markus - 2005-04-21 06:35:33 ```"Alan W. Irwin" wrote: > > On 2005-04-20 16:07+0200 Arjen Markus wrote: > > > Hello, > > > > I thought we had solved it, but there is still a problem > > with filling clipped polygons. This is exhibited by the > > small example below: > > > > A small triangle is filled rather than the complete rectangle without > > that triangle. If you use the second call to plwind() instead of > > the first you will see the complete polygon. > > I confirm the bug with latest cvs version on my Debian testing platform. > Here is how I would summarize it. If all the polyline is inside the > viewport all is well and the same if all the polyline is outside the > viewport. (The entire viewport is filled if you use plwind(108., 109.0, > 108., 109.); below.) But there are problems (the outside of the polyline is > filled rather than the inside) if part of the polyline is outside and part > inside the viewport. Note, that when a polyline is clipped at the boundary > there are two choices for how it is reconnected. You can connect it the > short way along the viewport boundary or the long way around the viewport > boundary. For the example below the incorrect "short way" choice was made so > that the fill occurred on the wrong side of the clipped polyline. So I > think I know exactly what the problem is, but I have no idea where in the > code these viewport boundary/polyline clipping decisions are made. Could > somebody who knows where those decisions are made have a look to see if my > hypothesis is correct? > > Nice demo of the bug, Arjen! > Alan, I have already solved a couple of similar bugs, and I am a bit familiar with the code, so I will volunteer to look into it - after all, this was a problem found by one of my colleagues ;). The main difference of this polygon with the others as I see it is that it encircles all four corners before entering the viewport. And I suspect there is a nasty bug in the procedure that has not caused any damage yet (iout may be used before it is being set). Anyway I wanted you to know about this bug, in case somebody else has a strong urge to solve it :) I was happy to see it arise immediately - with the previous ones it took some experimenting! Regards, Arjen ```
 Re: [Plplot-devel] Problem with filling a clipped polygon From: Arjen Markus - 2005-04-22 06:47:16 ```"Alan W. Irwin" wrote: > > On 2005-04-20 16:07+0200 Arjen Markus wrote: > > > Hello, > > > > I thought we had solved it, but there is still a problem > > with filling clipped polygons. This is exhibited by the > > small example below: > > > > A small triangle is filled rather than the complete rectangle without > > that triangle. If you use the second call to plwind() instead of > > the first you will see the complete polygon. > Could > somebody who knows where those decisions are made have a look to see if my > hypothesis is correct? > Before embarking on a change of the code to stop the logical gap, I did some experiments with an extra indentation in the polygon: - a second indentation in another side gives the correct picture - a second indentation in the same side gives two "fangs" rather than a filled rectangle with a bite mark. So it looks as if the missing logic is the case where only one side of the viewport is crossed. Regards, Arjen ```
 [Plplot-devel] Using CSA on Windows ... From: Arjen Markus - 2005-04-22 13:57:26 ```Hello all, I am trying to use the CSA library (not the very latest one, I admit), but I run into the problem that on Windows (using MSVC/C++) neither the function copysign() nor the function isnan() exist. Does anyone have an advice as to how to proceed with this? Regards, Arjen ```
 [Plplot-devel] Problem with filling a clipped polygon From: Arjen Markus - 2005-04-20 14:08:03 ```Hello, I thought we had solved it, but there is still a problem with filling clipped polygons. This is exhibited by the small example below: A small triangle is filled rather than the complete rectangle without that triangle. If you use the second call to plwind() instead of the first you will see the complete polygon. I have not checked, I admit with the very latest source code, so if this has been solved already, then ignore my mail. Regards, Arjen /* \$Id: x12c.c,v 1.14 2002/12/03 08:39:24 airwin Exp \$ Bar chart demo. */ #include "plcdemos.h" void plfbox(PLFLT x0, PLFLT y0); /*--------------------------------------------------------------------------*\ * main * * Try and demonstrate that filling polygons that partly fall outside * the viewport fails. \*--------------------------------------------------------------------------*/ int main(int argc, char *argv[]) { int i; char string[20]; PLFLT x0[20]; PLFLT y0[20]; /* Parse and process command line arguments */ (void) plParseOpts(&argc, argv, PL_PARSE_FULL); /* Initialize plplot */ plinit(); pladv(0); plvsta(); #if 1 plwind(0.0, 100.0, 0.0, 100.0); #else plwind(-500.0, 500.0, -500.0, 500.0); #endif plbox("bc", 1.0, 0, "bcnv", 10.0, 0); plcol0(2); x0[0] = -10 ; y0[0] = -10; x0[1] = -10 ; y0[1] = 110; x0[2] = 40 ; y0[2] = 110; x0[3] = 50 ; y0[3] = 50; x0[4] = 60 ; y0[4] = 110; x0[5] = 110 ; y0[5] = 110; x0[6] = 110 ; y0[6] = -10; x0[7] = -10 ; y0[7] = -10; plcol0(1); plpsty(0); plfill(8, x0, y0); plcol0(2); pllsty(1); plline(8, x0, y0); /* Don't forget to call plend() to finish off! */ plend(); exit(0); } ```
 Re: [Plplot-devel] Problem with filling a clipped polygon From: Arjen Markus - 2005-04-22 09:54:31 ```Arjen Markus wrote: > > Hello, > > I thought we had solved it, but there is still a problem > with filling clipped polygons. This is exhibited by the > small example below: > > A small triangle is filled rather than the complete rectangle without > that triangle. If you use the second call to plwind() instead of > the first you will see the complete polygon. > > I have not checked, I admit with the very latest source code, so if > this has been solved already, then ignore my mail. > I have just committed a corrected version of plline.c. Changes: - code to determine which sides are crossed - code to add the corners of the viewport in case only one side is crossed (this appeared to be the hole in the logic) - corrected an error in the pointinpolygon() function. - added a copy of pointinpolygon() to deal with an array of PLINT coordinates. I know: this is not an ideal solution, but it was quicker to implement than copying the data into a short array. With this version, my original example (and the one with two indentations) gets filled correctly. I am confident that I have not broken anything, but please try it out, if you have the opportunity. Regards, Arjen ```