Slow when using vtkRenderer, vtkRenderWindow

Hello

I received 3D Sensor data and developed 3D Viewer using VTK.
The time to call both functions continues to increase.


Global variable
vtkNew m_vtkRenderWindow;
vtkNew m_vtkRenderer;

UpdatePointerToWindow()
{

m_vtkRenderer->ResetCamera();


m_vtkRenderWindow->Render();

}


I want to know how to solve the problem I am having.
Some of the codes in use are attached.

Code.txt (2.2 KB)

Thanks!

You may receive hundreds of sensor data updates per second, but usually there is no need to update the screen more frequently than about 60Hz (and if your scene is complex then you may want limit refresh rate to a lower value to have some spare time on the main thread to do other things than rendering). Of course you also need to minimize changes in the update loop: you should pre-create all objects in advance and just update their properties (to avoid doing unnecessary computations and memory fragmentation).

In 3D Slicer we solved visualization of position-tracked instruments and live interventional imaging data by using “request render” mechanism implemented in CTK toolkit and do all sensor data collection and preprocessing in background threads. If you implement a medical application that I would strongly recommend to use these components that proven to work robustly in the operating room for various procedures (see www.slicerigt.org). If you work in a different domain then you can take source code or ideas from 3D Slicer and its extensions.

Thank you for your answer.
I think I gave you insufficient information.

3D View is not fast. (=0.2Hz)

he problem is that the ResetCamera(), Render() functions call time is getting slower and slower and slower.

1
ResetCamera(): 300ms
Render(): 300ms

2
ResetCamera(): 600ms
Render(): 500ms

3
ResetCamera(): 1100ms
Render(): 900ms

Things getting slower in each iteration means that you don’t pre-create all objects in advance but you create new instances in each iteration (and maybe not even clean them up properly).

Thank you very much.!!

After changing an object that was continuously created as a local variable to a global variable, it was confirmed that ResetCamera does not slow down.

However, it is still slow in Render.
vtkNew m_vtkRenderWindow;
m_vtkRenderWindow->Render();

Do I need to delete or remove?

Do not recreate the render window for each rendering - that’s a very expensive operation.

What do you render and what frame rate you can achieve now?

Thank you.

As you said, changing the local variable to a member variable (global variable X) solved the problem.

As your advice, I will not recreate the Render window.

BR