class Optic(Traceable): abstract=True n_inside = Complex(1.0+0.0j) #refractive n_outside = Complex(1.0+0.0j) all_rays = Bool(False, desc="trace all reflected rays") vtkproperty = tvtk.Property(opacity = 0.4, color = (0.8,0.8,1.0)) def _material_default(self): m = cmaterials.FullDielectricMaterial(n_inside = self.n_inside, n_outside = self.n_outside) return m def calc_refractive_index(self, wavelengths): """ Evaluates an array of (complex) refractive indices. @param wavelengths: a shape=(N,1) array of wavelengths @returns: a 2-tuple representing the inside and outside refractive indices respectively. The items in the tuple can be either 1) an arrays with the same shape as wavelengths and with dtype=numpy.complex128 or 2) a complex scalar """ return self.n_inside, self.n_outside @on_trait_change("n_inside, n_outside") def n_changed(self): self.material.n_inside = self.n_inside self.material.n_outside = self.n_outside self.update = True
class RectWindow(RectMirror, Optic): n_inside = 1.5 name = "Rectangular window" abstract = False traits_view = View( VGroup( Traceable.uigroup, Item('length', editor=NumEditor), Item('width', editor=NumEditor), Item('thickness', editor=NumEditor), Item('offset', editor=NumEditor), Item('n_inside', editor=NumEditor), ), ) vtkproperty = tvtk.Property(opacity=0.4, color=(0.8, 0.8, 1.0)) def _material_default(self): return Optic._material_default(self) def _thickness_changed(self, new_t): self.faces[1].z_plane = new_t def _faces_default(self): m = self.material fl = FaceList(owner=self) fl.faces = [ RectangularFace(owner=self, z_plane=0, material=m), RectangularFace(owner=self, z_plane=-self.thickness, invert_normal=True, material=m) ] return fl
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
def test_property_change_notification(self): """Test if changes to properties generate notification events.""" # Create a dummy class to test with. class Junk: def f(self, obj, name, old, new): self.data = obj, name, old, new z = Junk() cs = tvtk.ConeSource() m = tvtk.PolyDataMapper() if vtk_major_version < 6: m.on_trait_change(z.f, 'input') m.input = cs.output self.assertEqual(z.data, (m, 'input', None, cs.output)) m.input = None self.assertEqual(z.data, (m, 'input', cs.output, None)) m.on_trait_change(z.f, 'input', remove=True) m.input = cs.output else: m.on_trait_change(z.f, 'input_connection') m.input_connection = cs.output_port self.assertEqual(z.data, (m, 'input_connection', None, cs.output_port)) m.input_connection = None self.assertEqual(z.data, (m, 'input_connection', cs.output_port, None)) m.on_trait_change(z.f, 'input_connection', remove=True) m.input_connection = cs.output_port a = tvtk.Actor() a.on_trait_change(z.f, 'mapper') a.on_trait_change(z.f, 'property') a.mapper = m self.assertEqual(z.data, (a, 'mapper', None, m)) old = a.property new = tvtk.Property() a.property = new self.assertEqual(z.data, (a, 'property', old, new)) # Check if property notification occurs on add_input/remove_input a = tvtk.AppendPolyData() pd = tvtk.PolyData() if vtk_major_version < 6: a.on_trait_change(z.f, 'input') a.add_input(pd) old, new = None, pd self.assertEqual(z.data, (a, 'input', old, new)) a.remove_input(pd) old, new = pd, None self.assertEqual(z.data, (a, 'input', old, new)) a.remove_all_inputs() old, new = None, None self.assertEqual(z.data, (a, 'input', old, new)) else: a.add_input_data(pd) self.assertEqual(a.input, pd) a.remove_input_data(pd) self.assertEqual(a.input, None) a.remove_all_inputs() self.assertEqual(a.input, None)
def test_auto_update(self): """Test if traits are updated when the VTK object changes.""" p = tvtk.Property() obj = p._vtk_obj obj.SetEdgeVisibility(1) self.assertEqual(p.edge_visibility, 1) obj.SetOpacity(0.5) self.assertEqual(p.opacity, 0.5) obj.SetRepresentationToPoints() self.assertEqual(p.representation, 'points') # color traits have been made non updateable if vtk_major_version <= 5 and vtk_minor_version < 10: val = (1.0, 1.0, 0.0) obj.SetColor(val) self.assertEqual(p.color, val) val = (1.0, 0.0, 0.0) obj.SetDiffuseColor(val) self.assertEqual(p.diffuse_color, val) val = (0.0, 1.0, 0.0) obj.SetSpecularColor(val) self.assertEqual(p.specular_color, val)
def test_property(self): """Test if Property's color works ok in all circumstances.""" p = tvtk.Property() val = (0., 1., 0.) p.color = val p.specular = 1.0 self.assertEqual(p.specular_color, val) self.assertEqual(p.diffuse_color, val) self.assertEqual(p.ambient_color, val) sc = (1., 0., 1.) p.specular_color = sc self.assertEqual(p.specular_color, sc) self.assertEqual(p.diffuse_color, val) self.assertEqual(p.ambient_color, val) self.assertEqual(p.color, (0.5, 0.5, 0.5)) # Test pickling. s = cPickle.dumps(p) del p p = cPickle.loads(s) self.assertEqual(p.specular_color, sc) self.assertEqual(p.diffuse_color, val) self.assertEqual(p.ambient_color, val) self.assertEqual(p.color, (0.5, 0.5, 0.5))
def test_obj_del(self): """Test object deletion and reference cycles.""" p = tvtk.Property() p.representation = 0 ref = weakref.ref(p) del p self.assertEqual(ref(), None)
def _render_mesh(self, mesh_type="surface", ambient_light=0.0, specular_light=0.0, alpha=1.0): from tvtk.api import tvtk pd = tvtk.PolyData() pd.points = self.points pd.polys = self.trilist pd.point_data.t_coords = self.tcoords_per_point mapper = tvtk.PolyDataMapper() mapper.set_input_data(pd) p = tvtk.Property( representation=mesh_type, opacity=alpha, ambient=ambient_light, specular=specular_light, ) actor = tvtk.Actor(mapper=mapper, property=p) # Get the pixels from our image class which are [0, 1] and scale # back to valid pixels. Then convert to tvtk ImageData. texture = self.texture.pixels_with_channels_at_back(out_dtype=np.uint8) if self.texture.n_channels == 1: texture = np.stack([texture] * 3, axis=-1) image_data = np.flipud(texture).ravel() image_data = image_data.reshape([-1, 3]) image = tvtk.ImageData() image.point_data.scalars = image_data image.dimensions = self.texture.width, self.texture.height, 1 texture = tvtk.Texture() texture.set_input_data(image) actor.texture = texture self.figure.scene.add_actors(actor) self._actors.append(actor)
def arrow_actor(color=colors.peacock, opacity=1.0, resolution=24): """ Creates a 3D Arrow and returns an actor. """ source = tvtk.ArrowSource(tip_resolution=resolution, shaft_resolution=resolution) mapper = tvtk.PolyDataMapper(input=source.output) prop = tvtk.Property(opacity=opacity, color=color) actor = tvtk.Actor(mapper=mapper, property=prop) return actor
def cube_actor(center=(0, 0, 0), color=colors.blue, opacity=1.0): """ Creates a cube and returns the tvtk.Actor. """ source = tvtk.CubeSource(center=center) mapper = tvtk.PolyDataMapper(input=source.output) p = tvtk.Property(opacity=opacity, color=color) actor = tvtk.Actor(mapper=mapper, property=p) return actor
class RectTarget(RectMirror): name = "Beam Stop" thickness = 0.5 vtkproperty = tvtk.Property(opacity=0.4, color=(0, 0, 0)) def _material_default(self): return OpaqueMaterial()
def plot_atoms_3d(self, fig, a, x, y, z): # # !!! works on our molecules only !!! # todo: use some python libraries to draw any molecule # always in order: X, H, H, H, H, O sphere_radius = [0.3, 0.1, 0.1, 0.1, 0.1, 0.2] sphere_color = [(0.0, 0.5, 0.5), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (1.0, 0.0, 0.0)] # draw atoms # ---------- atom = [] for i in range(len(x)): sphere = tvtk.SphereSource(center=(x[i], y[i], z[i]), radius=sphere_radius[i], theta_resolution=80, phi_resolution=80) sphere_mapper = tvtk.PolyDataMapper() configure_input_data(sphere_mapper, sphere.output) sphere.update() p = tvtk.Property(opacity=0.8, color=sphere_color[i]) sphere_actor = tvtk.Actor(mapper=sphere_mapper, property=p) fig.scene.add_actor(sphere_actor) atom.append(sphere_actor) # draw bonds # ---------- # always in order: X, H, H, H, H, O pairs = [[0, 1], [0, 2], [5, 3], [5, 4]] bond = [] for i in range(len(pairs)): p1 = (x[pairs[i][0]], y[pairs[i][0]], z[pairs[i][0]]) p2 = (x[pairs[i][1]], y[pairs[i][1]], z[pairs[i][1]]) line = tvtk.LineSource(point1=p1, point2=p2) line_mapper = tvtk.PolyDataMapper() configure_input_data(line_mapper, line.output) line.update() tvtk.Property(opacity=0.8) line_actor = tvtk.Actor(mapper=line_mapper) line_actor.property.line_width = 1.9 line_actor.property.color = (0.4, 0.4, 0.4) fig.scene.add_actor(line_actor) bond.append(line_actor)
def get_actor_from_models(models): actors = [] scene_obj = {} m = models.keys()[randint(len(models))] mapper = models[m] scene_obj['model'] = m p = tvtk.Property(color=(1.0, 1.0, 1.0), lighting=False) actor = tvtk.Actor(mapper=mapper, property=p) x = (rand() - 0.5) * 2 * model_center_square y = (rand() - 0.5) * 2 * model_center_square theta = rand() * 360 actor.position = [x, y, 0] actor.rotate_z(theta) #scene_obj['x'] = actor.position[0] #scene_obj['y'] = actor.position[1] #scene_obj['theta'] = actor.orientation[2] scene_obj['actor_matrix'] = actor.matrix.to_array().tolist() actors.append(actor) plane = tvtk.PlaneSource() plane_mapper = tvtk.PolyDataMapper(input=plane.output) p = tvtk.Property(color=(1.0, 0, 0), lighting=False) floor_actor = tvtk.Actor(mapper=plane_mapper, property=p) p = tvtk.Property(color=(0, 1.0, 0), lighting=False) wall_actor = tvtk.Actor(mapper=plane_mapper, property=p) wall_actor.rotate_x(90) wall_actor.scale = [10, 6, 1] wall_actor.position = [0, 3, 2] floor_actor.scale = [10, 6, 1] actors.append(wall_actor) actors.append(floor_actor) return actors, scene_obj
def plotLetter(self, mlab): line = self.objList[0] v1 = [ line.x[1] - line.x[0], line.y[1] - line.y[0], line.z[1] - line.z[0] ] v2 = [ line.x[2] - line.x[1], line.y[2] - line.y[1], line.z[2] - line.z[1] ] v1 = numpy.array(v1) v2 = numpy.array(v2) v1 = v1 / numpy.linalg.norm(v1) v2 = v2 / numpy.linalg.norm(v2) vtext = tvtk.VectorText() vtext.text = self.letter text_mapper = tvtk.PolyDataMapper() configure_input_data(text_mapper, vtext.get_output()) vtext.update() p2 = tvtk.Property(color=(self.color[0], self.color[1], self.color[2])) text_actor = tvtk.Follower(mapper=text_mapper, property=p2) text_actor.position = (0, 0, 0) auxx = text_actor._get_x_range() auxy = text_actor._get_y_range() yc = (auxy[1] - auxy[0]) / 2 alpha = self.b / (2 * yc) xm = (auxx[1] + auxx[0]) * alpha / 2 y0 = auxy[0] vCorr = (self.a / 2 - xm) * v1 - y0 * v2 text_actor.orientation = self.orientation text_actor.scale = numpy.array([alpha, alpha, 1]) auxx = text_actor._get_x_range() auxy = text_actor._get_y_range() text_actor.position = (line.x[0] + vCorr[0], line.y[0] + vCorr[1], line.z[0] + vCorr[2]) fig = mlab.gcf() fig.scene.add_actor(text_actor) return mlab
class PlanarDispersiveWindow(PECMirror, Optic): name = "Planar dispersive window" abstract = False material = Instance(CoatedDispersiveMaterial, ()) dispersion = Instance(BaseDispersionCurve, desc="Dispersion curve for the glass") dispersion_coating = Instance(BaseDispersionCurve, desc="Dispersion curve for the coating") coating_thickness = Float(0.25, desc="Thickness of the AR coating, in microns") traits_view = View( VGroup( Traceable.uigroup, Item('diameter', editor=NumEditor), Item('thickness', editor=NumEditor), Item('offset', editor=NumEditor), Item('n_inside', editor=NumEditor), ), ) vtkproperty = tvtk.Property(opacity=0.4, color=(0.6, 0.9, 0.5)) @on_trait_change("dispersion, dispersion_coating, coating_thickness") def on_materials_changed(self): self.apply_materials() self.update = True def apply_materials(self): air = NondispersiveCurve(1.0) self.material.dispersion_inside = self.dispersion self.material.dispersion_outside = air self.material.dispersion_coating = self.dispersion_coating self.material.coating_thickness = self.coating_thickness def _thickness_changed(self, new_t): self.faces[1].z_plane = new_t self.update = True def _faces_default(self): self.apply_materials() m = self.material fl = FaceList(owner=self) fl.faces = [ CircularFace(owner=self, z_plane=0, material=m), CircularFace(owner=self, z_plane=self.thickness, invert_normal=True, material=m) ] return fl
def cylinder_actor(center=(0, 0, 0), radius=0.5, resolution=64, color=colors.green, opacity=1.0): """ Creates a cylinder and returns a tvtk.Actor. """ source = tvtk.CylinderSource(center=center, radius=radius, resolution=resolution) mapper = tvtk.PolyDataMapper(input=source.output) prop = tvtk.Property(opacity=opacity, color=color) actor = tvtk.Actor(mapper=mapper, property=prop) return actor
def sphere_actor(center=(0, 0, 0), radius=0.5, resolution=32, color=colors.purple, opacity=1.0): """ Creates a sphere and returns the actor. """ source = tvtk.SphereSource(center=center, radius=radius, theta_resolution=resolution, phi_resolution=resolution) mapper = tvtk.PolyDataMapper(input=source.output) prop = tvtk.Property(opacity=opacity, color=color) actor = tvtk.Actor(mapper=mapper, property=prop) return actor
def display_3d_array(array_3d, color_map, figure): ''' Method displays 3d array. Param: array_3d - np.array attenmap - np.array ''' cm = color_map # Dislay 3D Array Rendering v = figure for j in range(len(array_3d)): c = tuple(cm[j]) # Coordinate Information xx, yy, zz = np.where(array_3d[j] > 0.0) xx *= 100 yy *= 100 zz *= 100 # Generate Voxels For Protein append_filter = vtk.vtkAppendPolyData() for i in range(len(xx)): input1 = vtk.vtkPolyData() voxel_source = vtk.vtkCubeSource() voxel_source.SetCenter(xx[i], yy[i], zz[i]) voxel_source.SetXLength(100) voxel_source.SetYLength(100) voxel_source.SetZLength(100) voxel_source.Update() input1.ShallowCopy(voxel_source.GetOutput()) append_filter.AddInputData(input1) append_filter.Update() # Remove Any Duplicate Points. clean_filter = vtk.vtkCleanPolyData() clean_filter.SetInputConnection(append_filter.GetOutputPort()) clean_filter.Update() # Render Voxels pd = tvtk.to_tvtk(clean_filter.GetOutput()) cube_mapper = tvtk.PolyDataMapper() configure_input_data(cube_mapper, pd) p = tvtk.Property(opacity=1.0, color=c) cube_actor = tvtk.Actor(mapper=cube_mapper, property=p) v.scene.add_actor(cube_actor)
def test_do_change(self): """Test if VTK object changes when trait is changed.""" p = tvtk.Property() p.edge_visibility = not p.edge_visibility p.representation = 'p' p.interpolation = 'phong' p.opacity = 0.5 p.color = (0, 1, 0) p.diffuse_color = (1, 1, 1) p.specular_color = (1, 1, 0) for t, g in p._updateable_traits_: val = getattr(p._vtk_obj, g)() if t in ['representation', 'interpolation']: self.assertEqual(val, getattr(p, t + '_')) else: self.assertEqual(val, getattr(p, t))
def cone_actor(center=(0, 0, 0), height=1.0, radius=0.5, direction=(1, 0, 0), resolution=100, color=colors.red, opacity=1.0): """ Sets up a cone actor and returns the tvtk.Actor object.""" source = tvtk.ConeSource(center=center, height=height, radius=radius, direction=direction, resolution=resolution) mapper = tvtk.PolyDataMapper(input=source.output) p = tvtk.Property(opacity=opacity, color=color) actor = tvtk.Actor(mapper=mapper, property=p) return actor
def cylinder_actor(center=(0, 0, 0), radius=0.5, height=1, heiresolution=64, color=colors.green, opacity=1.0): """ Creates a cylinder and returns a tvtk.Actor. """ source = tvtk.CylinderSource(center=center, height=height, radius=radius, resolution=resolution) mapper = tvtk.PolyDataMapper() configure_input_data(mapper, source.output) prop = tvtk.Property(opacity=opacity, color=color) actor = tvtk.Actor(mapper=mapper, property=prop) source.update() return actor
def test_init_traits(self): """Test if the objects traits can be set in __init__.""" p = tvtk.Property(opacity=0.1, color=(1, 0, 0), representation='p') self.assertEqual(p.opacity, 0.1) self.assertEqual(p.color, (1.0, 0.0, 0.0)) self.assertEqual(p.representation, 'points') # Test case where the object traits are wrong. self.assertRaises(TraitError, tvtk.Property, foo='bar') cs = tvtk.ConeSource(radius=0.1, height=0.5, resolution=32) self.assertEqual(cs.radius, 0.1) self.assertEqual(cs.height, 0.5) self.assertEqual(cs.resolution, 32) # Test case where the object traits are wrong. self.assertRaises(TraitError, tvtk.ConeSource, foo=1)
def test_tvtk_dataset_name(self): "Can tvtk datasets can be converted to names correctly." datasets = [ tvtk.ImageData(), tvtk.StructuredPoints(), tvtk.RectilinearGrid(), tvtk.StructuredGrid(), tvtk.PolyData(), tvtk.UnstructuredGrid(), tvtk.Property(), # Not a dataset! 'foo', # Not a TVTK object. ] expect = [ 'image_data', 'image_data', 'rectilinear_grid', 'structured_grid', 'poly_data', 'unstructured_grid', 'none', 'none' ] result = [pipeline_info.get_tvtk_dataset_name(d) for d in datasets] self.assertEqual(result, expect)
def __init__(self): self.b = False self.i = 7 self.longi = 1234567890123456789 self.f = math.pi self.c = complex(1.01234, 2.3) self.n = None self.s = "String" self.u = "Unicode" self.inst = A() self.tuple = (1, 2, "a", A()) self.list = [1, 1.1, "a", 1j, self.inst] self.pure_list = list(range(5)) self.dict = {"a": 1, "b": 2, "ref": self.inst} self.numeric = numpy.ones((2, 2, 2), "f") self.ref = self.numeric if TVTK_AVAILABLE: self._tvtk = tvtk.Property()
def __init__(self): self.b = False self.i = 7 self.l = 1234567890123456789 self.f = math.pi self.c = complex(1.01234, 2.3) self.n = None self.s = 'String' self.u = u'Unicode' self.inst = A() self.tuple = (1, 2, 'a', A()) self.list = [1, 1.1, 'a', 1j, self.inst] self.pure_list = list(range(5)) self.dict = {'a': 1, 'b': 2, 'ref': self.inst} self.numeric = numpy.ones((2, 2, 2), 'f') self.ref = self.numeric if TVTK_AVAILABLE: self._tvtk = tvtk.Property()
def _render_mesh(self, mesh_type='surface', ambient_light=0.0, specular_light=0.0, alpha=1.0): from tvtk.api import tvtk pd = tvtk.PolyData() pd.points = self.points pd.polys = self.trilist pd.point_data.scalars = (self.colour_per_point * 255.).astype(np.uint8) mapper = tvtk.PolyDataMapper() mapper.set_input_data(pd) p = tvtk.Property(representation=mesh_type, opacity=alpha, ambient=ambient_light, specular=specular_light) actor = tvtk.Actor(mapper=mapper, property=p) self.figure.scene.add_actors(actor) self._actors.append(actor)
def _createVector(self, vector, frame, color): source = tvtk.ArrowSource() # pdm = tvtk.PolyDataMapper(input=source.output) pdm = tvtk.PolyDataMapper() # https://github.com/enthought/mayavi/issues/521 pdm.input_connection = source.output_port # configure_input_data(pdm, source) prop = tvtk.Property(color=color) actor = tvtk.Actor(mapper=pdm, property=prop) actor.user_transform = tvtk.Transform() # commented due to api change, new lines are above Actor creation # actor.property.color = color norm = vector.norm() actor.scale = (norm, ) * 3 quat = e.Quaterniond() # arrow are define on X axis quat.setFromTwoVectors(vector, e.Vector3d.UnitX()) X = sva.PTransformd(quat) * frame transform.setActorTransform(actor, X) return actor, X
def __init__(self, linear, angular, frame, linColor, angColor): """ Create the visualization of a 6D vector with a linear and angular part. Parameter: linear: 3d linear component (e.Vector3d) angular: 3d angular component (e.Vector3d) frame: vector frame (sva.PTransformd) linColor: linear component color (float, float, float) angColor: angular component color (float, float, float) """ self.linearActor, X_l = self._createVector(linear, frame, linColor) self.angularActor, X_a = self._createVector(angular, frame, angColor) # create a Arc around the angular axis # The arc must turn around the X axis (Arrow default axis) angNorm = angular.norm() angNormW = angNorm * 0.3 arcSource = tvtk.ArcSource(point1=(angNorm / 2., -angNormW, -angNormW), point2=(angNorm / 2., -angNormW, angNormW), center=(angNorm / 2., 0., 0.), negative=True, resolution=20) # arcPdm = tvtk.PolyDataMapper(input=arcSource.output) arcPdm = tvtk.PolyDataMapper() # https://stackoverflow.com/questions/35089379/how-to-fix-traiterror-the-input-trait-of-a-instance-is-read-only # configure_input_data(textPdm, textSource)# https://github.com/enthought/mayavi/issues/521 arcPdm.input_connection = arcSource.output_port prop = tvtk.Property(color=angColor) # https://github.com/enthought/mayavi/issues/521 # arcPdm.input_connection = arcSource.output_port self.arcActor = tvtk.Actor(mapper=arcPdm, property=prop) # commented due to api change, new lines are above Actor creation # self.arcActor.property.color = angColor # https://github.com/enthought/mayavi/blob/5c2694b72b329b8d5c469bc459a211378e2c8581/tvtk/pyface/actors.py#L112 self.arcActor.user_transform = tvtk.Transform() # apply the angular transform transform.setActorTransform(self.arcActor, X_a)
def add_static_background(self, data2D): self.sp2 = copy.copy(self.sp) self.z2 = np.reshape(np.transpose(data2D), (-1, )) self.sp2.point_data.scalars = self.z2 self.geom_filter2 = tvtk.ImageDataGeometryFilter(input=self.sp2) self.warp2 = tvtk.WarpScalar(input=self.geom_filter2.output) self.normals2 = tvtk.PolyDataNormals(input=self.warp2.output) # The rest of the VTK pipeline. self.m2 = tvtk.PolyDataMapper( input=self.normals2.output) #,scalar_range=(self.vmin, self.vmax)) self.p = tvtk.Property(opacity=1.0, color=(0.5, 0.5, 0.5), representation="w") self.a2 = tvtk.Actor(mapper=self.m2, property=self.p) self.ren.add_actor(self.a2) self.rwi.initialize() self.ren.reset_camera()
def endEffectorBody(X_s, size, color): """ Return a end effector reprsented by a plane and the appropriate static transform. """ apd = tvtk.AppendPolyData() ls = tvtk.LineSource(point1=(0., 0., 0.), point2=tuple(X_s.translation())) p1 = (sva.PTransformd(e.Vector3d.UnitX()*size)*X_s).translation() p2 = (sva.PTransformd(e.Vector3d.UnitY()*size)*X_s).translation() ps = tvtk.PlaneSource(origin=tuple(X_s.translation()), point1=tuple(p1), point2=tuple(p2), center=tuple(X_s.translation())) # apd.add_input(ls.output) # apd.add_input(ps.output) # https://github.com/enthought/mayavi/blob/ac5c8e316335078c25461a0bce4a724ae86f1836/tvtk/tests/test_tvtk.py#L586 apd.add_input_data(ls.output) apd.add_input_data(ps.output) # pdm = tvtk.PolyDataMapper(input=apd.output) # arcPdm = tvtk.PolyDataMapper(input=arcSource.output) pdm = tvtk.PolyDataMapper() # https://stackoverflow.com/questions/35089379/how-to-fix-traiterror-the-input-trait-of-a-instance-is-read-only # configure_input_data(textPdm, textSource)# https://github.com/enthought/mayavi/issues/521 pdm.input_connection = apd.output_port prop = tvtk.Property(color=color) # https://github.com/enthought/mayavi/issues/521 # arcPdm.input_connection = arcSource.output_port actor = tvtk.Actor(mapper=pdm, property=prop) actor.property.color = color actor.user_transform = tvtk.Transform() return actor, sva.PTransformd.Identity()