On Monday 18 January 2010 15:45:10 Andre Massing wrote: > Johan Hake wrote: > > On Monday 18 January 2010 15:20:48 Garth N. Wells wrote: > >> On Jan 18 2010, Johan Hake wrote: > >>> On Monday 18 January 2010 13:25:52 Andre Massing wrote: > >>>> Johan Hake wrote: > >>>>> On Monday 18 January 2010 12:58:19 Anders Logg wrote: > >>>>>> On Mon, Jan 18, 2010 at 09:47:38PM +0100, Andre Massing wrote: > >>>>>>> Hi, > >>>>>>> > >>>>>>> I am looking for suitable container in C++ (list, vector, array, > >>>>>>> something ordered, not a set) which is suitable to contain (shared) > >>>>>>> pointer or references to meshes *and* is willing to nicely > >>>>>>> interplay with the swig built python interface. I just want to pass > >>>>>>> a list of meshes to a constructor of a class. Is there any suitable > >>>>>>> classes around DOLFIN? Or it is now easy to wrap a say > >>>>>>> std::vector<boost::shared_ptr<Mesh> > or something similiar? > >>>>>>> > >>>>>>> Regards, > >>>>>>> Andre > >>>>>> > >>>>>> I think the dolfin::Array class is the best option. > >>>>>> > >>>>>> I'm not sure of the status of the wrapping of Array to Python but > >>>>>> the idea is that Array should be designed particularly for simple > >>>>>> wrapping to Python. Hake or Garth knows more. > >>>>> > >>>>> The transition is only done for ArrayDouble and maybe ArrayUInt I > >>>>> guess. > >>>>> > >>>>> For now you should be able to just add: > >>>>> > >>>>> IN_TYPEMAPS_STD_VECTOR_OF_POINTERS(Mesh) > >>>>> > >>>>> in std_vector_typemaps.i where the other similar macros are run. > >>>>> > >>>>> Then you should be able to pass list of Mesh objects to the wrapped > >>>>> C++ method/function. The signature of the C++ function can be any of: > >>>>> > >>>>> bar([const] std::vector< [const] Mesh&> >) > >>>> > >>>> Ok, that might also be an option (and a good opportunity to recall the > >>>> things you taught me :) but did you mean > >>>> > >>>> bar([const] std::vector< [const] Mesh *> >) ? > >>>> ^^^ > >>> > >>> Nope, a reference not a pointer. The typemap that govern this might be > >>> unreadable, but it has served us well ;) > >> > >> You can't use references in a std::vector. In Function, I used > > > > Yes, you're perfectly right. I think I need to read my own documentation > > better, or learn standard C++ better. Sorry to confuse you André... > > Ok, thanks for clarifying, I was really starting to doubt my basic C++ > skills, especially since I already got confused by pointer to pointers > and multidimensional arrays today (Marie knows what I talking about :)
If you blend SWIG into that mess I have compassion with you... > >> http://www.boost.org/doc/libs/1_41_0/libs/ptr_container/doc/ptr_containe > >>r.h tml > >> > >> to have a container of pointers without using shared_ptr. > >> > >>> It might disappear, as I think Garth want to go back to std_vector.i > >>> typemaps for these cases? > >> > >> We can use dolfin::Array if it's easy. > > > > It should be quite easy, we just need to define a typemap macro for the > > cases where we have pointers to dolfin::Foo instead of primitives. > > Ok, I go for that option. Thanks for the help and greeting to the other > side of the ocean :) Good! I would love to see more people getting their hands dirty with SWIG typemaps :) Johan _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : [email protected] Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp

