Wed, 07/25/2012 - 09:38
Forums:
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.
Fri, 07/27/2012 - 10: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
Fri, 03/29/2013 - 17:44
A thousand thanks!!!