天天看點

linux下OpenCasCade初始化

頭檔案需要自己引用一下

初始化代碼如下

Handle(Aspect_DisplayConnection) aDisplayConnection =
                new Aspect_DisplayConnection();

        // Get graphic driver if it exists, otherwise initialise it
        if (myGraphicDriver.IsNull())
        {
            myGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
        }

        // Get window handle. This returns something suitable for all platforms.
        WId window_handle = (WId) winId();

    // Create appropriate window for platform
#ifdef WNT
    Handle(WNT_Window) wind = new WNT_Window((Aspect_Handle) window_handle);
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
    Handle(Cocoa_Window) wind = new Cocoa_Window((NSView *) window_handle);
#else
    Handle(Xw_Window) wind = new Xw_Window(aDisplayConnection, (Window) window_handle);
#endif

// Create V3dViewer and V3d_View
myViewer = new V3d_Viewer(myGraphicDriver, Standard_ExtString("viewer3d"));

myView = myViewer->CreateView();

myView->SetWindow(wind);
if (!wind->IsMapped()) wind->Map();

// Create AISInteractiveContext
myAISContext = new AIS_InteractiveContext(myViewer);

// Set up lights etc
myViewer->SetDefaultLights();
myViewer->SetLightOn();

myView->SetBackgroundColor(Quantity_NOC_BLACK);
myView->MustBeResized();
myView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_ZBUFFER);

myAISContext->SetDisplayMode(AIS_Shaded, Standard_True);
           

繼續閱讀