Slow Performance with 2K actors (*.obj file)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Slow Performance with 2K actors (*.obj file)

Sonya Blade
Dear All,

I observe very weird problem with performance of VTK. I load the polydata with 
vtkObjReader and populate it to produce 2K objects in the scene. Along with loading
phase of scene which is 10-15sec, rendering phase is also very slow and it doesn't even 
interact with scene. 

I hardly believe but probably I configured something in a wrong way in VTK because I 
originated the program by directly modifying ObjReader example in official VTK page.

The *.obj file which I load can be found at the attachement.

I'll appreciate your guidance,

int main(int argc, char *argv[])
{
  // Parse command line arguments
  /*if(argc != 2)
    {
    std::cout << "Usage: " << argv[0] << " Filename(.obj)" << std::endl;
    return EXIT_FAILURE;
    }
*/
 vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);

for (int i=0;i<2000;i++)
{
  std::string filename = argv[1];
  vtkSmartPointer<vtkOBJReader> reader =
    vtkSmartPointer<vtkOBJReader>::New();
  reader->SetFileName("........new_I_Profile.obj");// SetFileName(filename.c_str());
  reader->Update();

  // Visualize
  vtkSmartPointer<vtkPolyDataMapper> mapper =
    vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(reader->GetOutputPort());

  vtkSmartPointer<vtkActor> actor =
    vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
   renderer->AddActor(actor);
}
 
  renderer->SetBackground(.3, .6, .3); // Background color green

  renderWindow->Render();
  renderWindowInteractor->Start();

  return EXIT_SUCCESS;

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers

Objects.obj (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Slow Performance with 2K actors (*.obj file)

David Cole-2
You should probably only have 10s or 100s of actors in any given
renderer. 1000s or more *actor* objects are known to be slow.

Unless somebody else chimes in and contradicts me, with a speed up
hint, it's probably best to restructure your code to use fewer actors.


HTH,
David C.

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Slow Performance with 2K actors (*.obj file)

Sonya Blade
Ok thanks David for entry point,

Probably construing the scene from many actors was not a good idea if you look at it from VTK side,
but due to the design architecture I should have each object as a seperate entity which might have the 
the supplied *.obj shape or any other arbitrary shape provided by end-user and those shapes should be 
interactable, modifiable, etc 

If it wasn't AddActor() proc then what other methods I can use for that ?

Regards,


> To: [hidden email]; [hidden email]

> Subject: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)
> From: [hidden email]
> Date: Sun, 15 Jun 2014 08:01:59 -0400
>
> You should probably only have 10s or 100s of actors in any given
> renderer. 1000s or more *actor* objects are known to be slow.
>
> Unless somebody else chimes in and contradicts me, with a speed up
> hint, it's probably best to restructure your code to use fewer actors.
>
>
> HTH,
> David C.
>

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Slow Performance with 2K actors (*.obj file)

Carlos

If all the actors have the same geometry, then you can use Shallowcopies (actor.ShallowCopy ) in a way similar to:

 

  // Visualize

  vtkSmartPointer<vtkPolyDataMapper> mapper =

    vtkSmartPointer<vtkPolyDataMapper>::New();

  mapper->SetInputConnection(reader->GetOutputPort());

 

  vtkSmartPointer<vtkActor> actor =

    vtkSmartPointer<vtkActor>::New();

  actor->SetMapper(mapper);

   renderer->AddActor(actor);

 

for (int i=0;i<2000;i++)

{

  vtkSmartPointer<vtkActor> actor2 =

    vtkSmartPointer<vtkActor>::New();

 

  actor2->ShallowCopy(actor);

   renderer->AddActor(actor2);

}

 

 

This will reduce both the time of loading as the polydata and the mapper are created only once and also it will improve the interaction experience.

There are only some parameters that can be change, like position or orientation but not the geometry in the new actors.

 

 

Regards,

 

Carlos

 

De: vtkusers [mailto:[hidden email]] En nombre de Sonya Blade
Enviado el: lunes, 16 de junio de 2014 8:09
Para: David Cole; [hidden email]
Asunto: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)

 

Ok thanks David for entry point,

 

Probably construing the scene from many actors was not a good idea if you look at it from VTK side,

but due to the design architecture I should have each object as a seperate entity which might have the 

the supplied *.obj shape or any other arbitrary shape provided by end-user and those shapes should be 

interactable, modifiable, etc 

 

If it wasn't AddActor() proc then what other methods I can use for that ?

 

Regards,

> To: [hidden email]; [hidden email]


