
Wed, 02/21/2018 - 22:22
Forums:
Hello!
I am extremely new to OpenCascade, but I am trying to get its base functionality integrated into my research. I have a simple Topo_DS_Shape object created, and I would like to open up a window and look at it. I don't need anything fancy for now, just a viewer window. So here is my initial attempt (I am working on a macbook pro, early 2015 with HighSierra).
int main(int argc, char *argv[])
{
BRepPrimAPI_MakeTorus TorusGen(1.0, 3.0);
TopoDS_Shape torus = TorusGen.Shape();
cout << "torus generated" << endl;
// create a default display connection
Handle(Aspect_DisplayConnection) aDispConnection = new Aspect_DisplayConnection();
// create a Graphic Driver
Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (aDispConnection, true);
// creating the Viewer
Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
cout << "V3d_Viewer created" << endl;
Standard_Integer thePxLeft = 100;
Standard_Integer thePxTop = 100;
Standard_Integer thePxWidth = 100;
Standard_Integer thePxHeight = 100;
cout << "Creating Cocoa Window..." << endl;
Handle(Cocoa_Window) aCocoaWindow;
aCocoaWindow = new Cocoa_Window("title",thePxLeft, thePxTop, thePxWidth, thePxHeight);
cout << "Cocoa Window created" << endl;
// creating a View
Handle(V3d_View) aView = aViewer->CreateView();
// the Interactive context
Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext(aViewer);
Handle(AIS_Shape) anAISShape = new AIS_Shape(torus);
aContext->Display(anAISShape, true);
aView->SetWindow(aCocoaWindow);
cout << "cocoa window associated with aView" << endl;
aCocoaWindow->Map();
return 0;
}
This compiles fine, but when I run it, I get an uncaught exception
Aspect_WindowDefinitionError
when the Cocoa_Window is being defined.
I am sure I am making a totally rookie mistake, but I would love the help!
Thanks!
Wed, 02/21/2018 - 22:40
I think there should more detailed message in console coming with this exception.
If you will look into source code, you will find only a couple of reasons for this error, and I suppose this one was hit:
Your code does not perform initialization of GUI application.
There is no Cocoa sample coming with OCCT, but you might find useful an old commit with a sample draft (for older OCCT version):
http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff;h=bea07fd...
Fri, 02/23/2018 - 00:11
Hello!
Thanks for getting back to me so quickly.
The full console message reads:
which is unfortunately not particularly verbose.
So it appears that the way this stuff is handled in an AppDelegate. I got what I was looking for cooked up with inspiration from that sample draft you posted.
main.mm:
AppDelegate.h
AppDelegate.mm
And that's it! Just gotta make sure all the libraries and frameworks get linked to the build properly. I am certain there are much better ways to accomplish this, but it works, so I'm happy! Attached is a screenshot of the output.
Thank you so much for the help! Hopefully this example will help others get off the ground with OpenCascade on macOS.
Cheers!