Lesson 2: Bring OpenCascade and VTK together

Forums: 

I am following OpenCascade tutorials but am using window10 with VS 2019 IDE.
I have installed OpenCascade 7.7.0 and VTK 6.1.0.

At first, the compiler didn't recognize vtkNew but this was solved by adding #include <vtkNew.h>

But then I got squiggles on these 5 lines:
renwin->AddRenderer(ren);
iren->SetInteractorStyle(istyle);
iren->SetRenderWindow(renwin);
actor->SetMapper(mapper);
ren->AddActor(actor);

The compiler had these 5 problems:
no suitable conversion function from "vtkNew<vtkRenderer>" to "vtkRenderer *" existsC/C++(413)
no suitable conversion function from "vtkNew<vtkInteractorStyleTrackballCamera>" to "vtkInteractorObserver *" existsC/C++(413)
no suitable conversion function from "vtkNew<vtkRenderWindow>" to "vtkRenderWindow *" existsC/C++(413)
no suitable conversion function from "vtkNew<vtkPolyDataMapper>" to "vtkMapper *" existsC/C++(413)
no suitable conversion function from "vtkNew<vtkActor>" to "vtkProp *" existsC/C++(413)

How do I solve this?

Dmitrii Pasukhin's picture

Hello, could you please share a little more details about "At first, the compiler didn't recognize vtkNew but this was solved by adding #include <vtkNew.h>"

And where is a problem? On OCCT repo or project depends on OCC?

Best regards, Dmitrii.

 

song jk's picture

This is a screenshot of the program:

#include <BRepPrimAPI_MakeBox.hxx>

#include <VtkRenderWindow.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkNew.h>

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

vtkNew<vtkRenderWindow> renderWindow; //
vtkNew<vtkRenderer> render; //
renderWindow->AddRenderer(render); //

return 0;
}

Attachments: 
song jk's picture

This is a screenshot of the program and error details:

#include <BRepPrimAPI_MakeBox.hxx>

#include <VtkRenderWindow.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkNew.h>

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

vtkNew<vtkRenderWindow> renderWindow; //
vtkNew<vtkRenderer> render; //
renderWindow->AddRenderer(render); //

return 0;
}

Attachments: