Orientation of visualization

Hello,

If I read a STEP file that contains the model of a mug (see mug.png) and I try to represent it by the V3d_View with the parameters shown below, I get the view shown in view.png :

        aView->Camera()->SetCenter(centre); //Look-at point of the camera
        aView->Camera()->SetDirection(gp_Dir(-1., 0., 0.)); //Camera direction
        aView->Camera()->SetDistance(200.0); //Camera distance
        aView->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Perspective);   

Why is it shown leaning?How can I solve that?

Thanks!

Attachments: 
Pranav's picture

Hi Adriana,

I'm new to OCCT and I've been trying to build a visualizer for my application. I'm finding it difficult to launch a widget which renderes my geometry and was hoping you could help. Would it be possible for you provide me a small example of your code for the viewer?

Regards,
Pranav 

Adriana Costas's picture

Hi Pranav,

Here you are.

 static Handle(OpenGl_GraphicDriver) aGraphicDriver;
        Handle(Aspect_DisplayConnection) aDisplayConnection;
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
        aDisplayConnection = new Aspect_DisplayConnection(getenv("DISPLAY"));
#endif
        aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);

        // creating the Viewer
        Handle(V3d_Viewer) aViewer = new V3d_Viewer(aGraphicDriver);
        aViewer->SetDefaultLights();
        aViewer->SetLightOn();

        // creating a View
        Handle(V3d_View) aView = aViewer->CreateView();

        Handle(Xw_Window) W = new Xw_Window(aDisplayConnection, "Test V3d", 0.5, 0.5, 500, 500);
        // Map this Window to this screen
        if (!W->IsMapped()) {
            W->Map();

        }

        // the Interactive context
        Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(aViewer);
        Handle(AIS_Shape) anAISShape = new AIS_Shape(result);

        Standard_Integer mode = 1;
        aContext->SetDisplayMode(mode, Standard_False);
        aContext->Display(anAISShape);     

        aView->SetWindow(W);

 

Regards,

Adriana