[vtkusers] Solved. renderWindow wrapped in a vtkSmartPtr - error pass it to the vtkWindowToImageFilter SetInput function.

Harlow Eric D Contr 412 TW/ENR Eric.Harlow at edwards.af.mil
Thu Sep 9 12:22:17 EDT 2004


 
Sean,


My fix for this:
> 
> vtkWindow* wind = RenderWindow_.get();
> w2if->SetInput(wind);
> 
> -Eric



Hi Eric,

   First off, unless you need access to some specialized methods of 
vtkWin32OpenGLRenderWindow, I would have the smart pointer hold a 
reference to a regular old vtkRenderWindow (i.e. 
vtkSmartPtr<vtkRenderWindow>). This way you can simply call 
vtkRenderWindow::New() and rely on VTK to instantiate the appropriate 
subclass.

   Second, because VTK includes only the parent class header in each 
class's header file and relies on forward declarations for references to 
other types, you will have to include the header of the derived class in 
whatever file implements "w2if->SetInput(RenderWindow_.get );". In your 
case, either:

#include "vtkWin32OpenGLRenderWindow.h"
   -OR-
#include "vtkRenderWindow.h" // if you case use my first suggestion

For more information, see:
<http://www.vtk.org/Wiki/VTK_FAQ#Forward_declaration_in_VTK_4.x>

-Sean

> 
> Does anyone know how to solve this?  I have a renderWindow wrapped in a
> vtkSmartPtr and I get an compile error when I try to pass it the
> vtkWindowToImageFilter SetInput function.  
> 
> 
> vtkSmartPtr<vtkWin32OpenGLRenderWindow>  RenderWindow_;
> 
> 
> implementation:
> 
> vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New();
> 
> 
> w2if->SetInput(RenderWindow_.get );
> 
> error:
> 
> c:\MDV\DVL\dvlcanvas.cpp(169) : error C2664:
> 'vtkWindowToImageFilter::SetInput' : cannot convert parameter 1 from
> 'vtkWin32OpenGLRenderWindow *(void) const' to 'vtkWindow *'
>         There is no context in which this conversion is possible
> 
> Thanks,
> 
> Eric



More information about the vtkusers mailing list