Hi, I am working on a triangular mesh of data, and I am trying to
interpolate values that are between vertices. I have come up with the
following method:, based on Gael's previous examples. However, I always get
an array of 0.0 for output.
Thanks!
--Tom
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # #
from enthought.mayavi import mlab
mesh=mlab.pipeline.triangular_mesh_source(x,y,z,tri,scalars=volt)
def interpolate_voltage(x,y,z,mesh):
delaunay = mlab.pipeline.delaunay3d(mesh)
unstructured_grid = delaunay.outputs[0]
from enthought.tvtk.api import tvtk
shape=x.shape
x = np.atleast_1d(x)
y = np.atleast_1d(y)
z = np.atleast_1d(z)
probe_data=tvtk.PolyData(points=np.c_[x.ravel(),y.ravel(),z.ravel()])
probe = tvtk.ProbeFilter()
probe.input = probe_data
probe.source = unstructured_grid
probe.update()
values = probe.output.point_data.scalars.to_array()
values = np.reshape(values, shape)
return values
X,Z=np.meshgrid(np.linspace(min(x),max(x),5),np.linspace(min(z),max(z),5))
X=X.flatten()
Z=Z.flatten()
Y=np.zeros(X.shape)
interpVolt=interpolate_voltage(X,Y,Z,mesh)
print interpVolt
mlab.pipeline.surface(mesh)
#mlab.points3d(X,Y,Z,interpVolt,scale_mode='scalar',scale_factor=3e-3)
mlab.points3d(X,Y,Z,scale_mode='scalar',scale_factor=3e-3)
mlab.show()
------------------------------------------------------------------------------
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
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users