no override found for 'vtkPolyDataMapper'

2020-02-08 05:52发布

I'm trying to use vtk in my code, but I'm having problems running an example. I have almost no clue about the reasons since it's the first time I'm using it and I'm not very experienced. I'm using visual studio 2012 and x64 platform. Since I don't really know which libs should I use I added all of them to the "Additional Dependencies". The example is given in this link. The problem is that when I run it, the window shows this message

Generic Warning: In C:\location\VTK6.0.0\Rendering\Core\vtkPolyDataMapper.cxx, line 27
Error: no override found for 'vtkPolyDataMapper'.

which corresponds to this line

// Return NULL if no override is supplied.
vtkAbstractObjectFactoryNewMacro(vtkPolyDataMapper)

And the error that visual studio shows is

First-chance exception at 0x000007F7AA106C8F in Test.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

Does anyone know how to solve this problem or at least what does this error mean?

8条回答
Bombasti
2楼-- · 2020-02-08 06:25

A quick hack solution: In CMakeList.txt file, replace vtkRendering${VTK_RENDERING_BACKEND} with vtkRenderingOpenGL2. The reason why we need this is because Cmake does not know where the rendering core is. By specifying it, we can use the rendering core to override the proper method.

The proper solution should be replace the whole find_package paragraph with:

find_package(VTK REQUIRED COMPONENTS vtkCommonCore) 
find_package(VTK COMPONENTS 
   vtkFiltersSources
   vtkInteractionStyle
   vtkRendering${VTK_RENDERING_BACKEND})

The first find_package lets the CMake know where to find the packages, then second find_package would know where to find vtkRendering${VTK_RENDERING_BACKEND}.

查看更多
老娘就宠你
3楼-- · 2020-02-08 06:36

You are missing include(${VTK_USE_FILE}) in your CMakeLists.txt file.

查看更多
登录 后发表回答