예제 #1
0
파일: actors.py 프로젝트: victorliun/mayavi
def earth_actor(radius=0.5, opacity=1.0):
    """ Creates an earth source and returns the actor. """
    source = tvtk.EarthSource(radius=radius, on_ratio=16, outline=0)
    mapper = tvtk.PolyDataMapper(input=source.output)
    prop = tvtk.Property(opacity=opacity)
    actor = tvtk.Actor(mapper=mapper, property=prop)
    return actor
예제 #2
0
 def __source_dict_default(self):
     """Default value for source dict."""
     sd = {
         'arrow': tvtk.ArrowSource(),
         'cone': tvtk.ConeSource(),
         'cube': tvtk.CubeSource(),
         'cylinder': tvtk.CylinderSource(),
         'disk': tvtk.DiskSource(),
         'earth': tvtk.EarthSource(),
         'line': tvtk.LineSource(),
         'outline': tvtk.OutlineSource(),
         'plane': tvtk.PlaneSource(),
         'point': tvtk.PointSource(),
         'polygon': tvtk.RegularPolygonSource(),
         'sphere': tvtk.SphereSource(),
         'superquadric': tvtk.SuperquadricSource(),
         'textured sphere': tvtk.TexturedSphereSource(),
         'glyph2d': tvtk.GlyphSource2D()
     }
     return sd
예제 #3
0
    atm_thickness = gchemgrid.c_km_geos5_r.max() * 1e3


# vtk atmosphere thickness vs. earth radius: height scale calculation

ratio_earth_atm = 2.0

earth_radius_scaled = ratio_earth_atm * atm_thickness

# vtk file basemap (sphere, continents)
globe_src = tvtk.SphereSource(radius=earth_radius_scaled -
                              1e-3 * earth_radius_scaled,
                              lat_long_tessellation=True,
                              phi_resolution=gchemgrid.c_lat_4x5.size,
                              theta_resolution=gchemgrid.c_lon_4x5.size)
continents_src = tvtk.EarthSource(on_ratio=1, radius=earth_radius_scaled)

writer = tvtk.XMLPolyDataWriter(input=globe_src.output,
                                file_name=os.path.join(run_dir, "vtk",
                                                       "globe.vtp"))
writer.write()
writer = tvtk.XMLPolyDataWriter(input=continents_src.output,
                                file_name=os.path.join(run_dir, "vtk",
                                                       "continents.vtp"))
writer.write()

# vtk meshes
tfield = filter_results[0].values

lev_offset = earth_radius_scaled + 1e-3 * earth_radius_scaled
lev_scale = 1.0  #atm_thickness / tfield.shape[2]
예제 #4
0
from tvtk.api import tvtk
from tvtk.tools import ivtk
from pyface.api import GUI


def ivtk_scene(actors):
    win = ivtk.IVTKWithCrustAndBrowser()
    win.open()
    win.scene.add_actor(actors)
    return win


def event_loop():
    gui = GUI()
    gui.start_event_loop()


if __name__ == '__main__':
    s = tvtk.EarthSource()
    m = tvtk.PolyDataMapper(input_connection=s.output_port)
    a = tvtk.Actor(mapper=m)
    win = ivtk_scene(a)
    event_loop()
    pass