/* Tell swig how to treat various types when moving them to and from python. Among other things, they tell swig how to convert collections of C++ objects (eg ExampleRestraints) into python lists and back. IMP_SWIG_OBJECT, IMP_SWIG_VALUE and IMP_SWIG_DECORATOR lines need to appear before any %include lines as well as any inline C++ code (or at least any such code which uses the types in question). */ IMP_SWIG_OBJECT(IMP::example, ExampleRestraint, ExampleRestraints); IMP_SWIG_DECORATOR(IMP::example, ExampleDecorator, ExampleDecorators); IMP_SWIG_OBJECT(IMP::example, ExampleUnaryFunction, ExampleUnaryFunctions); IMP_SWIG_OBJECT(IMP::example, ExampleSingletonModifier, ExampleSingletonModifiers); /* One can add python methods to your module by putting code in %pythoncode blocks This function can be called as IMP.examples.say_hello(). */ %pythoncode %{ def create_model_and_particles(): m= IMP.Model() sc= IMP.container.ListSingletonContainer(m) b= IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(0,0,0), IMP.algebra.Vector3D(10,10,10)) for i in range(0,100): p= IMP.Particle(m) sc.add_particle(p) d=IMP.core.XYZR.setup_particle(p, IMP.algebra.Sphere3D(IMP.algebra.get_random_vector_in(b), 1)) d.set_coordinates_are_optimized(True) return (m, sc) %} /* Wrap our own classes. Each header in the module should be listed here with a %include line.*/ %include "IMP/example/ExampleRestraint.h" %include "IMP/example/ExampleDecorator.h" %include "IMP/example/ExampleUnaryFunction.h" %include "IMP/example/ExampleRefCounted.h" %include "IMP/example/ExampleSingletonModifier.h" %include "IMP/example/ExampleTemplateClass.h" namespace IMP { namespace example { /* Python doesn't natively support C++ templates, so you have to manually choose which template parameters you want to intantiate a template with. */ %template(ExampleTemplateClass3D) ExampleTemplateClass<3>; } }