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

Visualization

Pranav's picture
Forums: 

Greetings,

I'm trying to visualize a BSpline I've generated using OCCT. 

My code is:

/// Displaying OCCT BSpline

    std::string fileName="AH82150F_processed.dat";

    Standard_Integer num_coordinates = 97; // Number of coordinates

    Hydrofoil f(fileName, num_coordinates, 5, CLOCKWISE_LE);

    TopoDS_Edge bspline = BRepBuilderAPI_MakeEdge(f.getCurve());

    Handle(AIS_Shape) anEdge = new AIS_Shape(bspline);

    anEdge->SetColor(Quantity_NOC_RED);

    const TCollection_AsciiString displayName("m:0.0");

    Standard_ExtString dname= 0;

    const Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();

    Handle(Graphic3d_GraphicDriver) driver3d = new OpenGl_GraphicDriver(aDisplayConnection);

    Handle(V3d_Viewer) viewer; // = new V3d_Viewer(driver3d, dname);

    Handle(V3d_View) view;

    // Create V3dViewer and V3d_View

    viewer = new V3d_Viewer(driver3d, (short* const)"viewer");

    view = viewer->CreateView();

    // Create AISInteractiveContext

    Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(viewer);

    aContext = new AIS_InteractiveContext(viewer);

    // Set up lights etc

    viewer->SetDefaultLights();

    viewer->SetLightOn();

    // view->SetBackgroundColor(Quantity_NOC_BLACK);

    // view->MustBeResized();

    // view->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_ZBUFFER);

    // Handle(V3d_Viewer) aViewer = ...;

    aContext -> Display(anEdge);

    //Display the presentable  object in the 3d viewer.

This does not create a window or widget to display. Could anybody kindly provide sample code which'll help me build a simple visualiser for the geometries I build. It should allow for viewing in different planes and rotation. Your help would be much appreciated.

Attachments: 
Kirill's picture

Your code does not creates a window for mapping 3D View (e.g. V3d_View::SetWindow()).

There are a bunch of samples creating a 3D viewer using various frameworks - Qt/MFC/Android(Java), just look into subfolder "samples"
(for example: samples\mfc\standard\04_Viewer3d\src\Viewer3dView.cpp).

Pranav's picture

Hi Kirill,

Thanks for the reply.

I have looked into the subfolder and tried compiling the qt example. I wasn't successfull as the example is out-of-date for opencascade-7.0.0. There is one example of occQt which I could get running and it is available here: https://github.com/eryar/occQt .

However, this example doesn't implement rotation and perspective viewing. I need help with that.

Best Regards,
Pranav

Kirill's picture

I have looked into the subfolder and tried compiling the qt example.
I wasn't successfull as the example is out-of-date for opencascade-7.0.0.

All samples coming within OCCT itself are supposed to be compatible with the OCCT version they are coming from.
They are also coming in binary form within OCCT installer for Windows - so it is unclear what do you mean by "out-of-date".
Within OCCT 7.0.0, Qt samples have also received some patches improving compatibility with Qt 5.x.

Pranav's picture

Hi Kirill,

Not necessarily. While the source code is updated, the examples are sometimes shipped without changes. The OCCT-Qt example hasn't been updated in quite sometime. The OCCT team told me so.