Hello,

I wonder if someone could help me?

I am trying to generate a series of cut planes as images
using NONGUI_PLUGIN_DEFINITIONS as per the example script
and using a python loop to move a ScalarCutPlane and write
a new image to file for each iteration.

I've appended the script that I've used to do this. As far
as possible I've tried to follow examples from the example
scripts to minimise madness creeping into the code.

The two problems I'm having are:

1) NONGUI_PLUGIN_DEFINITIONS doesn't appear to actually run
   without a GUI; I'm guessing from comments and from the 'Tips'
   section of the Mayavi site that this is a known issue and the
   best bet for now is to stick with the xvfb hack. Is this the
   case?

2) When I reset the depth of my cut plane using:

   cp.implicit_plane.origin=(1, -1, od)

   where cp = ScalarCutPlane() and od is the value of depth 
   which changes on each loop iteration, the rendered plane
   doesn't actually change from image to image. I've tried
   loading the VTU in an interactive session, dragging the 
   cut plane to the python command shell, and changing this
   by hand - it still doesn't change immediately, but when
   I click on the display it moves the plane outline and when
   I click on the grid outline it moves the rendered plane.

   I guess there is something I should call to update the 
   display having changed the plane origin, but I haven't been
   able to track it down! Advice would be much appreciated.

If there's anything I'm doing in a really crackpot way I would
appreciate correction and guidance :-)

Thanks in advance for any help,

Tim

Script is as follows:

#!/usr/bin/env python

from enthought.mayavi.app import Mayavi, NONGUI_PLUGIN_DEFINITIONS

import sys

class MyClass(Mayavi):

    def run(self):

       from enthought.mayavi.sources.vtk_xml_file_reader import VTKXMLFileReader
       from enthought.mayavi.modules.surface import Surface
       from enthought.mayavi.modules.text import Text
       from enthought.mayavi.modules.scalar_cut_plane import ScalarCutPlane

       script = self.script

       fg_color = (0.1, 0.1, 0.2)
       bg_color = (1, 1, 0.8)

       script.new_scene()

       src = VTKXMLFileReader()
       src.initialize("output.vtu")
       script.add_source(src)

       sfc = Surface()
       script.add_module(sfc)
       sfc.actor.property.representation='wireframe'
       sfc.actor.property.opacity=0.03

       t = Text()
       script.add_module(t)
       t.actor.scaled_text = False
       t.actor.text_property.font_size = 34
       t.actor.text_property.color = fg_color
       t.width = 
1.0*t.actor.mapper.get_width(t.scene.renderer)/t.scene.renderer.size[0]
       height = 
1.0*t.actor.mapper.get_height(t.scene.renderer)/t.scene.renderer.size[1]
       t.x_position = 0.5-t.width/2
       t.y_position = 1-height
       t.scene.background = bg_color
       t.scene.z_minus_view()
       t.scene.camera.zoom(1.5)

       cp = ScalarCutPlane()
       script.add_module(cp)
       cp.implicit_plane.normal = 0,0,1
       cp.implicit_plane.widget.enabled=False
       cp.module_manager.scalar_lut_manager.use_default_range = False
       cp.module_manager.scalar_lut_manager.data_range = [-0.00005, 0.00005]

       s = script.engine.current_scene

       for depth in range (0,6000,1000):
          od = depth/10000
          cp.implicit_plane.origin=(1, -1, od)
          t.text = 'Output ' + str(depth) + 'm'
          filename = 'cutplane' + str(depth) + '.jpg'
          s.scene.save(filename)

if __name__ == '__main__':

    mc = MyClass()
    mc.main(plugin_defs=NONGUI_PLUGIN_DEFINITIONS)



-- 
Dr. Timothy M Bond, Operations Manager
Applied Modelling and Computation Group
http://amcg.ese.ic.ac.uk/index.php?title=Dr_Tim_Bond

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to