Dear all,

as a quick inspection of simulation results I would like to add a Python function that takes a VTK file (3D tetrahedral grid with cell data) and opens a mayavi window with an interactive slicer. Is that technically possible and could you point me in the right direction? For the time being my code only visualizes the gridpoints:

   def showMesh3D(mesh, interactive=True):
        """
        Proof of concept for mayavi binding.
        """

        # should avoid opening of mayavi window when building documentation
        if not interactive:
            mlab.options.offscreen = True

        fig = mlab.figure(bgcolor=(1, 1, 1), size=(400, 400))

        # temporary VTK write & read, may be replaced with direct VTK
   object.
        tmp = "/tmp/3d_view_%s.vtk" % os.getpid()
        mesh.exportVTK(tmp)
        src = mlab.pipeline.open(tmp, figure=fig)
        os.remove(tmp)

        surf = mlab.pipeline.surface(src, figure=fig, opacity=0.5)
        edges = mlab.pipeline.extract_edges(surf, figure=fig)
        mlab.pipeline.surface(edges, color=(0, 0, 0), figure=fig)
        #mlab.pipeline.image_plane_widget(surf, colormap='gray',
                                         #plane_orientation='x_axes')


Thanks a lot,
Florian
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to