> Subject: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)
> From: [hidden email]
> Date: Sun, 15 Jun 2014 08:01:59 -0400
>
> You should probably only have 10s or 100s of actors in any given
> renderer. 1000s or more *actor* objects are known to be slow.
>
> Unless somebody else chimes in and contradicts me, with a speed up
> hint, it's probably best to restructure your code to use fewer actors.
>
>
> HTH,
> David C.
>

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Slow Performance with 2K actors (*.obj file)

Sonya Blade
I can not guarantee that all the actors will have the same geometry, the loaded shape was just 
for the testing purposes, in any case it'll completely depend on end-user input. AFAIK there are 
even better techniques if geometry is identical such as impostor, proxy object in OpenGL. 

I'm trying to follow the instructions given here http://www.cmake.org/Wiki/index.php?title=VTK/FAQ&redirect=no#VTK_is_slow.2C_what_is_wrong.3F (FAQ/How to handle large data sets in VTK, )

It mentions that "By default VTK keeps a copy of all intermediate results between filters in 
a pipeline" which is quite unnecessary for my case. In order to switch it off I should have 
vtkPolyDataReader so later on I can apply the following statement in order to test the performance.

// C++ 
vtkPolyDataReader *reader = vtkPolyDataReader::New(); 
reader->GetOutput()->ReleaseDataFlagOn();

The glitch here is: I do have ObjReader instead of vtkPolyReader, vtkPOlyReader doesn't load the *.obj file,
in order to eliminate that do I have to load the obj file with ObjReader and copy it to the PolyReader ? 
If so how can I do it?

Regards,


From: [hidden email]
To: [hidden email]; [hidden email]; [hidden email]
Subject: RE: [vtkusers] Slow Performance with 2K actors (*.obj file)
Date: Mon, 16 Jun 2014 13:25:02 +0200

If all the actors have the same geometry, then you can use Shallowcopies (actor.ShallowCopy ) in a way similar to:

 

  // Visualize

  vtkSmartPointer<vtkPolyDataMapper> mapper =

    vtkSmartPointer<vtkPolyDataMapper>::New();

  mapper->SetInputConnection(reader->GetOutputPort());

 

  vtkSmartPointer<vtkActor> actor =

    vtkSmartPointer<vtkActor>::New();

  actor->SetMapper(mapper);

   renderer->AddActor(actor);

 

for (int i=0;i<2000;i++)

{

  vtkSmartPointer<vtkActor> actor2 =

    vtkSmartPointer<vtkActor>::New();

 

  actor2->ShallowCopy(actor);

   renderer->AddActor(actor2);

}

 

 

This will reduce both the time of loading as the polydata and the mapper are created only once and also it will improve the interaction experience.

There are only some parameters that can be change, like position or orientation but not the geometry in the new actors.

 

 

Regards,

 

Carlos

 

De: vtkusers [mailto:[hidden email]] En nombre de Sonya Blade
Enviado el: lunes, 16 de junio de 2014 8:09
Para: David Cole; [hidden email]
Asunto: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)

 

Ok thanks David for entry point,

 

Probably construing the scene from many actors was not a good idea if you look at it from VTK side,

but due to the design architecture I should have each object as a seperate entity which might have the 

the supplied *.obj shape or any other arbitrary shape provided by end-user and those shapes should be 

interactable, modifiable, etc 

 

If it wasn't AddActor() proc then what other methods I can use for that ?

 

Regards,

> To: [hidden email]; [hidden email]


> Subject: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)
> From: [hidden email]
> Date: Sun, 15 Jun 2014 08:01:59 -0400
>
> You should probably only have 10s or 100s of actors in any given
> renderer. 1000s or more *actor* objects are known to be slow.
>
> Unless somebody else chimes in and contradicts me, with a speed up
> hint, it's probably best to restructure your code to use fewer actors.
>
>
> HTH,
> David C.
>

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Slow Performance with 2K actors (*.obj file)

Sonya Blade
Hi All,
Instructions given for how to efficiently handle large dataset at the official
 wiki page doesn't contribute much to the speed improvement in my case, that
means that it's somehow boils down to the fact that I shouldn't create many actors. 

Instead group the object which may fit into a specific actor( I shapes, S shapes, U shapes etc..),
the best method that comes in mind is that. But I don't know exactly how to insert each individual 
polydata into the very same actor, all the examples use the seperate mapper, actors for this.

There is not an example for inserting many polydata into a single actor, 

I'll appreciate your help,

Regards,

