def view(): from enthought.mayavi.sources.vtk_data_source import VTKDataSource from enthought.mayavi.modules.outline import Outline from enthought.mayavi.modules.surface import Surface from enthought.mayavi.modules.vectors import Vectors from enthought.mayavi.modules.api import TensorGlyph from enthought.mayavi.filters.api import WarpVector, ExtractTensorComponents mayavi.new_scene() wv = WarpVector() tc = ExtractTensorComponents() tc2 = ExtractTensorComponents() # The single type one src = VTKDataSource(data = mesh) print "str1", mesh.point_data.is_array_an_attribute(0) print "id ", mesh.point_data.has_array("d2") mayavi.add_source(src) mayavi.add_filter(wv) src.add_child(tc) tc.add_module(Surface()) #src.add_child(Surface()) mesh.point_data.set_active_tensors('first') src2 = VTKDataSource(data = mesh) mayavi.add_source(src2) #tg = TensorGlyph() #tg.glyph.glyph.scale_factor = 100. #mayavi.add_module(tg) #mayavi.add_module(Surface()) #mayavi.add_module(Vectors()) src2.add_child(tc2) tc2.add_module(Surface()) tc2.scene.z_plus_view()
def add_points(self, points): g = mlab.Glyphs(points, None, None) d = VTKDataSource() d.data = g.poly_data self.scene.add_child(d) v = Vectors() v.glyph.color_mode = "no_coloring" v.glyph.glyph_source = tvtk.PointSource(radius=0, number_of_points=1) d.add_child(v)
def add_points(self, points): g = mlab.Glyphs(points, None, None) d = VTKDataSource() d.data = g.poly_data self.scene.add_child(d) v = Vectors() v.glyph.color_mode = 'no_coloring' v.glyph.glyph_source = tvtk.PointSource(radius=0, number_of_points=1) d.add_child(v)
def add_source_data(self, data): from enthought.mayavi.filters.poly_data_normals import PolyDataNormals d = VTKDataSource() d.data = data obj = self.scene.add_child(d) w = WarpScalar() d.add_child(w) n = PolyDataNormals() n.filter.feature_angle = 45 w.add_child(n) s = Surface() n.add_child(s)
def add_source_data(self, data): from enthought.mayavi.filters.poly_data_normals import PolyDataNormals d = VTKDataSource() d.data = data obj = self.scene.add_child(d) w = WarpScalar() d.add_child(w) n = PolyDataNormals() n.filter.feature_angle = 45 w.add_child(n) s = Surface() n.add_child(s)
def add_lines(self, points): np = len(points) - 1 lines = scipy.zeros((np, 2), "l") lines[:, 0] = scipy.arange(0, np - 0.5, 1, "l") lines[:, 1] = scipy.arange(1, np + 0.5, 1, "l") pd = tvtk.PolyData(points=points, lines=lines) d = VTKDataSource() d.data = pd self.scene.add_child(d) filter = tvtk.TubeFilter(number_of_sides=6) filter.radius = 0.01 f = FilterBase(filter=filter, name="TubeFilter") d.add_child(f) s = Surface() s.actor.mapper.scalar_visibility = False d.add_child(s)
def add_lines(self, points): np = len(points) - 1 lines = scipy.zeros((np, 2), 'l') lines[:,0] = scipy.arange(0, np-0.5, 1, 'l') lines[:,1] = scipy.arange(1, np+0.5, 1, 'l') pd = tvtk.PolyData(points=points, lines=lines) d = VTKDataSource() d.data = pd self.scene.add_child(d) filter = tvtk.TubeFilter(number_of_sides=6) filter.radius = 0.01 f = FilterBase(filter=filter, name='TubeFilter') d.add_child(f) s = Surface() s.actor.mapper.scalar_visibility = False d.add_child(s)