How to integrate vtk render window into .NET forms?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to integrate vtk render window into .NET forms?

Feng Ma
Hi, All:

  I have a question regarding integrating vtk render window into a .NET
form. Here is what I do for the experiment:

  I create a simple .net form project. In the form, I create a button and a
picture box inside. When I press the button, I wanted to connect the picture
box to a vtk render window and display a sphere inside. Here is the code:

        private: System::Void button1_Click_1(System::Object *  sender,
System::EventArgs *  e)
                         {
                                vtkWin32OpenGLRenderWindow *m_RenderWindow;
                                vtkRenderer *m_Renderer;
                                vtkWin32RenderWindowInteractor *m_Interactor;

                                m_Renderer = vtkRenderer::New();
                                m_RenderWindow = vtkWin32OpenGLRenderWindow::New();
                                m_RenderWindow->AddRenderer(m_Renderer);

                                vtkSphereSource *sphere = vtkSphereSource::New();
                                sphere->SetRadius(20.0);

                                vtkPolyDataMapper *pSurfM = vtkPolyDataMapper::New();
                                pSurfM->SetInput(sphere->GetOutput());
                                vtkActor *pSurfActor = vtkActor::New();
                                pSurfActor->SetMapper(pSurfM);

                                // assign our actor to the renderer
                                m_Renderer->AddActor(pSurfActor);

                                // setup the parent window
                                m_RenderWindow->SetParentId((HWND)((this->pictureBox1->Handle).ToPointer()));
                                m_Interactor = vtkWin32RenderWindowInteractor::New();
                                m_Interactor->SetRenderWindow(m_RenderWindow);

                                m_Renderer->SetBackground( 1.0, 1.0, 1.0 );

                                m_Renderer->Render();

                                sphere->Delete();
                                pSurfM->Delete();
                                pSurfActor->Delete();

                         }

   When I compile the project, I got the following linking error. Any
suggestions? Your helps are greatly appreciated.

-Feng


------ Build started: Project: VTKConnect, Configuration: Debug Win32 ------

Compiling...
AssemblyInfo.cpp
Form1.cpp
Compiling managed resources...
Read in 12 resources from
'h:\Ma\ITKAppBuildW32\VTKConnect\VTKConnect\Form1.resX'
Writing resource file...  Done.
Linking...
msvcrt.lib(MSVCR71.dll) : error LNK2005: _exit already defined in
LIBCMT.lib(crt0dat.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _free already defined in
LIBCMT.lib(free.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _malloc already defined in
LIBCMT.lib(malloc.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _getenv already defined in
LIBCMT.lib(getenv.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: virtual __thiscall
std::basic_streambuf<char,struct std::char_traits<char>
 >::~basic_streambuf<char,struct std::char_traits<char> >(void)"
(??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined
in libcpmtd.lib(cerr.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "protected: void __thiscall
std::strstreambuf::_Init(int,char *,char *,int)"
(?_Init@strstreambuf@std@@IAEXHPAD0H@Z) already defined in
libcpmtd.lib(strstrea.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "protected: __thiscall
std::basic_streambuf<char,struct std::char_traits<char>
 >::basic_streambuf<char,struct std::char_traits<char> >(void)"
(??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined
in libcpmtd.lib(cerr.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: void __thiscall
std::strstreambuf::freeze(bool)" (?freeze@strstreambuf@std@@QAEX_N@Z)
already defined in libcpmtd.lib(strstrea.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: virtual __thiscall
std::strstreambuf::~strstreambuf(void)" (??1strstreambuf@std@@UAE@XZ)
already defined in libcpmtd.lib(strstrea.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: virtual __thiscall
std::basic_ostream<char,struct std::char_traits<char>
 >::~basic_ostream<char,struct std::char_traits<char> >(void)"
(??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in
libcpmtd.lib(cerr.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: virtual __thiscall
std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct
std::char_traits<char> >(void)"
(??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in
libcpmtd.lib(cerr.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: __thiscall
std::basic_ostream<char,struct std::char_traits<char>
 >::basic_ostream<char,struct std::char_traits<char> >(class
std::basic_streambuf<char,struct std::char_traits<char> > *,bool)"
(??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z)
already defined in libcpmtd.lib(cerr.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: virtual __thiscall
std::ostrstream::~ostrstream(void)" (??1ostrstream@std@@UAE@XZ) already
defined in libcpmtd.lib(strstrea.obj)
msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: virtual __thiscall
std::ios_base::~ios_base(void)" (??1ios_base@std@@UAE@XZ) already defined in
libcpmtd.lib(ios.obj)
LINK : error LNK2020: unresolved token (0A000026) vtkObjectBase.__dtor
LINK : fatal error LNK1120: 1 unresolved externals

Build log was saved at
"file://h:\Ma\ITKAppBuildW32\VTKConnect\VTKConnect\Debug\BuildLog.htm"
VTKConnect - 16 error(s), 0 warning(s)


---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped


_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers