When I use VTK, IVtkTools_ShapeDataSource error

Forums: 

Hello everyone, This problem has troubled me for several days. I try to compile OCC and VTK,But no effect. My configuration: vs2019 + occ 7.6 +vtk 8.2/9.1

this is my simple code:

#include <BRepPrimAPI_MakeBox.hxx>
#include <IVtkTools_ShapeDataSource.hxx>
#include <vtkType.h>
#include <vtkAutoInit.h>
#include <vtkRenderWindow.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkInteractorStyleTrackballCamera.h>

VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkInteractionStyle)

int main()
{
    BRepPrimAPI_MakeBox mkBox(1., 2., 3);
    const TopoDS_Shape& shape = mkBox.Shape();

    vtkNew<vtkRenderWindow> renWin;

    vtkNew<vtkRenderer> ren;
    renWin->AddRenderer(ren);
    renWin->SetSize(640, 640);

    vtkNew<vtkInteractorStyleTrackballCamera> istyle;
    vtkNew<vtkRenderWindowInteractor> iren;

    iren->SetRenderWindow(renWin);
    iren->SetInteractorStyle(istyle);

    vtkNew<IVtkTools_ShapeDataSource> DS ;
    DS->SetShape(new IVtkOCC_Shape(shape));

    vtkNew<vtkPolyDataMapper> mapper;
    mapper->SetInputConnection(DS->GetOutputPort());

    vtkNew<vtkActor> actor;
    actor->SetMapper(mapper);

    ren->AddActor(actor);

    renWin->Render();
    iren->Start();

    return 0;
}

line: mapper->SetInputConnection(DS->GetOutputPort()); // error

ERROR: In D:\Software\3rdParty_useByMyself\VTK\VTK8_2\VTK-8.2.0_src\Common\ExecutionModel\vtkAlgorithm.cxx, line 908
IVtkTools_ShapeDataSource (000001E1CE813170): Attempt to get output port index 0 for an algorithm with -829853712 output ports.

Can anyone help me? thank you very much

ye na's picture

I think there is no problem with this code.

Jihui Cong's picture

I have the same problem with u,and i don't how to do either.

luffy luo's picture

i have the same problem. has this problem been solved?
qt6 + vtk9.3.2 + occ7.5.0

luffy luo's picture

i think i found the reason. when your application run as "Debug" mode, the VTK and OCC need use the debug libs and dlls.

Yang Lin's picture

i have the same problem. has this problem been solved?

Dmitrii Pasukhin's picture

Hello, did you try to specify debug/release libs?

Best regards, Dmitrii.