From: [hidden email]
To: [hidden email]; [hidden email]; [hidden email]
Date: Mon, 16 Jun 2014 13:01:52 +0100
Subject: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)

I can not guarantee that all the actors will have the same geometry, the loaded shape was just 
for the testing purposes, in any case it'll completely depend on end-user input. AFAIK there are 
even better techniques if geometry is identical such as impostor, proxy object in OpenGL. 

I'm trying to follow the instructions given here http://www.cmake.org/Wiki/index.php?title=VTK/FAQ&redirect=no#VTK_is_slow.2C_what_is_wrong.3F (FAQ/How to handle large data sets in VTK, )

It mentions that "By default VTK keeps a copy of all intermediate results between filters in 
a pipeline" which is quite unnecessary for my case. In order to switch it off I should have 
vtkPolyDataReader so later on I can apply the following statement in order to test the performance.

// C++ 
vtkPolyDataReader *reader = vtkPolyDataReader::New(); 
reader->GetOutput()->ReleaseDataFlagOn();

The glitch here is: I do have ObjReader instead of vtkPolyReader, vtkPOlyReader doesn't load the *.obj file,
in order to eliminate that do I have to load the obj file with ObjReader and copy it to the PolyReader ? 
If so how can I do it?

Regards,


From: [hidden email]
To: [hidden email]; [hidden email]; [hidden email]
Subject: RE: [vtkusers] Slow Performance with 2K actors (*.obj file)
Date: Mon, 16 Jun 2014 13:25:02 +0200

If all the actors have the same geometry, then you can use Shallowcopies (actor.ShallowCopy ) in a way similar to:

 

  // Visualize

  vtkSmartPointer<vtkPolyDataMapper> mapper =

    vtkSmartPointer<vtkPolyDataMapper>::New();

  mapper->SetInputConnection(reader->GetOutputPort());

 

  vtkSmartPointer<vtkActor> actor =

    vtkSmartPointer<vtkActor>::New();

  actor->SetMapper(mapper);

   renderer->AddActor(actor);

 

for (int i=0;i<2000;i++)

{

  vtkSmartPointer<vtkActor> actor2 =

    vtkSmartPointer<vtkActor>::New();

 

  actor2->ShallowCopy(actor);

   renderer->AddActor(actor2);

}

 

 

This will reduce both the time of loading as the polydata and the mapper are created only once and also it will improve the interaction experience.

There are only some parameters that can be change, like position or orientation but not the geometry in the new actors.

 

 

Regards,

 

Carlos

 

De: vtkusers [mailto:[hidden email]] En nombre de Sonya Blade
Enviado el: lunes, 16 de junio de 2014 8:09
Para: David Cole; [hidden email]
Asunto: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)

 

Ok thanks David for entry point,

 

Probably construing the scene from many actors was not a good idea if you look at it from VTK side,

but due to the design architecture I should have each object as a seperate entity which might have the 

the supplied *.obj shape or any other arbitrary shape provided by end-user and those shapes should be 

interactable, modifiable, etc 

 

If it wasn't AddActor() proc then what other methods I can use for that ?

 

Regards,

> To: [hidden email]; [hidden email]


> Subject: Re: [vtkusers] Slow Performance with 2K actors (*.obj file)
> From: [hidden email]
> Date: Sun, 15 Jun 2014 08:01:59 -0400
>
> You should probably only have 10s or 100s of actors in any given
> renderer. 1000s or more *actor* objects are known to be slow.
>
> Unless somebody else chimes in and contradicts me, with a speed up
> hint, it's probably best to restructure your code to use fewer actors.
>
>
> HTH,
> David C.
>

_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/vtkusers

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Slow Performance with 2K actors (*.obj file)

Najzero
In reply to this post by Sonya Blade
Hi,

First thing that comes to my mind is http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/CombinePolyData

As this append filter does take performance as well, I would save the final result of your 2000 current actors in a whole .vtk file after all of them have been appended or chunk them down in corresponding groups and save those.

Regards
Reply | Threaded
Open this post in threaded view
|

Re: Slow Performance with 2K actors (*.obj file)

metamurk
This post has NOT been accepted by the mailing list yet.
In reply to this post by Sonya Blade
Hello together,
same issue here. When I render 2000 triangles in one actor it is significant faster than render 2000 times 1 triangle in 2000 actor, although it produces the same output image!
This is a major showstopper in my opinion because this actor count is absolutely necessary for many applications.

Can anybody point me on the reason within vtk or even give a short summary what to do to fix that problem.
Thanks