
Wed, 08/15/2018 - 05:14
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();
Tue, 01/15/2019 - 13:33
Hello Rui,
this is exactly my problem as well. How did you sort this issue?
Fri, 11/29/2019 - 16:34
Hello Rui Song ,
I also encountered this problem now, did you solve it? occ730
Tue, 05/21/2024 - 08:20
I had the same issue.
When printing
cpp std::cout << "GetNumberOfOutputPorts : " << occSource->GetNumberOfOutputPorts() << std::endl;
, I had a negative value.To fix it, during the compilation of OCCT, it you chosse "USE_VTK" the VTK 6.1 will be selected automatically in 3rparty dir. Change it to the version you want to use.
I am running with OCCT 7.8.1 and VTK 9.3 with this code: