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

Home » Public Forums » archive » MESH_DECIMATE Gotcha
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
MESH_DECIMATE Gotcha [message #56611] Fri, 02 November 2007 13:49
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

I just wasted another couple of hours on this, so I thought
I would mention it. (And perhaps write a small article about
it.)

I had a "blob" and I wanted to save this thing as a shapefile.
So I found the perimeter points of the blob with my FIND_BOUNDARY
program. But, because this program uses a chain-code algorithm,
the points are densely spaced (in fact, the pixels are right
next to one another). I wanted to eliminate a great many of
these points that were "over-determining" my polygon. So I
thought to use MESH_DECIMATE.

It seemed straightforward. My original polygon was a
3 by 701 array. I need that and a "connectivity array"
to pass to MESH_DECIMATE. The connectivity array is
simple. Since each point in the polygon is connected to the
next, it looks like conn=Lindgen(701).

OK, so I call MESH_DECIMATE like this:

nverts = MESH_DECIMATE(polygon, conn, connout, $
VERTICES=newVertices, PERCENT_VERTICES=30)

And, EVERYTIME I did so IDL would crash completely, in both
IDL 6.3 and 6.4 and on both my Windows PC and my LINUX PC.
Yikes!!

After MUCH consternation and fooling around, I noticed in a part
of the documentation far, far away from the MESH_DECIMATE documentation
that connectivitiy arrays should be specified in counter-
clockwise fashion. Of course, my chain-code algorithm works in
clockwise fashion. So I try reversing the connectivity array,
like this:

nverts = MESH_DECIMATE(polygon, REVERSE(conn), connout, $
VERTICES=newVertices, PERCENT_VERTICES=30)

That works perfectly!

Now I have a closer look at the MESH_DECIMATE documentation.
Here is how the connectivity array is described:

CONN Input polygonal mesh connectivity array.

I read the whole damn page again. Finally, I find this:

"For best results, all the polygons in the input mesh
should be convex."

No shit! For those of you who don't know, "convex" means
specified in a counter-clockwise fashion. I learned that
somewhere, but NOT in the IDL documentation. :-(

Just a word to the wise.

Cheers,

David

P.S. Maybe later this weekend I'll describe my adventure
getting the shapefile thing to work correctly. :-(

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Previous Topic: Openw and printf
Next Topic: SYLK

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

Current Time: Sat Oct 11 13:42:53 PDT 2025

Total time taken to generate the page: 0.64259 seconds