Lots of Actors

Discussion in 'Python' started by Yi-Yu Chou, Feb 10, 2004.

  1. Yi-Yu Chou

    Yi-Yu Chou Guest

    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.SetPoint1(vf_points.x,vf_points.y,vf_points.z)
    line.SetPoint2(vf_points.x + vf.vx,vf_points.y +
    vf.vy,vf_points.z + vf.vz)
    line_mapper.append(vtkPolyDataMapper())
    line_mapper.SetInput(line.GetOutput())
    self.line_actor.append(vtkActor())
    self.line_actor.SetMapper(line_mapper)
    self.line_actor.GetProperty().SetLineWidth(1)
    self.line_actor.GetProperty().SetColor(0,1,1)
    self.line_actor.PickableOff()
    self.tar_renderer.AddActor(self.line_actor)

    _________________________________________________________________
    ¥[¤J MSN ªÀ¸s¡G¾Ö©ê¸s²³¡B¤À¨É¸gÅç¡Bµo²{¥Í¬¡ªº¼Ö½ì
    http://groups.msn.com?pgmarket=zh-tw
    Yi-Yu Chou, Feb 10, 2004
    #1
    1. Advertising

  2. Yi-Yu Chou

    Peter Hansen Guest

    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.SetPoint1(vf_points.x,vf_points.y,vf_points.z)
    > line.SetPoint2(vf_points.x + vf.vx,vf_points.y +
    > vf.vy,vf_points.z + vf.vz)
    > line_mapper.append(vtkPolyDataMapper())
    > line_mapper.SetInput(line.GetOutput())
    > self.line_actor.append(vtkActor())
    > self.line_actor.SetMapper(line_mapper)
    > self.line_actor.GetProperty().SetLineWidth(1)
    > self.line_actor.GetProperty().SetColor(0,1,1)
    > self.line_actor.PickableOff()
    > self.tar_renderer.AddActor(self.line_actor)


    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 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
    Peter Hansen, Feb 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brad
    Replies:
    9
    Views:
    364
    Bruno Desthuilliers
    Jun 19, 2008
  2. zuzu
    Replies:
    14
    Views:
    231
    Phil Tomson
    Aug 23, 2004
  3. MenTaLguY
    Replies:
    0
    Views:
    101
    MenTaLguY
    May 25, 2007
  4. fedzor

    Actors and Concurrency

    fedzor, Feb 11, 2008, in forum: Ruby
    Replies:
    6
    Views:
    122
    Jason Roelofs
    Feb 13, 2008
  5. coolneo
    Replies:
    9
    Views:
    184
    coolneo
    Jan 30, 2007
Loading...

Share This Page