def _actors_default(self): source = self.plane_src trans_f = tvtk.TransformFilter(input_connection=source.output_port, transform = self.transform) map = tvtk.PolyDataMapper(input_connection=trans_f.output_port) act = tvtk.Actor(mapper=map) actors = tvtk.ActorCollection() actors.append(act) return actors
def _actors_default(self): pipeline = self.pipeline map = tvtk.PolyDataMapper(input_connection=pipeline.output_port) map.scalar_visibility = False act = tvtk.Actor(mapper=map) act.property = self.vtkproperty actors = tvtk.ActorCollection() actors.append(act) return actors
def test_collection(self): """Test if Collection objects work nicely.""" ac = tvtk.ActorCollection() self.assertEqual(len(ac), 0) self.assertRaises(IndexError, ac.__getitem__, 0) a_list = [] a = tvtk.Actor() a_list.append(a) ac.append(a) self.assertRaises(TypeError, ac.__getitem__, 's') self.assertEqual(len(ac), 1) a = tvtk.Actor() a_list.append(a) ac.append(a) self.assertEqual(len(ac), 2) # Test iterator nature. for i, j in zip(ac, a_list): self.assertEqual(i._vtk_obj, j._vtk_obj) for i, j in enumerate(ac): self.assertEqual(a_list[i]._vtk_obj, j._vtk_obj) # Test __setitem__. ac[0] = a_list[1] ac[1] = a_list[0] self.assertEqual(ac[0]._vtk_obj, a_list[1]._vtk_obj) self.assertEqual(ac[1]._vtk_obj, a_list[0]._vtk_obj) self.assertRaises(TypeError, ac.__setitem__, 's', a_list[1]) # Test __delitem__. del ac[-2] self.assertEqual(ac[0]._vtk_obj, a_list[0]._vtk_obj) self.assertEqual(len(ac), 1) self.assertRaises(TypeError, ac.__delitem__, 1.414) del ac[0] self.assertEqual(len(ac), 0) # Test __repr__. self.assertEqual(repr(ac), '[]') # test extend. ac.extend(a_list) self.assertEqual(len(ac), 2) for i, j in enumerate(ac): self.assertEqual(a_list[i]._vtk_obj, j._vtk_obj) # Test the prop collection. pc = tvtk.PropCollection() a = tvtk.Actor() pc.append(a) self.assertEqual(pc[0], a) for i in pc: self.assertEqual(i, a)
def _actors_default(self): source = self.source def execute(): output = source.poly_data_output if self.rays is None: return points = self.rays.origin cells = self.rays.cells output.points = points output.polys = cells.tolist() #print "PSF", cells, points source.set_execute_method(execute) map = tvtk.PolyDataMapper(input_connection=source.output_port) act = tvtk.Actor(mapper=map) act.property.representation="wireframe" actors = tvtk.ActorCollection() actors.append(act) return actors