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
def __init__(self, new_engine=False, param=None): ''' Input: param: object of GraphPlotParam class ''' if param is None: param = GraphPlotParam() self.TubeColor = param.TubeColor self.TubeRadius = param.TubeRadius self.GylphColor = param.GylphColor self.GylphSize = param.GylphSize self.TubeMode = { 'radius_by_scale': False, 'radius_by_color': False, 'type_by_color': False, 'branching_by_color': False, 'flow_by_color': False, 'pressure_by_color': False } # start engine if new_engine: from mayavi.core.api import Engine e = Engine() e.start() # source self.DataSource = scalar_scatter([], [], []) self.Data = self.DataSource.data self.Nodes = self.Data.points self.Edges = self.Data.lines #modules self.Glyph = glyph(self.DataSource) self.Glyph.glyph.glyph.clamping = True self.Glyph.glyph.glyph.scale_factor = 2.0 self.Glyph.glyph.glyph.range = np.array([0., 1.]) self.Glyph.glyph.color_mode = 'no_coloring' self.Glyph.glyph.scale_mode = 'data_scaling_off' self.Glyph.actor.property.representation = 'wireframe' self.Glyph.actor.property.color = (0.75, 0.25, 0.25) self.Tube = tube(self.Glyph, tube_radius=self.TubeRadius) self.TubeSurface = surface(self.Tube, color=self.TubeColor) self.Tube.filter.vary_radius = 'vary_radius_off' self.TubeSurface.actor.mapper.scalar_visibility = False
def __init__(self, s=None, param=None, new_engine=False): ''' input: param: object from StackPlotParam ''' # if s is None: # print('Noe input surface model') # return if param is None: param = StackPlotParam() self.SurfaceColor = param.SurfaceColor self.SurfaceOpacity = param.SurfaceOpacity # start engine if new_engine: from mayavi.core.api import Engine e = Engine() e.start() # source self.DataSource = scalar_field( (np.random.rand(5, 5, 5) > 0.5).astype(int)) self.DataSource.origin = [0, 0, 0] self.Data = self.DataSource.scalar_data self.DataSource.origin = np.array([0, 0, 0]) #modules self.Contour = contour(self.DataSource) self.Contour.filter.contours = [] self.Contour.filter.contours = [0.5] self.Contour.filter.auto_update_range = False self.Surface = None self.__UpdateSurface()
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() #renderLearningData('pattern.json') #scene = e.new_scene() #renderLearningData('pattern2.json') #renderLearningData('pattern3.json') scene = e.new_scene() ExampleRenderer('cluster.json', scene) scene = e.new_scene() ExampleRenderer('nocluster.json', scene) show() return e, ui
@author: Schmulius """ from mayavi.modules.scalar_cut_plane import ScalarCutPlane from pyface.timer.api import Timer from mayavi.core.api import Engine from mayavi.core.base import Base from mayavi.core.module import Module from mayavi.core.lut_manager import LUTManager from mayavi.core.common import handle_children_state, exception from mayavi.core.pipeline_info import PipelineInfo scp = Engine() scp.start() scene = scp.new_scene() scp = ScalarCutPlane() # set scp as ScalarCutPlane() module # 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 = True 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]
# -*- coding: utf-8 -*- """ Spyder Editor """ import os from mayavi.core.api import Engine from mayavi.sources.vtk_file_reader import VTKFileReader from mayavi.modules.surface import Surface vtkFile_l = '/Users/richad/bin/lh.vtk' vtkFile_r = '/Users/richad/bin/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 surface1 = Surface() reader1 = VTKFileReader() reader1.initialize(vtkFile_l) engine.add_source(reader1) engine.add_filter(surface1, reader1) surface2 = Surface() reader2 = VTKFileReader() reader2.initialize(vtkFile_r) engine.add_source(reader2) engine.add_filter(surface2, reader2) #import networkx as nx
Created on Mon Jan 4 18:14:18 2016 @author: ethansolomon """ import os from mayavi.core.api import Engine from mayavi.sources.vtk_file_reader import VTKFileReader 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)