def get_mayavi_cubic_arena_source(engine, info=None): v = info['verts4x4'] # arranged in 2 rectangles of 4 verts points = v lines = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4], [1, 5], [2, 6], [3, 7]] if 0: import enthought.mayavi.tools.mlab as mlab for lineseg in lines: p0 = points[lineseg[0]] p1 = points[lineseg[1]] x = np.array([p0[0], p1[0]]) y = np.array([p0[1], p1[1]]) z = np.array([p0[2], p1[2]]) mlab.plot3d(x, y, z) #polys = numpy.arange(0, len(points), 1, 'l') #polys = numpy.reshape(polys, (len(points), 1)) pd = tvtk.PolyData( points=points, #polys=polys, lines=lines) e = engine e.add_source(VTKDataSource(data=pd, name='cubic arena')) s = Surface() e.add_module(s)
def plot_stiffness(self, editor, object): '''This method gets the input data from the current tstepper which is the root of the tree. Sets up the context and gets the stiffness matrix. ''' K = self._get_stiffness(editor, object) K_dense = DenseMtx(assemb=K) # prepare plotting of the matrix in Mayavi # z_data = K_dense.mtx.flatten() z_max = max(z_data) n_dofs = K.n_dofs spoints = tvtk.StructuredPoints(origin=(0, 0, 0), spacing=(1, -1, 1), dimensions=(n_dofs, n_dofs, 1)) spoints.point_data.scalars = z_data spoints.point_data.scalars.name = 'Stiffness' e = get_engine() src = VTKDataSource(data=spoints) e.add_source(src) scale_factor = .1 / float(z_max) * n_dofs ws = WarpScalar() ws.filter.scale_factor = scale_factor e.add_filter(ws) e.add_filter(PolyDataNormals()) s = Surface() e.add_module(s)
def rebuild_pipeline(self, pd): src = VTKDataSource(name=self.name, data=pd) self.engine.add_source(src) if self.warp: self.engine.add_filter(WarpVector()) if self.name in src._point_tensors_list: src.point_tensors_name = self.name self.engine.add_filter(ExtractTensorComponents()) elif self.name in src._point_vectors_list: src.point_vectors_name = self.name self.engine.add_filter(ExtractVectorComponents()) elif self.name in src._point_scalars_list: src.point_scalars_name = self.name s = Surface() s.actor.property.point_size = 5. self.engine.add_module(s) src.scene.z_plus_view()
def __init__(self, **kw): e = get_engine() super(MVPolyData, self).__init__(**kw) from mayavi.modules.api import Outline, Surface, Labels self.src = VTKDataSource(name=self.name, data=self.pd) e.add_source(self.src) o = Outline() e.add_module(o) s = Surface() e.add_module(s)
def __init__(self, **kw): e = get_engine() super(MVPointLabels, self).__init__(**kw) from mayavi.modules.api import Outline, Surface, Labels self.src = VTKDataSource(name=self.name, data=self.pd) e.add_source(self.src) self.labels = Labels(name='Node numbers', object=self.src, label_format='%g', number_of_labels=100) self.labels.property.color = self.color e.add_module(self.labels)
def __init__(self, **kw): super(MVStructuredGrid, self).__init__(**kw) e = get_engine() from mayavi.modules.api import \ StructuredGridOutline, GridPlane self.src = VTKDataSource(name=self.name, data=self.pd) e.add_source(self.src) o = StructuredGridOutline() e.add_module(o) for axis in ['x', 'y', 'z']: g = GridPlane(name='%s - grid plane' % axis) g.grid_plane.axis = axis e.add_module(g) if self.scalars or self.vectors or self.tensors: s = Surface() e.add_module(s)
def __init__(self, g): HasTraits.__init__(self) self.src = VTKDataSource(data=g)