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

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forums
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forums / pythonCascade / pythonCascade

pythonCascade

pythonCascade
jelle 2006/01/07 15:33
Hi,

I'm very impressed with some of the efforts binding openCASCADE to python.
I'd be very interested to know what kind of efforts are being made right now in coupling openCASCADE right now, since for instance pythonCASCADE dates back 'til 2003, hence I'm curious about more current efforts.

Cheers,

Jelle
Marco Nawijn 2006/10/06 16:55
Hi Jelle,

I am also very interested in the python/opencascade bindings. I have written an e-mail to the Opencascade company
itself and they confirmed that they have a python binding, but they will not release it to the public :(.

I am willing to give it a try myself, but I am not an experienced C++ programmer and as you probably know, the
Opencascade library is huge. My main motivation would be to use the binding as a core component for a
Python based knowledge based engineering application similar to ICAD (bought by Dassault Systemes) and Genworks(www.genworks.com).

Maybe we can combine our efforts and start with a small demonstration program.

Bye,

Marco


Andy 2006/10/09 10:20
Hi Marco,

I have written some Python bindings for OCC. The objects provide similar functionality to the ICAD geometry objects, although they are not as complete as the ICAD objects and functions at the moment.

SWIG is used to generate the bindings and wxPython is used for the display. Rather than trying to wrap all of the OCC objects, I have created simplified objects (similar to those you would use in ICAD) and wrapped these simplified objects. This seemed to be the most appropriate method since it gave me more control over the interface.

I'm planning on releasing the software at the end of the year. The solution focuses more on knowledge lifecycle and process capture than on KBE so the OCC bindings are just a small part of the overall functionality.

Andy

Marco Nawijn 2006/10/10 14:07
Hi Andy,

Thanks for your response. Interesting to see that you are working on KBE lifecycle and process capture with Python/OCC (and probably other software). I have a few questions:

1.) Can you tell me which OCC objects you have wrapped? I would like to build a demo application where all the bits and pieces
are functioning.

2.) Can you show me an example on how to render OCC output to a wxPython window. This will probably save me a lot of time!

I have worked with SWIG before. I once wrapped the SILO library (for building computational databases) and that worked
quite well for me. However, I don't know how well this works for a library as large as OCC. Currently, I am looking into
boost.python and py++. I will probably try to wrap a few classes with these tools and see how it works.

Thanks again,

Marco



Andy 2006/10/10 14:46
Hi Marco,

As I mentioned, I started by defining the objects that I would want to work with. For example:

Point
Vector
Line
Circle
Box
Curve
IgesWriter
UnitedSolid
etc

I then defined these to have the attributes and methods that I would want to work with. In certain cases these may call on a number of different OCC objects. For instance, the Curve object returns a Normal at a specific U value and so uses the GeomLProp_CLProps object under the covers.

I then wrapped these simplified objects using SWIG, which was simply a matter of including my header files (with the occasional "#ifndef SWIG ...").

I have an object called Display. This obviously handles the display of all of the objects, including things such as zoom, pan, rotate, etc. Display also has a method “SaveAsBMP” which can be called interactively or programmatically to grab the screen.

I call the Display object from Python using something like this:

self.OCCDisplay = Display()
self.OCCDisplay.Set_hWnd(self.GetHandle())
self.OCCDisplay.Initialise()
self.OCCDisplay.SetBackgroundColour(0.200, 0.200, 0.400)

Where "self" in this instance is based on a wx.Panel.

Once you’ve got the hWnd, the code to initialise the display is pretty standard I think. Something like:

Handle(Graphic3d_WNTGraphicDevice) graphicDevice= new Graphic3d_WNTGraphicDevice;
Handle(WNT_Window) aWNTWindow= new WNT_Window(graphicDevice, (HWND*)_hWnd);
Handle(V3d_Viewer) viewer = new V3d_Viewer(graphicDevice, (short* const)"viewer");
view = viewer->CreateView();
view->SetWindow(aWNTWindow);
context = new AIS_InteractiveContext(viewer);
viewer->SetDefaultLights();

Hope that helps.

Andy
Andy 2006/10/10 15:26
Hi Marco,

I've thrown a few examples onto a web page so you can take a look if you like.

http://www.btinternet.com/~a.haywood1/

Apologies for the rough look, but hopefully you get the idea. All of the examples are written in Python using the wrapped objects.

Andy
Marco Nawijn 2006/10/13 10:34
Hi Andy,

Looks nice! At the moment I am setting up my new Macbook
for compiling Opencascade. This should not be a very big
problem. Further, I decided to try to wrap the FoundationClasses using boost.python and py++. I will keep you informed about the progress. If all things turnout fine, I will contribute the wrapper to the OCC community.

Thanks a lot for your response!

Marco
jelle 2006/11/30 12:07
Hi Andy & Marco,

What an interesting thread this has become!
I'm very excited to see both Andres screenshots & Marco intention of wrapping the FoundationClasses. I wonder what the overlap is between both your projects.

Andy, I've tried to reach you via email, but haven't been able to find your address.
Would you be so kind to drop me a line on jelleferinga@gmail.com ?

Cheers,

-jelle
 
 
Latest news
  • Open CASCADE Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!

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