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

A mimimal example Cascade & 3D viewer (V3d_Viewer)

aka's picture

Data in class or global data:

Handle_Graphic3d_WNTGraphicDevice myGraphicDevice;
Handle_V3d_Viewer myViewer;
Handle_AIS_InteractiveContext myAISContext;
Handle_V3d_View myView;
Handle_WNT_WClass myWClass;
Handle(WNT_Window) aWNTWindow;

Code of 3D view initialization:

myGraphicDevice = new Graphic3d_WNTGraphicDevice();

Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice = myGraphicDevice;
theGraphicDevice = myGraphicDevice;
//Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,parent_window);
try {
myWClass= new WNT_WClass((char*)L"some_class_fdfdddd",NULL,CS_HREDRAW|CS_VREDRAW);
} catch (WNT_ClassDefinitionError &err) {
int errcode=GetLastError();
int x=0;
WNT_Window * t = new WNT_Window(theGraphicDevice,"some_win_mmmmddddd",myWClass,WS_VISIBLE ,1,1,400,400,Quantity_NOC_MATRAGRAY,NULL);
//WNT_Window * t = new WNT_Window(theGraphicDevice,"some_win_mmmmddddd",myWClass,WS_CHILD | WS_VISIBLE | WS_TABSTOP,1,1,400,400,Quantity_NOC_MATRAGRAY,parent_window);
aWNTWindow = t;
myViewer = new V3d_Viewer(theGraphicDevice,(short *) "Visu3D");
myView = myViewer->CreateView();
if (!aWNTWindow->IsMapped()){

myAISContext =new AIS_InteractiveContext(myViewer);

Handle(V3d_Viewer) aViewer = myViewer;
Handle(AIS_InteractiveContext) aContext;
aContext = new AIS_InteractiveContext(aViewer);

BRepPrimAPI_MakeSphere S(gp_Pnt(0,300,0), 100.);
Handle(AIS_Shape) aisthing=new AIS_Shape(S.Shape());

thanks for Travers Biddle

Be sure to call


everytime when you modify the shape.

Be sure to call


everytime when WM_PAINT processed

Amine M's picture


This is my first time using OpenCASCADE, so please be patient with me .

I'm trying for 4 days to make it works but have nothing yet, And each time I find a good example to follow I find some changes in the OCCT versions.

For example: I have no Handle_Graphic3d_WNTGraphicDevice (I'm on ubuntu, but there is no such thing with xw), no Graphic3d.hxx (used in some examples), no Handle_Aspect_GraphicDevice (also used in another example), for Graphic3d_GraphicDriver I have to use OpenGl_GraphicDriver ... and too many others!.

So I have some questions:

  1. 1) Is there a very simple (minimal) example on showing an object (a box for example) ?
  2. 2) Is Qt needed to show an object, or I can have an OpenGL window only ?
  3. 3) As I'm on Ubuntu, I have no samples on my installation, Where can I download the official Linux samples (for qt) ?

Here is the code I have:

    TopoDS_Shape myBottle = MakeBottle(70., 120., 30.); // from the official tutorial

    Handle(Aspect_DisplayConnection) aDisplayConnection;
    Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);

    //Handle(Xw_Window) aWindow = new Xw_Window(aDisplayConnection, (short* const)"myViewer", 0, 0, 640, 480);
    // this is commented because it returns error, It's bad implemented

    Handle(V3d_Viewer) aViewer = new V3d_Viewer(aGraphicDriver, (short* const)"Viewer");

    Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(aViewer);
    Handle(AIS_Shape) anAISShape = new AIS_Shape(myBottle);


OCCT 6.8.0

OS : Ubuntu 14.04 32bit

Forum supervisor's picture

Dear Amine,

The source package of Open CASCADE Technology 6.9.1 (including documentation, source files of samples and a set of building procedures) is available for all platforms via OCCT Download Center -

Detailed instructions you can find at the sub-folder of installation package - .../opencascade-6.9.1/doc/overview/.

See chapters "../Developer Guides / Building OCCT from sources " and "../Tutorial".

Best regards.


Forum supervisor's picture

Dear Amine,

To be more clear I suggest you OCCT Qt sample $CASROOT/samples/qt/Tutorial as a place to consult.

Best regards