complex path problem

Mike,

When I eliminate the cuts from filled contour paths, I do find pathological cases where the filling works correctly with the cuts in place, but not without them. Attached are a data file and a script to plot it, illustrating the problem. Is this due to a known limitation of filled paths? In the example, the top two holes are connected to the lower hole, instead of being connected directly to the outer boundary of the filled region. Is this illegal? If so, I think we are stuck, because rearranging the paths that cntr makes to eliminate this type of case would likely be very difficult.

Eric

badpath.npz (1.31 KB)

p.py (1.84 KB)

My understanding is that MOVETO in the middle of the path serve as a
CLOSEPOLY when the path is filled. So, I don't think it actually
matters how holes are connected each other. And as you can see, the
largest hole is actually composed of three different polygons that
overlaps, and the funny pattern is due to this overlaps.

The attached is my attempt to solve this problem. "remove_cuts"
removes the cuts in a way that a hole becomes a single closed polygon,
although I'm not sure if the code is rigorous enough. It seems to work
okay for your sample data. It assumes that cuts are always vertical
lines but this assumption can be dropped if we do bookkepping of all
the path segments.
I hope the code turns out to be work okay in general.

Ideally, it would be better if something similar would be done inside
the contouring routine.

-JJ

p_jj.py (3.05 KB)

image.png

···

On Thu, Aug 6, 2009 at 1:58 PM, Eric Firing<efiring@...229...> wrote:

Mike,

When I eliminate the cuts from filled contour paths, I do find pathological
cases where the filling works correctly with the cuts in place, but not
without them. Attached are a data file and a script to plot it,
illustrating the problem. Is this due to a known limitation of filled
paths? In the example, the top two holes are connected to the lower hole,
instead of being connected directly to the outer boundary of the filled
region. Is this illegal? If so, I think we are stuck, because rearranging
the paths that cntr makes to eliminate this type of case would likely be
very difficult.

Eric

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Jae-Joon Lee wrote:

My understanding is that MOVETO in the middle of the path serve as a
CLOSEPOLY when the path is filled. So, I don't think it actually
matters how holes are connected each other. And as you can see, the
largest hole is actually composed of three different polygons that
overlaps, and the funny pattern is due to this overlaps.

The attached is my attempt to solve this problem. "remove_cuts"
removes the cuts in a way that a hole becomes a single closed polygon,
although I'm not sure if the code is rigorous enough. It seems to work
okay for your sample data. It assumes that cuts are always vertical
lines but this assumption can be dropped if we do bookkepping of all
the path segments.
I hope the code turns out to be work okay in general.

Ideally, it would be better if something similar would be done inside
the contouring routine.

JJ,

Thank you. In fact, earlier today I wrote a python class that handles the reorganization of the paths, and it seems to work fine--but it is much too slow for complicated contour plots. Therefore I started on a C implementation inside cntr.c, directly generating the verts and codes that will be input to Path. I think I have the main structure in place, but finishing and debugging will take some time. I hope to be able to commit it in a few days.

Eric

···

-JJ

On Thu, Aug 6, 2009 at 1:58 PM, Eric Firing<efiring@...229...> wrote:

Mike,

When I eliminate the cuts from filled contour paths, I do find pathological
cases where the filling works correctly with the cuts in place, but not
without them. Attached are a data file and a script to plot it,
illustrating the problem. Is this due to a known limitation of filled
paths? In the example, the top two holes are connected to the lower hole,
instead of being connected directly to the outer boundary of the filled
region. Is this illegal? If so, I think we are stuck, because rearranging
the paths that cntr makes to eliminate this type of case would likely be
very difficult.

Eric

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

------------------------------------------------------------------------

Jae-Joon Lee wrote:

My understanding is that MOVETO in the middle of the path serve as a
CLOSEPOLY when the path is filled. So, I don't think it actually
matters how holes are connected each other. And as you can see, the
largest hole is actually composed of three different polygons that
overlaps, and the funny pattern is due to this overlaps.

The attached is my attempt to solve this problem. "remove_cuts"
removes the cuts in a way that a hole becomes a single closed polygon,
although I'm not sure if the code is rigorous enough. It seems to work
okay for your sample data. It assumes that cuts are always vertical
lines but this assumption can be dropped if we do bookkepping of all
the path segments.
I hope the code turns out to be work okay in general.

Ideally, it would be better if something similar would be done inside
the contouring routine.

An implementation of the path conversion is now in the reorder() function in cntr.c; as of svn r7422, it is used by contourf (and by contour, although for line contours it is merely copying data into the output arrays). In addition to the contourf_demo.py, I have tested it with basemap's simpletest.py and with random data, without detecting any obvious artifacts. More testing is welcome, of course.

Eric

···

-JJ

On Thu, Aug 6, 2009 at 1:58 PM, Eric Firing<efiring@...229...> wrote:

Mike,

When I eliminate the cuts from filled contour paths, I do find pathological
cases where the filling works correctly with the cuts in place, but not
without them. Attached are a data file and a script to plot it,
illustrating the problem. Is this due to a known limitation of filled
paths? In the example, the top two holes are connected to the lower hole,
instead of being connected directly to the outer boundary of the filled
region. Is this illegal? If so, I think we are stuck, because rearranging
the paths that cntr makes to eliminate this type of case would likely be
very difficult.

Eric

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

------------------------------------------------------------------------