For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

visualize an OCCT topological shape in VTK viewer

Rui Song's picture
Forums: 

I want to visualize an OCCT topological shape in VTK viewer.

I refer to the tutorial of VIS.However there throw exception in 'Mapper->SetInputConnection(DS->GetOutputPort());'

Here is my code:

// 1 . Create IVtkOCC_Shape instance(VIS wrapper for OCCT shape) and initialize it with TopoDS_Shape object containing the actual geometry.
//TopoDS_Shape aShape = makebottle();
TopoDS_Shape aShape;
BRep_Builder B;
BRepTools::Read(aShape, "D:\\OpenCASCADE7.0.0-vc12-64\\opencascade-7.0.0\\data\\occ\\face.brep",B);

//Initialize aShape variable: e.g. load it from BREP file
IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(aShape);

//Handle(IVtkOCC_Shape)
aShapeImpl = new IVtkOCC_Shape(aShape);

// 2 .Create VTK polygonal data source for the target OCCT topological shape and initialize it with created 
// IVtkOCC_Shape instance. At this stage the faceter is implicitly plugged.
vtkSmartPointer DS = vtkSmartPointer ::New();
DS->SetShape(aShapeImpl); 

// 3. visualize the load shape in usual VTK way starting a pipline from the newly created specific source.
vtkSmartPointer Mapper = vtkSmartPointer::New();
Mapper->SetInputConnection(DS->GetOutputPort());
vtkSmartPointer Actor = vtkSmartPointer::New();
Actor->SetMapper(Mapper);
vtkSmartPointer renderer = vtkSmartPointer::New();
renderer->AddActor(Actor);
renderer->SetBackground(0.1, 0.2, 0.4);
vtkSmartPointer renWin = vtkSmartPointer::New();
renWin->AddRenderer(renderer);
renWin->SetSize(300, 300);
renWin->SetPosition(300, 300);
// vtkSmartPointer iren = vtkSmartPointer::New();
iren->SetRenderWindow(renWin);
vtkSmartPointer style = vtkSmartPointer::New();
iren->SetInteractorStyle(style);
iren->Initialize();
iren->Start();

Heike Broichhausen's picture

Hello Rui,

this is exactly my problem as well. How did you sort this issue?