Steve Juranich a écrit :
> I'm trying to get my head around how the Volume module is working.  I saw in
> the documentation that the module requires the scalar data to be either
> chars or shorts (Is that right?  What is the reason for this restriction?).
>
> So in the interest of just getting something pretty on my screen, I create
> some data with the following script:
>
> -- <mkdata.py> --
> #! /usr/bin/env python
>
> import vtk
>
> points = vtk.vtkPoints()
> for z in xrange(3):
>     for y in xrange(3):
>         for x in xrange(3):
>             points.InsertNextPoint(x, y, z)
>
> vals = vtk.vtkShortArray()
> vals.SetName('simple')
> for i in xrange(27):
>     vals.InsertNextValue(i + 1)
>
> sg = vtk.vtkStructuredGrid()
> sg.SetPoints(points)
> sg.GetPointData().SetScalars(vals)
>
> w = vtk.vtkXMLStructuredGridWriter()
> w.SetFileName('simple_cube.vts')
> w.SetInput(sg)
>
> w.Write()
> -- </mkdata.py> --
>   
Hi,

May be too late, but I think you miss to set the Extent required for 
StructuredGrid.

Try:

sg = vtkStructuredGrid()
sg.SetExtent(0, 3, 0, 3, 0, 3)
sg.SetPoints(points)
sg.GetPointData().SetScalars(scalars)

HTH

-- 
http://scipy.org/FredericPetit


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to