comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: clipping with polyfill
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: clipping with polyfill [message #29925] Wed, 27 March 2002 10:24
Charlie Zender is currently offline  Charlie Zender
Messages: 8
Registered: October 1996
Junior Member
Thanks everyone for your help and insight with this.
The manual should be more explicit about clipping not being supported
with solid or pattern fills.
Mark Hadfield's mgh_polyclip() is doing a great job of clipping
in software so the orientation of the clipped polygon is not altered.
Nice job Mark!

Charlie
--
Charlie Zender, zender at uci dot edu, (949) 824-2987, Department of
Earth System Science, University of California, Irvine CA 92697-3100
Re: clipping with polyfill [message #29945 is a reply to message #29925] Tue, 26 March 2002 13:56 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"David Fanning" <david@dfanning.com> wrote in message
news:MPG.170a8e0a84f81cef989850@news.frii.com...
> James Kuyper (kuyper@gscmail.gsfc.nasa.gov) writes:
>
>> It seems to me that this does the right thing only when the edges
>> of the polygon that are clipped are perpendicular to the clipping
>> boundary. Otherwise, it changes the orientation of those edges.
>
> Right, that's what all that replacement nonsense I wrote before was
> about. If the clipping place is not exactly on a data boundary, the
> edges of the polygon will be off and you will have to replace the
> data value with the clipping value. You will have to interpolate,
> essentially. :-)

I haven't been following this thread very closely, but are you talking
about clipping a polygon to a rectangular region? If so my
MGH_POLYCLIP might be of use. It clips a 2D polygon to a vertical or
horizontal line. Apply it four times to clip to a box. As explained in
the header, it's based on a function of JD's but I did some
performance tuning (and changed the name to annoy him). See:

http://katipo.niwa.cri.nz/~hadfield/gust/software/idl/

--
Mark Hadfield
m.hadfield@niwa.co.nz Ka puwaha et tai nei
http://katipo.niwa.co.nz/~hadfield Hoea tatou
National Institute for Water and Atmospheric Research (NIWA)
Re: clipping with polyfill [message #29947 is a reply to message #29945] Tue, 26 March 2002 12:54 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
James Kuyper (kuyper@gscmail.gsfc.nasa.gov) writes:

> It seems to me that this does the right thing only when the edges of the
> polygon that are clipped are perpendicular to the clipping boundary.
> Otherwise, it changes the orientation of those edges.

Right, that's what all that replacement nonsense I wrote
before was about. If the clipping place is not exactly
on a data boundary, the edges of the polygon will be
off and you will have to replace the data value with
the clipping value. You will have to interpolate,
essentially. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: clipping with polyfill [message #29948 is a reply to message #29947] Tue, 26 March 2002 12:44 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
David Fanning wrote:
...

> I guess the question is, how general does this have to be?
> If you want to clip on "data boundaries", it is easy, you
> just do something like this:
>
> Polyfill, xclip[0] > [x1, Reverse(x2)] < xclip[1], $
> [y1, Reverse(y2)], Color=100

It seems to me that this does the right thing only when the edges of the
polygon that are clipped are perpendicular to the clipping boundary.
Otherwise, it changes the orientation of those edges.
Re: clipping with polyfill [message #29949 is a reply to message #29948] Tue, 26 March 2002 12:11 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Charlie Zender (zender@uci.edu) writes:

> I am using IDL 5.2 under Linux and having problems with clipping.
> I am using polyfill to shade regions on an xy plot.
> Some of the polygon vertices fall outside the axis ranges and so
> I want to clip the polyfill so that the shading stays within the axes,
> and so that the filling does not obscure the tickmarks on the axes,
> so I do
>
> clp=[!x.crange(0)+0.5,!y.crange(0),!x.crange(1)-0.5,!y.crang e(1)]
> polyfill,x,y,clip=clp
>
> but the results show no clipping. the values of !x,y.crange all
> look reasonable so I am confused why the clipping does not appear to
> work either on screen or when sent to postscript. Any ideas?

The CLIP keyword only works with vector output with
the POLYFILL command. You aren't using vector output. :-(

I can imagine how to do your own clipping in the X direction
of the plot (where values are increasing in value), but I can't
see how to clip in the Y direction without a LOT of trouble.
(It's no picnic for the X direction, but--as I say--I can
imagine how it is done, given the previous constraints of your
problem.

I guess the question is, how general does this have to be?
If you want to clip on "data boundaries", it is easy, you
just do something like this:

Polyfill, xclip[0] > [x1, Reverse(x2)] < xclip[1], $
[y1, Reverse(y2)], Color=100

Where the xclip vector just contains the x data values
where you want to clip. If you want to clip in an
arbitrary way, you are going to have to find out
which data value is closest to your clipping point
(you can use a distance test), and either replace
that value (or the one next to it) with the clipping
value (depending upon whether the data value is greater
or lesser than the clipping value) before you clamp
as above.

It's a lot of trouble for sure. But if your problem is
constrained enough, you may be able to get it to work.

Cheers,

David

>
> I was also surprised that postscript printing does not support the
> pattern fill option in polyfill, but at least the manual documented
> this "feature".
>
>

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Leaking objects...
Next Topic: Re: Vector Graphics in IDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 10:51:44 PDT 2025

Total time taken to generate the page: 0.08386 seconds