By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,404 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,404 IT Pros & Developers. It's quick & easy.

Lots of Actors

P: n/a
Dear all,

I want to use line segments to display a 3D vector field.
However, my progrm becomes very slow when displaying this vector field if
the number of lin segments is very 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])

__________________________________________________ _______________
加入 MSN 社群:擁抱群眾、分享經驗、發現生活的樂趣
http://groups.msn.com?pgmarket=zh-tw
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Yi-Yu Chou wrote:

I want to use line segments to display a 3D vector field.
However, my progrm becomes very slow when displaying this vector field if
the number of lin segments is very 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])


What makes you think the above code, specifically, is the cause of the
slowness? It doesn't look to me as though the above code is actually
doing the rendering, but merely setting things up to be rendered. On
the other hand, without any idea what a tar_renderer is, or anything
else about the code, it's hard to tell.

If the above is really the part that needs to be optimized, and only
profiling or something like that will tell you, you could save at least
a tiny bit of time by binding a local variable to self.line_actor[i] and
using that in subsequent lines in place of the longer form, which
involves a dictionary lookup (on self) and an index operation repeatedly.

I'd look for more points of concern, but it doesn't seem productive
unless you have evidence that this is really the bottleneck in your
code.

-Peter
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.