yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #05291
[Branch ~yade-dev/yade/trunk] Rev 2354: 1. Make GL dispatchers proper classes exposed to python
------------------------------------------------------------
revno: 2354
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-07-12 19:36:42 +0200
message:
1. Make GL dispatchers proper classes exposed to python
2. Make State and derived classes indexable
3. Update scripts/test/dispatcher-torture.py
modified:
core/Dispatcher.hpp
core/State.hpp
doc/sphinx/yadeSphinx.py
lib/multimethods/DynLibDispatcher.hpp
pkg/common/DataClass/Shape/Cylinder.cpp
pkg/common/DataClass/Shape/Cylinder.hpp
pkg/common/RenderingEngine/GLDrawFunctors.cpp
pkg/common/RenderingEngine/GLDrawFunctors.hpp
pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp
pkg/common/RenderingEngine/OpenGLRenderingEngine.hpp
pkg/dem/Engine/GlobalEngine/CohesiveFrictionalPM.hpp
pkg/dem/meta/ConcretePM.hpp
py/yadeWrapper/customConverters.cpp
scripts/test/dispatcher-torture.py
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/Dispatcher.hpp'
--- core/Dispatcher.hpp 2010-06-11 22:22:13 +0000
+++ core/Dispatcher.hpp 2010-07-12 17:36:42 +0000
@@ -185,7 +185,7 @@
return "";
}
- protected :
+ public :
void postProcessAttributes(bool deserializing)
{
Dispatcher::postProcessAttributes(deserializing);
=== modified file 'core/State.hpp'
--- core/State.hpp 2010-06-08 22:25:00 +0000
+++ core/State.hpp 2010-07-12 17:36:42 +0000
@@ -1,6 +1,8 @@
// 2009 © Václav Šmilauer <eudoxos@xxxxxxxx>
#pragma once
#include<yade/lib-serialization/Serializable.hpp>
+#include<yade/lib-multimethods/Indexable.hpp>
+#include<yade/core/Dispatcher.hpp>
/*! State (internal & spatial variables) of a body.
For now, I put position, orientation, velocity and angular velocity here,
@@ -14,7 +16,7 @@
Historical note: this used to be part of the PhysicalParameters class.
The other data are now in the Material class.
*/
-class State: public Serializable{
+class State: public Serializable, public Indexable{
public:
/// linear motion (references to inside se3)
Vector3r& pos;
@@ -75,10 +77,12 @@
((ori,se3.orientation)),
/* ctor */,
/*py*/
+ YADE_PY_TOPINDEXABLE(State)
.add_property("blockedDOFs",&State::blockedDOFs_vec_get,&State::blockedDOFs_vec_set,"Degress of freedom where linear/angular velocity will be always constant (equal to zero, or to an user-defined value), regardless of applied force/torque. List of any combination of 'x','y','z','rx','ry','rz'.")
// references must be set using wrapper funcs
.add_property("pos",&State::pos_get,&State::pos_set,"Current position.")
.add_property("ori",&State::ori_get,&State::ori_set,"Current orientation.")
);
+ REGISTER_INDEX_COUNTER(State);
};
REGISTER_SERIALIZABLE(State);
=== modified file 'doc/sphinx/yadeSphinx.py'
--- doc/sphinx/yadeSphinx.py 2010-07-12 09:11:16 +0000
+++ doc/sphinx/yadeSphinx.py 2010-07-12 17:36:42 +0000
@@ -131,7 +131,7 @@
sect('Constitutive laws','',['LawFunctor','LawDispatcher'])+
sect('Callbacks','',['BodyCallback','IntrCallback'])+
sect('Preprocessors','',['FileGenerator'])+
- sect('Rendering','',['OpenGLRenderingEngine','GlShapeFunctor','GlStateFunctor','GlBoundFunctor','GlInteractionGeometryFunctor','GlInteractionPhysicsFunctor'])+
+ sect('Rendering','',['OpenGLRenderingEngine','GlShapeFunctor','GlStateFunctor','GlBoundFunctor','GlInteractionGeometryFunctor','GlInteractionPhysicsFunctor','GlShapeDispatcher','GlStateDispatcher','GlBoundDispatcher,','GlInteractionGeometryDispatcher','GlInteractionPhysicsDispatcher'])+
sect('Simulation data','',['Omega','BodyContainer','InteractionContainer','ForceContainer','MaterialContainer'])
+"""
Other classes
=== modified file 'lib/multimethods/DynLibDispatcher.hpp'
--- lib/multimethods/DynLibDispatcher.hpp 2009-12-13 19:27:57 +0000
+++ lib/multimethods/DynLibDispatcher.hpp 2010-07-12 17:36:42 +0000
@@ -216,7 +216,7 @@
shared_ptr<Executor> getExecutor(shared_ptr<BaseClass1>& arg1){
int ix1;
if(arg1->getClassIndex()<0) throw runtime_error("No functor for type "+arg1->getClassName()+" (index "+lexical_cast<string>(arg1->getClassIndex())+"), since the index is invalid (negative).");
- if(locateMultivirtualFunctor2D(ix1,arg1)) return callBacks[ix1];
+ if(locateMultivirtualFunctor1D(ix1,arg1)) return callBacks[ix1];
return shared_ptr<Executor>();
}
=== modified file 'pkg/common/DataClass/Shape/Cylinder.cpp'
--- pkg/common/DataClass/Shape/Cylinder.cpp 2010-07-12 14:06:55 +0000
+++ pkg/common/DataClass/Shape/Cylinder.cpp 2010-07-12 17:36:42 +0000
@@ -1,6 +1,8 @@
#include "Cylinder.hpp"
#include<yade/pkg-common/Sphere.hpp>
-#include<yade/lib-opengl/OpenGLWrapper.hpp>
+#ifdef YADE_OPENGL
+ #include<yade/lib-opengl/OpenGLWrapper.hpp>
+#endif
#include<yade/pkg-common/Aabb.hpp>
Cylinder::~Cylinder(){}
@@ -9,8 +11,13 @@
CylScGeom::~CylScGeom(){}
-YADE_PLUGIN((Cylinder)(ChainedCylinder)(ChainedState)(CylScGeom)(Ig2_Sphere_ChainedCylinder_CylScGeom)(Ig2_ChainedCylinder_ChainedCylinder_ScGeom)(Gl1_Cylinder)/*(Gl1_ChainedCylinder)*/(Bo1_Cylinder_Aabb)/*(Bo1_ChainedCylinder_Aabb)*/);
-YADE_REQUIRE_FEATURE(OPENGL)
+YADE_PLUGIN(
+ (Cylinder)(ChainedCylinder)(ChainedState)(CylScGeom)(Ig2_Sphere_ChainedCylinder_CylScGeom)(Ig2_ChainedCylinder_ChainedCylinder_ScGeom)
+ #ifdef YADE_OPENGL
+ (Gl1_Cylinder)/*(Gl1_ChainedCylinder)*/
+ #endif
+ (Bo1_Cylinder_Aabb)/*(Bo1_ChainedCylinder_Aabb)*/
+);
vector<vector<int> > ChainedState::chains;
unsigned int ChainedState::currentChain=0;
@@ -157,6 +164,7 @@
return go(cm2,cm1,state2,state1,-shift2,force,c);
}
+#ifdef YADE_OPENGL
//!################## RENDERING #####################
bool Gl1_Cylinder::wire;
@@ -275,6 +283,7 @@
//!################## BOUNDS FUNCTOR #####################
+#endif
void Bo1_Cylinder_Aabb::go(const shared_ptr<Shape>& cm, shared_ptr<Bound>& bv, const Se3r& se3, const Body* b){
Cylinder* cylinder = static_cast<Cylinder*>(cm.get());
=== modified file 'pkg/common/DataClass/Shape/Cylinder.hpp'
--- pkg/common/DataClass/Shape/Cylinder.hpp 2010-07-12 14:06:55 +0000
+++ pkg/common/DataClass/Shape/Cylinder.hpp 2010-07-12 17:36:42 +0000
@@ -5,7 +5,9 @@
#include<yade/pkg-dem/ScGeom.hpp>
#include<yade/pkg-common/InteractionGeometryFunctor.hpp>
#include<yade/core/Scene.hpp>
-#include<yade/pkg-common/GLDrawFunctors.hpp>
+#ifdef YADE_OPENGL
+ #include<yade/pkg-common/GLDrawFunctors.hpp>
+#endif
#include<yade/pkg-common/BoundFunctor.hpp>
@@ -73,8 +75,9 @@
/* additional initializers */
/* ((pos,se3.position))
((ori,se3.orientation)),*/
- /* ctor */,
- /*py*/,
+ ,
+ /* ctor */ createIndex(); ,
+ /*py*/
// .def_readwrite("chains",&ChainedState::chains,"documentation")
.def_readwrite("currentChain",&ChainedState::currentChain,"Current active chain (where newly created chained bodies will be appended).")
.def("addToChain",&ChainedState::addToChain,(python::arg("bodyId")),"Add body to current active chain")
@@ -116,7 +119,7 @@
-
+#ifdef YADE_OPENGL
class Gl1_Cylinder : public GlShapeFunctor{
private:
static int glCylinderList;
@@ -134,6 +137,7 @@
RENDERS(Cylinder);
friend class Gl1_ChainedCylinder;
};
+#endif
//!This doesn't work : the 1D dispatcher will pick Gl1_Cylinder to display ChainedCylinders, workaround : add shift to cylinders (should be a variable of chained cylinders only).
// class Gl1_ChainedCylinder : public Gl1_Cylinder{
@@ -190,7 +194,9 @@
REGISTER_SERIALIZABLE(Bo1_Cylinder_Aabb);
// REGISTER_SERIALIZABLE(Bo1_ChainedCylinder_Aabb);
+#ifdef YADE_OPENGL
REGISTER_SERIALIZABLE(Gl1_Cylinder);
+#endif
// REGISTER_SERIALIZABLE(Gl1_ChainedCylinder);
REGISTER_SERIALIZABLE(Cylinder);
REGISTER_SERIALIZABLE(ChainedCylinder);
=== modified file 'pkg/common/RenderingEngine/GLDrawFunctors.cpp'
--- pkg/common/RenderingEngine/GLDrawFunctors.cpp 2010-02-06 16:01:07 +0000
+++ pkg/common/RenderingEngine/GLDrawFunctors.cpp 2010-07-12 17:36:42 +0000
@@ -1,3 +1,6 @@
#include<yade/pkg-common/GLDrawFunctors.hpp>
-YADE_PLUGIN((GlBoundFunctor)(GlShapeFunctor)(GlInteractionGeometryFunctor)(GlInteractionPhysicsFunctor)(GlStateFunctor));
+YADE_PLUGIN(
+(GlBoundFunctor)(GlShapeFunctor)(GlInteractionGeometryFunctor)(GlInteractionPhysicsFunctor)(GlStateFunctor)
+(GlBoundDispatcher)(GlShapeDispatcher)(GlInteractionGeometryDispatcher)(GlInteractionPhysicsDispatcher)(GlStateDispatcher)
+);
YADE_REQUIRE_FEATURE(OPENGL);
=== modified file 'pkg/common/RenderingEngine/GLDrawFunctors.hpp'
--- pkg/common/RenderingEngine/GLDrawFunctors.hpp 2010-04-25 13:18:11 +0000
+++ pkg/common/RenderingEngine/GLDrawFunctors.hpp 2010-07-12 17:36:42 +0000
@@ -8,11 +8,12 @@
#include<yade/core/State.hpp>
#include<yade/core/Shape.hpp>
#include<yade/core/Functor.hpp>
+#include<yade/core/Dispatcher.hpp>
#include<yade/core/InteractionGeometry.hpp>
#include<yade/core/Body.hpp>
#include<yade/core/InteractionPhysics.hpp>
-#define RENDERS(name) public: virtual string renders() const { return #name;};
+#define RENDERS(name) public: virtual string renders() const { return #name;}; FUNCTOR1D(name);
struct GLViewInfo{
GLViewInfo(): sceneCenter(Vector3r::Zero()), sceneRadius(1.){}
@@ -20,48 +21,27 @@
Real sceneRadius;
};
-class GlBoundFunctor: public Functor1D<void, TYPELIST_2(const shared_ptr<Bound>&, Scene*)> {
- public:
- virtual ~GlBoundFunctor() {};
- virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
- virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
- YADE_CLASS_BASE_DOC(GlBoundFunctor,Functor,"Abstract functor for rendering :yref:`Body::bound` objects.");
-};
-REGISTER_SERIALIZABLE(GlBoundFunctor);
-
-class GlShapeFunctor: public Functor1D<void, TYPELIST_4(const shared_ptr<Shape>&, const shared_ptr<State>&,bool,const GLViewInfo&)>{
- public:
- virtual ~GlShapeFunctor() {};
- virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
- virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
- YADE_CLASS_BASE_DOC(GlShapeFunctor,Functor,"Abstract functor for rendering :yref:`Body::shape` objects.");
-};
-REGISTER_SERIALIZABLE(GlShapeFunctor);
-
-class GlInteractionGeometryFunctor: public Functor1D<void,TYPELIST_5(const shared_ptr<InteractionGeometry>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool)>{
- public:
- virtual ~GlInteractionGeometryFunctor() {};
- virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
- virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
- YADE_CLASS_BASE_DOC(GlInteractionGeometryFunctor,Functor,"Abstract functor for rendering :yref:`Interaction::interactionGeometry` objects.");
-};
-REGISTER_SERIALIZABLE(GlInteractionGeometryFunctor);
-
-class GlInteractionPhysicsFunctor: public Functor1D<void, TYPELIST_5(const shared_ptr<InteractionPhysics>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool)>{
- public:
- virtual ~GlInteractionPhysicsFunctor() {};
- virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
- virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
- YADE_CLASS_BASE_DOC(GlInteractionPhysicsFunctor,Functor,"Abstract functor for rendering :yref:`Interaction::interactionPhysics` objects.");
-};
-REGISTER_SERIALIZABLE(GlInteractionPhysicsFunctor);
-
-class GlStateFunctor: public Functor1D<void,TYPELIST_1(const shared_ptr<State>&/*, draw parameters: color, scale, given from OpenGLRenderer, or sth.... */)>{
- public :
- virtual ~GlStateFunctor() {};
- virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
- virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
- YADE_CLASS_BASE_DOC(GlStateFunctor,Functor,"Abstract functor for rendering :yref:`Body::state` objects.");
-};
-REGISTER_SERIALIZABLE(GlStateFunctor);
+#define GL_FUNCTOR(klass,typelist,renderedType) class klass: public Functor1D<void,typelist>{public:\
+ virtual ~klass(){};\
+ virtual string renders() const { throw std::runtime_error(#klass ": unregistered gldraw class.\n"); };\
+ virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};\
+ YADE_CLASS_BASE_DOC(klass,Functor,"Abstract functor for rendering :yref:`" #renderedType "` objects.");};\
+ REGISTER_SERIALIZABLE(klass);
+#define GL_DISPATCHER(klass,typelist,functor,disptype) class klass: public Dispatcher1D<disptype,functor,void,typelist>{public:\
+ YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(klass,Dispatcher,"Dispatcher calling :yref:`" #functor"s<" #functor">` based on :yref:`" #disptype "` type.",/*attrs*/,/*ctor*/,/*py*/YADE_PY_DISPATCHER(klass)); };\
+ REGISTER_SERIALIZABLE(klass);
+
+GL_FUNCTOR(GlBoundFunctor,TYPELIST_2(const shared_ptr<Bound>&, Scene*),Bound);
+GL_FUNCTOR(GlShapeFunctor,TYPELIST_4(const shared_ptr<Shape>&, const shared_ptr<State>&,bool,const GLViewInfo&),Shape);
+GL_FUNCTOR(GlInteractionGeometryFunctor,TYPELIST_5(const shared_ptr<InteractionGeometry>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool),InteractionGeometry);
+GL_FUNCTOR(GlInteractionPhysicsFunctor,TYPELIST_5(const shared_ptr<InteractionPhysics>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool),InteractionGeometry);
+GL_FUNCTOR(GlStateFunctor,TYPELIST_1(const shared_ptr<State>&),State);
+
+GL_DISPATCHER(GlBoundDispatcher,TYPELIST_2(const shared_ptr<Bound>&, Scene*),GlBoundFunctor,Bound);
+GL_DISPATCHER(GlShapeDispatcher,TYPELIST_4(const shared_ptr<Shape>&, const shared_ptr<State>&,bool,const GLViewInfo&),GlShapeFunctor,Shape);
+GL_DISPATCHER(GlInteractionGeometryDispatcher,TYPELIST_5(const shared_ptr<InteractionGeometry>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool),GlInteractionGeometryFunctor,InteractionGeometry);
+GL_DISPATCHER(GlInteractionPhysicsDispatcher,TYPELIST_5(const shared_ptr<InteractionPhysics>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool),GlInteractionPhysicsFunctor,InteractionPhysics);
+GL_DISPATCHER(GlStateDispatcher,TYPELIST_1(const shared_ptr<State>&),GlStateFunctor,State);
+#undef GL_FUNCTOR
+#undef GL_DISPATCHER
=== modified file 'pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp'
--- pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp 2010-06-08 22:25:00 +0000
+++ pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp 2010-07-12 17:36:42 +0000
@@ -26,7 +26,6 @@
const int OpenGLRenderingEngine::numClipPlanes;
void OpenGLRenderingEngine::init(){
-
map<string,DynlibDescriptor>::const_iterator di = Omega::instance().getDynlibsDescriptor().begin();
map<string,DynlibDescriptor>::const_iterator diEnd = Omega::instance().getDynlibsDescriptor().end();
for(;di!=diEnd;++di){
@@ -390,6 +389,7 @@
if(!deserializing) return;
for(unsigned int i=0;i<boundFunctorNames.size();i++) boundDispatcher.add1DEntry(boundFunctorNames[i][0],boundFunctorNames[i][1]);
for(unsigned int i=0;i<shapeFunctorNames.size();i++) shapeDispatcher.add1DEntry(shapeFunctorNames[i][0],shapeFunctorNames[i][1]);
+ for(unsigned int i=0;i<stateFunctorNames.size();i++) stateDispatcher.add1DEntry(stateFunctorNames[i][0],stateFunctorNames[i][1]);
for(unsigned int i=0;i<interactionGeometryFunctorNames.size();i++) interactionGeometryDispatcher.add1DEntry(interactionGeometryFunctorNames[i][0],interactionGeometryFunctorNames[i][1]);
for(unsigned int i=0;i<interactionPhysicsFunctorNames.size();i++) interactionPhysicsDispatcher.add1DEntry(interactionPhysicsFunctorNames[i][0],interactionPhysicsFunctorNames[i][1]);
}
=== modified file 'pkg/common/RenderingEngine/OpenGLRenderingEngine.hpp'
--- pkg/common/RenderingEngine/OpenGLRenderingEngine.hpp 2010-05-03 12:17:44 +0000
+++ pkg/common/RenderingEngine/OpenGLRenderingEngine.hpp 2010-07-12 17:36:42 +0000
@@ -46,12 +46,20 @@
// updated after every call to render
shared_ptr<Scene> scene;
+ #if 0
DynLibDispatcher<InteractionGeometry, GlInteractionGeometryFunctor, void, TYPELIST_5(const shared_ptr<InteractionGeometry>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool)> interactionGeometryDispatcher;
DynLibDispatcher<InteractionPhysics, GlInteractionPhysicsFunctor, void, TYPELIST_5(const shared_ptr<InteractionPhysics>&, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool)> interactionPhysicsDispatcher;
DynLibDispatcher<State, GlStateFunctor, void, TYPELIST_1(const shared_ptr<State>&)> stateDispatcher;
DynLibDispatcher<Bound, GlBoundFunctor, void, TYPELIST_2(const shared_ptr<Bound>&, Scene*)> boundDispatcher;
DynLibDispatcher<Shape, GlShapeFunctor, void, TYPELIST_4(const shared_ptr<Shape>&, const shared_ptr<State>&,bool,const GLViewInfo&)> shapeDispatcher;
+ #endif
+ GlBoundDispatcher boundDispatcher;
+ GlInteractionGeometryDispatcher interactionGeometryDispatcher;
+ GlInteractionPhysicsDispatcher interactionPhysicsDispatcher;
+ GlShapeDispatcher shapeDispatcher;
+ GlStateDispatcher stateDispatcher;
+
vector<vector<string> >
stateFunctorNames,
=== modified file 'pkg/dem/Engine/GlobalEngine/CohesiveFrictionalPM.hpp'
--- pkg/dem/Engine/GlobalEngine/CohesiveFrictionalPM.hpp 2010-06-02 06:52:37 +0000
+++ pkg/dem/Engine/GlobalEngine/CohesiveFrictionalPM.hpp 2010-07-12 17:36:42 +0000
@@ -27,9 +27,11 @@
/** This class holds information associated with each body state*/
class CFpmState: public State {
- YADE_CLASS_BASE_DOC_ATTRS(CFpmState,State,"CFpm state information about each body.\n\nNone of that is used for computation (at least not now), only for post-processing.",
- ((int,numBrokenCohesive,0,"Number of broken cohesive links. [-]"))
+ YADE_CLASS_BASE_DOC_ATTRS_CTOR(CFpmState,State,"CFpm state information about each body.\n\nNone of that is used for computation (at least not now), only for post-processing.",
+ ((int,numBrokenCohesive,0,"Number of broken cohesive links. [-]")),
+ createIndex();
);
+ REGISTER_CLASS_INDEX(CFpmState,State);
};
REGISTER_SERIALIZABLE(CFpmState);
=== modified file 'pkg/dem/meta/ConcretePM.hpp'
--- pkg/dem/meta/ConcretePM.hpp 2010-07-12 09:11:16 +0000
+++ pkg/dem/meta/ConcretePM.hpp 2010-07-12 17:36:42 +0000
@@ -59,7 +59,7 @@
None of that is used for computation (at least not now), only for post-processing.
*/
class CpmState: public State {
- YADE_CLASS_BASE_DOC_ATTRS(CpmState,State,"State information about body use by :ref:`cpm-model`.\n\nNone of that is used for computation (at least not now), only for post-processing.",
+ YADE_CLASS_BASE_DOC_ATTRS_CTOR(CpmState,State,"State information about body use by :ref:`cpm-model`.\n\nNone of that is used for computation (at least not now), only for post-processing.",
((Real,epsVolumetric,0,"Volumetric strain around this body (unused for now)"))
((int,numBrokenCohesive,0,"Number of (cohesive) contacts that damaged completely"))
((int,numContacts,0,"Number of contacts with this body"))
@@ -67,8 +67,10 @@
((Real,epsPlBroken,0,"Plastic strain on contacts already deleted (bogus values)"))
((Real,normEpsPl,0,"Sum of plastic strains normalized by number of contacts (bogus values)"))
((Vector3r,sigma,Vector3r::Zero(),"Normal stresses on the particle"))
- ((Vector3r,tau,Vector3r::Zero(),"Shear stresses on the particle."))
+ ((Vector3r,tau,Vector3r::Zero(),"Shear stresses on the particle.")),
+ /*ctor*/ createIndex();
);
+ REGISTER_CLASS_INDEX(CpmState,State);
};
REGISTER_SERIALIZABLE(CpmState);
=== modified file 'py/yadeWrapper/customConverters.cpp'
--- py/yadeWrapper/customConverters.cpp 2010-06-07 17:09:08 +0000
+++ py/yadeWrapper/customConverters.cpp 2010-07-12 17:36:42 +0000
@@ -34,6 +34,9 @@
#include<yade/pkg-common/InteractionPhysicsFunctor.hpp>
#include<yade/pkg-common/LawFunctor.hpp>
#include<yade/pkg-common/Callbacks.hpp>
+#ifdef YADE_OPENGL
+ #include<yade/pkg-common/GLDrawFunctors.hpp>
+#endif
@@ -139,6 +142,13 @@
VECTOR_SEQ_CONV(shared_ptr<LawFunctor>);
VECTOR_SEQ_CONV(shared_ptr<IntrCallback>);
VECTOR_SEQ_CONV(shared_ptr<BodyCallback>);
+ #ifdef YADE_OPENGL
+ VECTOR_SEQ_CONV(shared_ptr<GlBoundFunctor>);
+ VECTOR_SEQ_CONV(shared_ptr<GlStateFunctor>);
+ VECTOR_SEQ_CONV(shared_ptr<GlShapeFunctor>);
+ VECTOR_SEQ_CONV(shared_ptr<GlInteractionGeometryFunctor>);
+ VECTOR_SEQ_CONV(shared_ptr<GlInteractionPhysicsFunctor>);
+ #endif
#undef VECTOR_SEQ_CONV
import_array();
=== modified file 'scripts/test/dispatcher-torture.py'
--- scripts/test/dispatcher-torture.py 2010-07-12 13:20:02 +0000
+++ scripts/test/dispatcher-torture.py 2010-07-12 17:36:42 +0000
@@ -10,35 +10,57 @@
"""
-dispatches={'Law':('InteractionGeometry','InteractionPhysics'),
-'InteractionGeometry':('Shape','Shape'),
-'InteractionPhysics':('Material','Material'),
-'Bound':('Shape','Bound')
-}
+import collections
+Dispatch=collections.namedtuple('Dispatch',['basename','types'])
+
+dispatches=[
+ Dispatch('Law',('InteractionGeometry','InteractionPhysics')),
+ Dispatch('InteractionGeometry',('Shape','Shape')),
+ Dispatch('InteractionPhysics',('Material','Material')),
+ Dispatch('Bound',('Shape','Bound')),
+ Dispatch('GlBound',('Bound',)),
+ Dispatch('GlInteractionGeometry',('InteractionGeometry',)),
+ Dispatch('GlInteractionPhysics',('InteractionPhysics',)),
+ Dispatch('GlShape',('Shape',)),
+ #Dispatch('GlState',('State',)) # broken for now
+]
sys.path.append('.')
import HTML
outStr=''
-for D in dispatches.keys():
- functors=yade.system.childClasses(D+'Functor')
+for D in dispatches:
+ functors=yade.system.childClasses(D.basename+'Functor')
# create dispatcher with all available functors
- dispatcher=eval(D+'Dispatcher([%s])'%(','.join(['%s()'%f for f in functors])))
- if len(dispatches[D])!=2: raise NotImplementedError("Only 2d dispatchers implemented now.")
- # lists of types the dispatcher accepts
- allDim0=list(yade.system.childClasses(dispatches[D][0]))
- allDim1=list(yade.system.childClasses(dispatches[D][1]))
- table=HTML.Table(header_row=['']+allDim1)
- for d0 in allDim0:
- row=[d0]
- for d1 in allDim1:
- dd0,dd1=eval(d0+'()'),eval(d1+'()')
+ dispatcher=eval(D.basename+'Dispatcher([%s])'%(','.join(['%s()'%f for f in functors])))
+ if len(D.types)==1:
+ allDim0=list(yade.system.childClasses(D.types[0]))
+ table=HTML.Table(header_row=allDim0)
+ row=[]
+ for d0 in allDim0:
+ dd0=eval(d0+'()')
try:
- f=dispatcher.dispFunctor(dd0,dd1)
+ f=dispatcher.dispFunctor(dd0)
row.append(f.name if f else '-')
- except RuntimeError: # ambiguous
- row.append('<b>ambiguous<b>')
+ except RuntimeError as strerror:
+ row.append('<b>ambiguous (%s)</b>'%(strerror))
table.rows.append(row)
- outStr+='\n<h1>%sDispatcher</h1>'%D
+ elif len(D.types)==2:
+ # lists of types the dispatcher accepts
+ allDim0=list(yade.system.childClasses(D.types[0]))
+ allDim1=list(yade.system.childClasses(D.types[1]))
+ table=HTML.Table(header_row=['']+allDim1)
+ for d0 in allDim0:
+ row=['<b>'+d0+'</b>']
+ for d1 in allDim1:
+ dd0,dd1=eval(d0+'()'),eval(d1+'()')
+ try:
+ f=dispatcher.dispFunctor(dd0,dd1)
+ row.append(f.name if f else '-')
+ except RuntimeError: # ambiguous
+ row.append('<b>ambiguous</b>')
+ table.rows.append(row)
+ else: raise ValueError("Dispatcher must be 1D or 2D, not %dD"%len(D.types))
+ outStr+='\n<h1>%sDispatcher</h1>'%D.basename
outStr+=str(table)
print outStr
quit()