Question #103867 on DOLFIN changed: https://answers.launchpad.net/dolfin/+question/103867
Kent proposed the following answer: > New question #103867 on DOLFIN: > https://answers.launchpad.net/dolfin/+question/103867 > > I have a mesh generator, written in C++, which I have now linked with > dolfin, using the MeshEditor class to construct > a mesh. This works, but I would like to be able to use it from python. > I have tried to use SWIG to create a module, but I don't know how to tell > it that my new class inherits Mesh. > > Here is a summary of my code... but maybe there is a better way to do > this? > > Chris > > mymesh.i > ======== > > %module mymesh > %{ > /* Put header files here or function declarations like below */ > #include "mymesh.h" > %} > > /* mymesh.h */ > namespace dolfin{ > > class Mymesh : public Mesh > { > public: > Mymesh(); > }; > } > > mymesh.cpp > ========== > > #include "mymesh.h" > > #include <dolfin/mesh/MeshPartitioning.h> > #include <dolfin/mesh/MeshEditor.h> > #include <dolfin.h> > > using namespace dolfin; > ..... > Mymesh::Mymesh() { > Mesheditor editor; > .... > } > > > # swig -c++ -python mymesh.i > mymesh.i:11: Warning(401): Nothing known about base class 'Mesh'. Ignored. > > Hake gave a more comprehensive answer, but here is a short one, to fix only this problem you need to include the path to Mesh on the command line, i.e., swig -c++ -python -I/path/to/Mesh mymesh.i You will also need to include dolfin during linking. Kent > > -- > You received this question notification because you are a member of > DOLFIN Team, which is an answer contact for DOLFIN. > > _______________________________________________ > Mailing list: https://launchpad.net/~dolfin > Post to : [email protected] > Unsubscribe : https://launchpad.net/~dolfin > More help : https://help.launchpad.net/ListHelp > -- You received this question notification because you are a member of DOLFIN Team, which is an answer contact for DOLFIN. _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : [email protected] Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp

