[vtk-developers] Structured Grid
Alessandro Artusi
artusialessandro4 at googlemail.com
Tue Oct 20 03:36:00 EDT 2009
Dear All,
What i want to do is the following:
- I am reading volume data from a netCDF file
- I want to compute the isosurfaces
I am able to do both of them using a rectilinear grid, so as I have the
isosurfaces on a rectilinear shape including the depth,
but when I try to map these data on a sphere (using conversion from
cartesian to spherical) using StructuredGrid and I visualise the result
seems that the depth dissapear and I have as result a circle.
The code to map the latitude, longitude and depth to X,Y,Z for mapping to
sphere is the following:
# Convresion to spherical coordinates
E_Radius = 6370
gamma = 10
volume = empty(shape=(len(zc), len(xc), len(yc)), dtype=float32, order='C')
coordinates = array([0,0,0], dtype=int)
lats = xc.getValue()
longs = yc.getValue()
depths = zc.getValue()
# I generate a vtk Points data structure where to put the coordinates
points = vtk.vtkPoints()
points.Allocate(10, len(xc)*len(yc)*len(zc))
# I start the conversion of teh coordinates, the volume data are transfered
in a 3-D array
# the coordinates are in 1-D array with offset to relate the coordinate to
the volume pixel. I did
# also without this offset but the result si the same
for k in range(len(zc)):
kOffset = k * len(xc) * len(yc)
for i in range(len(xc)):
iOffset = i * len(yc)
for j in range(len(yc)):
coordinates[0] = (E_Radius + gamma*k) * cos(lats[i]) * cos(longs[j])
# x
coordinates[1]= (E_Radius + gamma*k) * cos(lats[i]) * sin(longs[j]) #
y
coordinates[2] = (E_Radius + gamma*k) * sin(lats[i]) # z
Offset = j + kOffset + iOffset
points.InsertPoint(Offset,coordinates)
volume[k,i,j] = var[0,k,i,j] # have also put the volume data in a 1-D
array indexing # thedata with the
Offset but no way
array_data = nm_to_vtk_array(volume, float32)
result = vtk.vtkStructuredGrid()
result.SetDimensions(len(zc), len(xc), len(yc))
result.SetPoints(points)
result.GetPointData().SetScalars(array_data)
return result
i have no idea why not a sphere but a circle is coming out.
Any Help?
Thanks a lot,
Alessandro.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20091020/9a92ef61/attachment.html>
More information about the vtk-developers
mailing list