[vtkusers] Re nder observer events

hampycalc i.am.tom.hampshire at googlemail.com
Fri Nov 27 11:39:40 EST 2009


Hi everyone, I have been tearing my hair out trying to find a solution to
this problem, and think I'm quite close, just not quite there yet.
I am using a vtkCameraInterpolator to generate a fly through, similarly to
how it is implemented here: 
http://www.vtk.org/doc/nightly/html/c2_vtk_t_3.html#c2_vtk_t_vtkCameraInterpolator
only in C++. However, it renders very slowly due to the fact that
vtkRenderWindow->Render() is called multiple times in the loop, creating
multiple new threads, before it actually renders a frame. I want to check if
the frame has been rendered correctly (and the render thread has ended)
before making another call to vtkRenderWindow->Render(), and have attemped
to do this by subclassing vtkCommand and attaching it to the vtkRenderer as
an observer and look for vtkCommand::EndEvent and vtkCommand::StartEvent
events. However, these seem to be called directly after one another,
regardless of whether the frame has been rendered correctly. The vtkCommand
I am using is:

class vtkRenderFinish : public vtkCommand
{
    public:
        static vtkRenderFinish *New()
        {
			vtkRenderFinish *v = new vtkRenderFinish;
			v->finished = true;
			return v;
        }

        void Delete()
        {
			delete this;
        }

        virtual void Execute(vtkObject *caller, unsigned long eventId, void*
arguments)
        {
			if (eventId == vtkCommand::EndEvent)
				finished = true;
			else if (eventId == vtkCommand::StartEvent)
				finished = false;
        }

	bool isFinished(){
			return finished;
	}

private:
	bool finished;
};

And I am attempting to halt the vtkRenderWindow->Render() by putting:

while(!vtkRenderFinish->isFinished()){
	Sleep(10);
}

before it. The inside of this while statement is never reached, which leads
me to believe I am not observing the correct object and/or commands.
Any help would be greatly appreciated.
-- 
View this message in context: http://old.nabble.com/Render-observer-events-tp26544829p26544829.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list