2011/5/22 Csanády István <istvancsan...@gmail.com>

> Hi Thomas,
>

Hi Istvan,


>
> Thank you for your answer! Actually this would be the simplest way to
> share TopoDS objects, but what if I want to control a pyocc script
> from C++? I mean I want to create pyocc objects from C++ and run
> python codes from C++ (but I dont want to access any data members of
> the objects)?


1. The easiest way, the system() call
#include <stdlib.h>

int main ()
{
  int i;
  // call a python script that generated a .brep topods_shape serialization
  i=system ("python create_topods_shape.py");
  return 0;
}

2. Embed a python interpreter in your C++ app
http://docs.python.org/extending/embedding.html

I don't want to share any other objects, but TopoDS
> objects, but I want to control them from C++, so I need a quite strong
> interoperation between the GUI (which is written in C++) and python.
> Is this possible somehow? (I want to use pyocc because of it's runtime
> features and serialization capabilities, this is why I don't want to
> write the whole stuff in C++) I know this question is not strongly
> related to the pyocc project, but you have serious experience in
> C++/python interop.
>

Not really, I don't use to mix c++ and python, mostly because I *don't* want
to use any C++ code. I did it once, to speed up some algorithm implemented
in python. I ported the algorithm to C++ and called this part of code from
python with a simple SWIG wrapper. So I know how to embed C++ code into
python, but I did not experiment the opposite. Maybe FreeCAD guys could
helps you, since they mix C++/python code from a C++ gui.


>
> István
>

Thomas


>
> On Sun, May 22, 2011 at 5:23 PM, Thomas Paviot <tpav...@gmail.com> wrote:
> > 2011/5/22 Csanády István <istvancsan...@gmail.com>
> >>
> >> OK, I have figured out the answer to my last question -  I did not
> >> know that STANDARD_TYPE(Classname) simply creates a cstring from the
> >> class' name. However I have another question. Is it possible to
> >> integrate a pythonocc code with a C++ code? I want to write the
> >> modeling logic in python, and the rendering and other stuff in C++. So
> >> is it possible somehow to get a TopoDS object from python in a C++
> >> code?
> >>
> >> Thanks,
> >> Istvan
> >>
> >
> > Hi Istvan,
> >
> > IMO, the easiest way to exchange TopoDS shapes between python/C++ is to
> use
> > the .brep serialization. You can easily export any TopoDS_Shape from
> python
> > with the pickle module to a file 'my_shape.brep' and pass it to your c++
> app
> > that will import it. Note that you won't loose any information unlike
> using
> > the STEP or IGES file format.
> >
> > You can have a look at the TopoDS_Shape_pickling example
> > (
> http://code.google.com/p/pythonocc/source/browse/trunk/src/examples/Level1/Serialization/TopoDS_Shape_pickling.py
> ).
> >
> > Details about the implementation of TopoDS_Shape pickling with pythonn is
> > available at lines 925--944 of the SWIG_generator.py file
> > (
> http://code.google.com/p/pythonocc/source/browse/trunk/src/wrapper/SWIG_generator.py
> ).
> > It can easily be ported to C++.
> >
> > Best Regards,
> >
> > Thomas
> >
> >
> >
> >
> > _______________________________________________
> > Pythonocc-users mailing list
> > Pythonocc-users@gna.org
> > https://mail.gna.org/listinfo/pythonocc-users
> >
> >
>
> _______________________________________________
> Pythonocc-users mailing list
> Pythonocc-users@gna.org
> https://mail.gna.org/listinfo/pythonocc-users
>
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to