Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
 

New to OpenCascade, can't project to screen

New to OpenCascade, can't project to screen
Travers Biddle 2012/07/25 07:38
Hi, I'm new to OpenCASCADE and currently woking through the bottle tutorial.

I can't figure out how to actually display the image to the screen.

I'm familiar with OpenGL but this has got me stumped and I can't find any resources specifically dealing with this.

Any help would be greatly appreciated.
Travers Biddle 2012/07/27 08:19
Okay, I solved it. It was just much more involved than I originally thought.

For future generations coming across this post here's what I did for a standard MFC SDI program:

In the C**App class header file add these:

     Handle_Graphic3d_WNTGraphicDevice GetGraphicDevice() const { return myGraphicDevice; } ;
     Handle_Graphic3d_WNTGraphicDevice myGraphicDevice;

------------------------------------------------------------------
In the C*App cpp add this to the constructor:

     try
     {myGraphicDevice = new Graphic3d_WNTGraphicDevice();}
     catch(Standard_Failure)
     {
          AfxMessageBox(L"Fatal error during graphic initialization",MB_ICONSTOP);
          ExitProcess(1);
     }

------------------------------------------------------------------
In C**Doc.h add these:

     Handle_V3d_Viewer GetViewer() { return myViewer; };
     Handle_V3d_Viewer myViewer;
     Handle_AIS_InteractiveContext myAISContext;

------------------------------------------------------------------
In C**Doc.cpp add these to the constructor:

     Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice = ((COCCTestApp*)AfxGetApp())->GetGraphicDevice();
     myViewer = new V3d_Viewer(theGraphicDevice,(short *) "Visu3D");
     myViewer->SetDefaultLights();
     myViewer->SetLightOn();
     myAISContext =new AIS_InteractiveContext(myViewer);

------------------------------------------------------------------
In C**View.h add this to the class:

     Handle_V3d_View myView;


------------------------------------------------------------------
In C**View.cpp:
OnInitialUpdate:

     myView = GetDocument()->GetViewer()->CreateView();
     Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice = ((COCCTestApp*)AfxGetApp())->GetGraphicDevice();
     Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
     myView->SetWindow(aWNTWindow);
     if (!aWNTWindow->IsMapped()){

          aWNTWindow->Map();
     }



after constructing the bottle, add this in OnDraw:

     Handle(V3d_Viewer)aViewer = GetDocument()->GetViewer();
     Handle(AIS_InteractiveContext)aContext;
     aContext = new AIS_InteractiveContext(aViewer);
     
     Handle(AIS_Shape) aisthing=new AIS_Shape(aRes);
     aContext->SetDisplayMode(ais2,AIS_Shaded);
     aContext->Display(aisthing);

------------------------------------------------------------------
I'm still new at this so the above could be a terrible way of doing it, but it kind of works
aka 2013/03/29 14:44
A thousand thanks!!!
 
 
Latest news
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map