Mayavi Triangular Mesh?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Mayavi Triangular Mesh?

Dimagiba, Lorenzo
Hi,

I'm trying to make use of mayavi's triangular mesh, but it doesn't seem to be working out properly. I keep getting an error

"The triangles indices must be smaller than the number of points".

Any ideas what is causing this? My set of points and faces should work as they are able to produce what I want in matlab.

Lorenzo

This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient.
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited.
If you have received this e-mail in error, please contact the sender and delete all copies.
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Mayavi Triangular Mesh?

Eric Carlson
Matlab indices start at 1, python at 0 -> subtract 1 from your index array

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Dimagiba, Lorenzo
Sent: Tuesday, January 08, 2013 10:01 AM
To: [hidden email]
Subject: [Enthought-Dev] Mayavi Triangular Mesh?

Hi,

I'm trying to make use of mayavi's triangular mesh, but it doesn't seem to be working out properly. I keep getting an error

"The triangles indices must be smaller than the number of points".

Any ideas what is causing this? My set of points and faces should work as they are able to produce what I want in matlab.

Lorenzo

This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient.
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited.
If you have received this e-mail in error, please contact the sender and delete all copies.
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Mayavi Triangular Mesh?

Dimagiba, Lorenzo
In reply to this post by Dimagiba, Lorenzo
Thanks for the input Eric, but this is most definitely not the problem. Just for testing purposes, I have used different lengths of my index array. Using a significantly shorter array removes the error, but obviously causes my shape to have missing pieces. Does anyone else have experience with the triangular_mesh function?



This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient.
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited.
If you have received this e-mail in error, please contact the sender and delete all copies.
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Mayavi Triangular Mesh?

Rich Signell
Lorenzo,
The code below produces this plot:
http://screencast.com/t/fIK8M6yaQ

"""
An example how to triagonal grid surfaces using MAYAVI/MLAB
"""
# Author: Rich Signell <[hidden email]>
# License: MIT/X

from mayavi import mlab
import netCDF4

# get some ADCIRC triangular mesh results via OPeNDAP
URL = 'http://geoport.whoi.edu/thredds/dodsC/usgs/data1/rsignell/models/adcirc/fort.64.nc'
nc = netCDF4.Dataset(URL)
lon = nc.variables['x'][:]        # lon at nodes
lat = nc.variables['y'][:]        # lat at nodes
h = nc.variables['depth'][:]      # water depth at nodes
nv = nc.variables['element'][:]   # connectivity array
nv = nv-1                         # python is 0-based
z = 0*h                           # create z at MSL

# 3D triangular mesh surface (like trisurf)
# triangular_mesh(lon,lat,z,nv,scalars=-h)
mlab.triangular_mesh(0.74*lon,lat,-h/1000,nv,scalars=-h)
mlab.view(-70,20)                 #set view



-Rich


On Tue, Jan 8, 2013 at 1:14 PM, Dimagiba, Lorenzo
<[hidden email]> wrote:

> Thanks for the input Eric, but this is most definitely not the problem. Just for testing purposes, I have used different lengths of my index array. Using a significantly shorter array removes the error, but obviously causes my shape to have missing pieces. Does anyone else have experience with the triangular_mesh function?
>
>
>
> This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient.
> Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited.
> If you have received this e-mail in error, please contact the sender and delete all copies.
> Opinions, conclusions or other information contained in this e-mail may not be that of the organization.
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev



--
Dr. Richard P. Signell   (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Mayavi Triangular Mesh?

Dimagiba, Lorenzo
In reply to this post by Dimagiba, Lorenzo
Thank you for all the input. I was able to figure it out. It was along the lines of what Eric was saying, perhaps it's exactly what Eric was saying, but it just took me some time to realize.

In which case, what I had been doing was using a matlab function to take .obj files and explicitly take the vertices and put them in an array, and take the face indices and put them in an array. The way obj files are set up however is so that the face indices refer to the first vertex as 1, as opposed to 0. Therefore all that needs to be done is to subtract 1 from all the values face index array.

This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient.
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited.
If you have received this e-mail in error, please contact the sender and delete all copies.
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev