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

Home » Public Forums » archive » Using POLYGON to plot unstructred mesh
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
Using POLYGON to plot unstructred mesh [message #86164] Tue, 15 October 2013 02:23 Go to next message
Laurent Testut is currently offline  Laurent Testut
Messages: 7
Registered: May 2011
Junior Member
Hi all,
I need to plot a mesh from an unstructured ocean model. I had a quick look to the POLYGON and IDLgrPOLYGON object which seem to me an interesting way of loading of viewing the mesh (not sure it is the best solution).
Has I'm not used with object-oriented programming I'm wondering if there is a simple way to assign to the vertices, in addition to the classical X,Y (Z) properties, others properties like depths, tidal amplitude, etc ...

Many thanks,
Laurent
Re: Using POLYGON to plot unstructred mesh [message #86249 is a reply to message #86164] Mon, 21 October 2013 12:26 Go to previous messageGo to next message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Laurent Testut wrote, On 2013-10-15 2:23am:
> Hi all,
> I need to plot a mesh from an unstructured ocean model. I had a quick look to the POLYGON and IDLgrPOLYGON object which seem to me an interesting way of loading of viewing the mesh (not sure it is the best solution).
> Has I'm not used with object-oriented programming I'm wondering if there is a simple way to assign to the vertices, in addition to the classical X,Y (Z) properties, others properties like depths, tidal amplitude, etc ...
>
> Many thanks,
> Laurent
>

Hi Laurent,

As I understand it, if you're using an "unstructured grid" model, with vertices
and a connectivity list, that is exactly what IDLgrPolygon and the Polygon
function work with. Whether your grid has only (x,y) position data or (x,y,z),
IDL has good tools for working with this. Depending on what you want to do,
associating the other properties can be done in different ways. With a little
more detail (Is your mesh 2-D or 3-D? What kind of display of your other
properties are you looking for?), I can offer some suggestions.

--

Cheers,
-Dick

Dick Jackson Software Consulting
Victoria, BC, Canada
www.d-jackson.com
Re: Using POLYGON to plot unstructred mesh [message #86287 is a reply to message #86249] Wed, 23 October 2013 04:54 Go to previous messageGo to next message
Laurent Testut is currently offline  Laurent Testut
Messages: 7
Registered: May 2011
Junior Member
Hi Dick,
Thanks for your reply, specially because the POLYGON is obviously not a sexy subject in this newsgroup :). You clearly understood my needs.

My mesh is a 2D mesh from ADCIRC model (which I was able to visualize )
> oModel = OBJ_NEW('IDLgrModel')
> oPolygon = OBJ_NEW('IDLgrPolygon', vertices, POLYGONS = connectivity, STYLE = 1)
> oPolygon->SetProperty, STYLE=1, thick=1
> oModel->Add, oPolygon
> XOBJVIEW, oModel, /BLOCK, TITLE = 'Original Mesh'

I want now to be able to plot some properties of my model (bathymetry, rugosity, velocity, etc) at each grid node or some properties associate with each triangle (surface, ...). I also want to be able to simply visualize the boundaries with a different color and to plot the polygon segments with a size (km) dependant color scale (each segments has color with depend on his length (in km). As you can see I want to do a lot of things. I was wondering if there is a simple way to associate to my polygon (x,y) and connectivity some additional 'properties/data' (bathy, velocity, ...) which can be easily added to my polygon objects and then plotted.

Thanks for your help,
Laurent
Re: Using POLYGON to plot unstructred mesh [message #86320 is a reply to message #86287] Fri, 25 October 2013 14:36 Go to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Laurent Testut wrote, On 2013-10-23, 4:54am:
> Hi Dick, Thanks for your reply, specially because the POLYGON is obviously
> not a sexy subject in this newsgroup :). You clearly understood my needs.
>
> My mesh is a 2D mesh from ADCIRC model (which I was able to visualize )
>> oModel = OBJ_NEW('IDLgrModel') oPolygon = OBJ_NEW('IDLgrPolygon',
>> vertices, POLYGONS = connectivity, STYLE = 1) oPolygon->SetProperty,
>> STYLE=1, thick=1 oModel->Add, oPolygon XOBJVIEW, oModel, /BLOCK, TITLE =
>> 'Original Mesh'
>
> I want now to be able to plot some properties of my model (bathymetry,
> rugosity, velocity, etc) at each grid node or some properties associate with
> each triangle (surface, ...). I also want to be able to simply visualize the
> boundaries with a different color and to plot the polygon segments with a
> size (km) dependant color scale (each segments has color with depend on his
> length (in km). As you can see I want to do a lot of things. I was wondering
> if there is a simple way to associate to my polygon (x,y) and connectivity
> some additional 'properties/data' (bathy, velocity, ...) which can be easily
> added to my polygon objects and then plotted.
>
> Thanks for your help, Laurent

Great, thanks for the detail. You're looking for full control of colours of
polygon fills, segments and perhaps vertices as well.

The IDLgrPolygon class is an efficient way to work with such meshes if you don't
need more flexibility than it offers.

Using one IDLgrPolygon object, created in the usual way (with vertices shared
between triangles) and its Vert_Colors property, you can indeed control the
colour of the polygon fills (Style=2) or the colour of the segments (Style=1),
or by using two of them you could have segments overlaid on the filled mesh
using different sets of colours. Why stop there? A third object with Style=0
could have yet another set of colours used to make points at each vertex! When
you want a different dataset represented, you just use
object -> SetProperty, Vert_Colors=newValues
and the next time it is rendered, the new colours are used.

However, for the polygon fills, "The color of the first vertex in each polygon
is used to define the color for the entire polygon." This is a problem for your
task, as there can be more triangles than vertices, and it would be difficult to
coordinate this for perfect triangle-colour control. For segment colours, there
would be similar issues.

Now, it's possible, although a little less efficient, to create the mesh with
three new vertices for each triangle, and control of the fill colour is then
easy. Similarly, the polygon segments could be duplicated in an IDLgrPolyline
object, also with Vert_Colors, where, "the color of a line segment is the color
of the second vertex of that line segment."

(Another possibility is to work with a texture map image created to show your
data, but I'm not sure that is quite what you're looking for.)

It seems that the Function Graphics POLYGON and POLYLINE have the same sets of
features as the IDLgr* classes, so it's possible to go that way as well. I think
a well-constructed object class, with these properties associated with its
polygons and its mesh segments, and a widget program to allow control of display
of these features, would be a very feasible project in IDL.

One more thing: You've spoken of this as a 2-D mesh, but of course, with
bathymetry data added as the Z values, you will get a 3-D surface rendering of
the ocean floor!

Lots of ideas, and I'd be happy to discuss this further.

--

Cheers,
-Dick

Dick Jackson Software Consulting
Victoria, BC, Canada
www.d-jackson.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: (Beginner) issue setting variables using ENVI_FILE_QUERY
Next Topic: Using Y_SCROLL_SIZE and COLUMN=8 on Mac widgets

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

Current Time: Wed Oct 08 15:14:16 PDT 2025

Total time taken to generate the page: 0.00726 seconds