Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Opencascade visualization in QT



  • Hi everyone,

    I am trying to execute an opencascade example: "MakeBottle". This example returns a TopoDS_Shape. I have been able to compile but I am not see any bottle. The qt window is empty. You can find the code below:

    int main(int argc, char *argv[])
    {
    
      QApplication a(argc, argv);
    
      // create a Qt window
      QWidget *window = new QWidget();
    
        // create a bottle (TopoDS_Shape)
      TopoDS_Shape myBottle = MakeBottle(70., 120., 30.);
    
      // th DisplayDonnection
      Handle(Aspect_DisplayConnection) aDisplayConnection;
    
      // the GraphicDriver
      Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
    
      // creating the Viewer
      Handle(V3d_Viewer) aViewer = new V3d_Viewer(aGraphicDriver, Standard_ExtString("my3dViewer"));
    
      // creating a View
      Handle(V3d_View) aView = aViewer->CreateView();
    
    
      Handle(WNT_Window) wind = new WNT_Window((Aspect_Handle)window->winId());
    
      // the Interactive context
      Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(aViewer);
    
      Handle(AIS_Shape) anAISShape = new AIS_Shape(myBottle);
      aContext->Display(anAISShape, true);
    
      aView->SetWindow(wind);
    
      window->show();
      return a.exec();
    
    }
    

    Thanks in advance.

    Kind regards.


  • Lifetime Qt Champion

    Hi,

    OpenCascade is providing Qt examples, did you try them ?



  • I guess the problem is rather related to the setup of the OpenGl context for the viewer or something like that than to OCCT. What OS are you on?


Log in to reply