[Tutor] Lots of Actors

Daniel Ehrenberg littledanehren at yahoo.com
Thu Feb 12 17:13:39 EST 2004


Yi-Yu Chou wrote:
> Dear all,
> 
> I would like to us line segments to display a 3D
> vector filed.
> However the program becomes very slow when
> displaying this vector field if 
> the number of line
> segments is huge. Is there any better method to do
> it ?
> Thanks in advance !!!
> 
> Below is my code :
> 
> line = []
> line_mapper = []
> self.line_actor = []		
> for i in range(0, vf_points.num):
> 	line.append(vtkLineSource())
> 
>
line[i].SetPoint1(vf_points.x[i],vf_points.y[i],vf_points.z[i])
> 	line[i].SetPoint2(vf_points.x[i] +
> vf.vx[i],vf_points.y[i] + 
> vf.vy[i],vf_points.z[i] + vf.vz[i])
> 	line_mapper.append(vtkPolyDataMapper())
> 	line_mapper[i].SetInput(line[i].GetOutput())
> 	self.line_actor.append(vtkActor())
> 	self.line_actor[i].SetMapper(line_mapper[i])
> 	self.line_actor[i].GetProperty().SetLineWidth(1)
> 	self.line_actor[i].GetProperty().SetColor(0,1,1)
> 	self.line_actor[i].PickableOff()
> 	self.tar_renderer.AddActor(self.line_actor[i])

You may want to create temporary variables. They stay
"linked" to what you assigned them to, so you don't
need to worry that they'll just be coppied. Try making
a variable for self.line_actor[i] since you keep
refering to it.

Daniel Ehrenberg

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html



More information about the Tutor mailing list