def main(): # Create the MayaVi engine and start it. e = Engine() # Starting the engine registers the engine with the registry and # notifies others that the engine is ready. e.start() # Do this if you need to see the MayaVi tree view UI. ev = EngineView(engine=e) ui = ev.edit_traits() # Create a new scene. scene = e.new_scene() # Now create a new scene just for kicks. scene1 = e.new_scene() # Now setup a normal MayaVi pipeline. src = VTKXMLFileReader() src.initialize(join(get_data_dir(abspath(__file__)), 'fire_ug.vtu')) e.add_source(src) e.add_module(Outline()) e.add_module(ScalarCutPlane()) e.add_module(Streamline()) return e, ui
vtkFile = 'flow.vtk' # Create the MayaVi engine and start it. engine = Engine() engine.start() scene = engine.new_scene() # Read in VTK file and add as source reader = VTKFileReader() reader.initialize(vtkFile) engine.add_source(reader) # Add Surface Module surface = Surface() engine.add_module(surface) # Move the camera scene.scene.camera.elevation(-70) # Save scene to image file scene.scene.save_png('image.png') # Create a GUI instance and start the event loop. # This stops the window from closing from enthought.pyface.api import GUI gui = GUI() gui.start_event_loop() #(text processing)
engine = Engine() engine.start() scene = engine.new_scene() #vtkFile = 'simple.vtk' vtkFile = '/volumes/esd01/docs/jloos/data_small/runs_elmerice_refined/Mesh60_200500_0/Bump_0001.pvtu' #reader = VTKFileReader() #reader = VTKXMLFileReader() #reader.initialize(vtkFile) #engine.add_source(reader) # Add Surface Module #surface = Surface() #engine.add_module(surface), scp = ScalarCutPlane() # set scp as ScalarCutPlane() module engine.add_module(scp) # add module to the scene scp.implicit_plane.normal = (1, 0, 0) # set normal to Ox axis # set origin to (i=10, j=25, k=25) i.e. integers for a structured grid scp.implicit_plane.origin = (10, 25, 25) # set origin to (x=1.0, y=2.5, z=2.5) i.e. reals for unstructured grids # scp.implicit_plane.origin = (1.0, 2.5, 2.5) scp.implicit_plane.widget.enabled = False scp.actor.property.diffuse = 0.0 # set some color properties scp.actor.property.ambient = 1.0 # scp.actor.property.opacity = 1.0 # scp.module_manager.scalar_lut_manager.data_range = [0, 1]
from mayavi.modules.surface import Surface vtkFile_l = 'lh.vtk' vtkFile_r = 'rh.vtk' # Create the MayaVi engine and start it. engine = Engine() engine.start() scene = engine.new_scene() # Read in VTK file and add as source reader1 = VTKFileReader() reader1.initialize(vtkFile_l) engine.add_source(reader1) # Add Surface Module surface = Surface() engine.add_module(surface) # Move the camera scene.scene.camera.elevation(90) scene.scene.camera.azimuth(-180) # Save scene to image file scene.scene.save_png('image.png') # Create a GUI instance and start the event loop. # This stops the window from closing from pyface.api import GUI gui = GUI() gui.start_event_loop()
if len(engine.scenes) == 0: engine.new_scene() #--------------------------------------------------------------------------------------- #__________________________________ load data ____________________________________# #--------------------------------------------------------------------------------------- vtkxml_file_reader = engine.open( '/Volumes/esd01/docs/jloos/data_small/runs_elmerice_refined/Mesh20_5001000_0_0.1/Mesh/ForwardRemesh100M20L0011.pvtu' ) # Set time-step for visualisation; depending on simulation setting time-step cann range between # 0.1 and 0.5 = 2 (two time sizes 1a) from mayavi.modules.surface import Surface surface = Surface() engine.add_module(surface, obj=None) # Set timestep for visualisation # only depends on pvtu, choose random pvtu and then set time step #vtkxml_file_reader = engine.scenes[0].children[0] #vtkxml_file_reader.name = 'VTK XML file (ForwardRemesh100M20L0004.pvtu) (timeseries)' #vtkxml_file_reader.file_path = '/Volumes/esd01/docs/jloos/data_small/runs_elmerice_refined/Mesh20_5001000_0_0.1/Mesh/ForwardRemesh100M20L0004.pvtu' vtkxml_file_reader.timestep = 3 #--------------------------------------------------------------------------------------- #_______________________________ Set scene_______________________________# #--------------------------------------------------------------------------------------- # Arrange dataset and frame for scene. Choose between set of point scalar names # (ds/dt, groundedmask,...)and point vector names (velocity,,...) # set scale(aspect ratio) between 20-30 for better visualisation