← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 4046: Add YADE_PTR_DYN_CAST to define dynamic_cast.

 

------------------------------------------------------------
revno: 4046
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Tue 2014-07-01 20:14:18 +0200
message:
  Add YADE_PTR_DYN_CAST to define dynamic_cast.
modified:
  CMakeLists.txt
  core/Dispatcher.hpp
  core/Functor.hpp
  core/Omega.cpp
  core/Scene.cpp
  pkg/common/Collider.cpp
  pkg/common/InsertionSortCollider.cpp
  pkg/common/ZECollider.cpp
  pkg/dem/ConcretePM.cpp
  pkg/dem/DomainLimiter.cpp
  pkg/dem/FacetTopologyAnalyzer.cpp
  pkg/dem/FlatGridCollider.cpp
  pkg/dem/GeneralIntegratorInsertionSortCollider.cpp
  pkg/dem/Polyhedra.cpp
  pkg/dem/Polyhedra_splitter.cpp
  pkg/dem/Shop_01.cpp
  pkg/dem/Shop_02.cpp
  pkg/dem/SpherePack.cpp
  pkg/dem/SpheresFactory.cpp
  pkg/dem/Tetra.cpp
  py/_polyhedra_utils.cpp
  py/_utils.cpp
  py/wrapper/yadeWrapper.cpp


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2014-06-25 18:18:39 +0000
+++ CMakeLists.txt	2014-07-01 18:14:18 +0000
@@ -62,7 +62,7 @@
 ENDIF()
 
 #===========================================================
-ADD_DEFINITIONS(" -DYADE_PTR_CAST=boost::static_pointer_cast -DYADE_CAST=static_cast ")
+ADD_DEFINITIONS(" -DYADE_PTR_CAST=boost::static_pointer_cast -DYADE_CAST=static_cast -DYADE_PTR_DYN_CAST=boost::dynamic_pointer_cast ")
 IF (CMAKE_CXX_FLAGS)
   #If flags are set, add only neccessary flags
   IF (DEBUG)

=== modified file 'core/Dispatcher.hpp'
--- core/Dispatcher.hpp	2014-05-23 13:05:19 +0000
+++ core/Dispatcher.hpp	2014-07-01 18:14:18 +0000
@@ -40,7 +40,7 @@
 #define _YADE_DIM_DISPATCHER_FUNCTOR_DOC_ATTRS_CTOR_PY(Dim,DispatcherT,FunctorT,doc,attrs,ctor,py) \
 	typedef FunctorT FunctorType; \
 	void updateScenePtr(){ FOREACH(shared_ptr<FunctorT> f, functors){ f->scene=scene; }} \
-	void postLoad(DispatcherT&){ clearMatrix(); FOREACH(shared_ptr<FunctorT> f, functors) add(boost::static_pointer_cast<FunctorT>(f)); } \
+	void postLoad(DispatcherT&){ clearMatrix(); FOREACH(shared_ptr<FunctorT> f, functors) add(YADE_PTR_CAST<FunctorT>(f)); } \
 	virtual void add(FunctorT* f){ add(shared_ptr<FunctorT>(f)); } \
 	virtual void add(shared_ptr<FunctorT> f){ bool dupe=false; string fn=f->getClassName(); FOREACH(const shared_ptr<FunctorT>& f, functors) { if(fn==f->getClassName()) dupe=true; } if(!dupe) functors.push_back(f); addFunctor(f); } \
 	BOOST_PP_CAT(_YADE_DISPATCHER,BOOST_PP_CAT(Dim,D_FUNCTOR_ADD))(FunctorT,f) \
@@ -71,7 +71,7 @@
 	FOREACH(classItemType clss, Omega::instance().getDynlibsDescriptor()){
 		if(Omega::instance().isInheritingFrom_recursive(clss.first,topName) || clss.first==topName){
 			// create instance, to ask for index
-			shared_ptr<topIndexable> inst=boost::dynamic_pointer_cast<topIndexable>(ClassFactory::instance().createShared(clss.first));
+			shared_ptr<topIndexable> inst=YADE_PTR_DYN_CAST<topIndexable>(ClassFactory::instance().createShared(clss.first));
 			assert(inst);
 			if(inst->getClassIndex()<0 && inst->getClassName()!=top->getClassName()){
 				throw logic_error("Class "+inst->getClassName()+" didn't use REGISTER_CLASS_INDEX("+inst->getClassName()+","+top->getClassName()+") and/or forgot to call createIndex() in the ctor. [[ Please fix that! ]]");
@@ -107,7 +107,7 @@
 template<typename DispatcherT>
 std::vector<shared_ptr<typename DispatcherT::functorType> > Dispatcher_functors_get(shared_ptr<DispatcherT> self){
 	std::vector<shared_ptr<typename DispatcherT::functorType> > ret;
-	FOREACH(const shared_ptr<Functor>& functor, self->functors){ shared_ptr<typename DispatcherT::functorType> functorRightType(boost::dynamic_pointer_cast<typename DispatcherT::functorType>(functor)); if(!functorRightType) throw logic_error("Internal error: Dispatcher of type "+self->getClassName()+" did not contain Functor of the required type "+typeid(typename DispatcherT::functorType).name()+"?"); ret.push_back(functorRightType); }
+	FOREACH(const shared_ptr<Functor>& functor, self->functors){ shared_ptr<typename DispatcherT::functorType> functorRightType(YADE_PTR_DYN_CAST<typename DispatcherT::functorType>(functor)); if(!functorRightType) throw logic_error("Internal error: Dispatcher of type "+self->getClassName()+" did not contain Functor of the required type "+typeid(typename DispatcherT::functorType).name()+"?"); ret.push_back(functorRightType); }
 	return ret;
 }
 

=== modified file 'core/Functor.hpp'
--- core/Functor.hpp	2014-05-23 13:05:19 +0000
+++ core/Functor.hpp	2014-07-01 18:14:18 +0000
@@ -50,7 +50,7 @@
 {
 	public:
 		typedef _DispatchType1 DispatchType1; typedef _ReturnType ReturnType; typedef _ArgumentTypes ArgumentTypes; 
-		#define FUNCTOR1D(type1) public: std::string get1DFunctorType1(void){return string(#type1);} int checkArgTypes(const shared_ptr<DispatchType1>& arg1){ return (bool)boost::dynamic_pointer_cast<type1>(arg1)?1:0; }
+		#define FUNCTOR1D(type1) public: std::string get1DFunctorType1(void){return string(#type1);} int checkArgTypes(const shared_ptr<DispatchType1>& arg1){ return (bool)YADE_PTR_DYN_CAST<type1>(arg1)?1:0; }
 		virtual std::string get1DFunctorType1(void){throw runtime_error("Class "+this->getClassName()+" did not use FUNCTOR1D to declare its argument type?"); }
 		virtual vector<string> getFunctorTypes(void){vector<string> ret; ret.push_back(get1DFunctorType1()); return ret;};
 		// check that the object can be correctly cast to the derived class handled by the functor (will be used if ever utils.createInteraction can be called with list of functors only)
@@ -72,7 +72,7 @@
 {
 	public:
 		typedef _DispatchType1 DispatchType1; typedef _DispatchType2 DispatchType2; typedef _ReturnType ReturnType; typedef _ArgumentTypes ArgumentTypes; 
-		#define FUNCTOR2D(type1,type2) public: std::string get2DFunctorType1(void){return string(#type1);}; std::string get2DFunctorType2(void){return string(#type2);}; int checkArgTypes(const shared_ptr<DispatchType1>& arg1, const shared_ptr<DispatchType2>& arg2){ if(boost::dynamic_pointer_cast<type1>(arg1)&&boost::dynamic_pointer_cast<type2>(arg2)) return 1; if(boost::dynamic_pointer_cast<type1>(arg2)&&boost::dynamic_pointer_cast<type2>(arg1)) return -1; return 0; }
+		#define FUNCTOR2D(type1,type2) public: std::string get2DFunctorType1(void){return string(#type1);}; std::string get2DFunctorType2(void){return string(#type2);}; int checkArgTypes(const shared_ptr<DispatchType1>& arg1, const shared_ptr<DispatchType2>& arg2){ if(YADE_PTR_DYN_CAST<type1>(arg1)&&YADE_PTR_DYN_CAST<type2>(arg2)) return 1; if(YADE_PTR_DYN_CAST<type1>(arg2)&&YADE_PTR_DYN_CAST<type2>(arg1)) return -1; return 0; }
 		virtual std::string get2DFunctorType1(void){throw logic_error("Class "+this->getClassName()+" did not use FUNCTOR2D to declare its argument types?");}
 		virtual std::string get2DFunctorType2(void){throw logic_error("Class "+this->getClassName()+" did not use FUNCTOR2D to declare its argument types?");}
 		virtual vector<string> getFunctorTypes(){vector<string> ret; ret.push_back(get2DFunctorType1()); ret.push_back(get2DFunctorType2()); return ret;};

=== modified file 'core/Omega.cpp'
--- core/Omega.cpp	2014-05-23 13:05:19 +0000
+++ core/Omega.cpp	2014-07-01 18:14:18 +0000
@@ -145,9 +145,9 @@
 		try {
 			LOG_DEBUG("Factoring plugin "<<name);
 			f = ClassFactory::instance().createShared(name);
-			dynlibs[name].isIndexable    = boost::dynamic_pointer_cast<Indexable>(f);
-			dynlibs[name].isFactorable   = boost::dynamic_pointer_cast<Factorable>(f);
-			dynlibs[name].isSerializable = boost::dynamic_pointer_cast<Serializable>(f);
+			dynlibs[name].isIndexable    = YADE_PTR_DYN_CAST<Indexable>(f);
+			dynlibs[name].isFactorable   = YADE_PTR_DYN_CAST<Factorable>(f);
+			dynlibs[name].isSerializable = YADE_PTR_DYN_CAST<Serializable>(f);
 			for(int i=0;i<f->getBaseClassNumber();i++){
 				dynlibs[name].baseClasses.insert(f->getBaseClassName(i));
 			}

=== modified file 'core/Scene.cpp'
--- core/Scene.cpp	2014-05-23 13:05:19 +0000
+++ core/Scene.cpp	2014-07-01 18:14:18 +0000
@@ -194,8 +194,8 @@
 		if(!b) continue;
 		if(b->bound){
 			for(int i=0; i<3; i++){
-				if(!isinf(b->bound->max[i])) mx[i]=max(mx[i],b->bound->max[i]);
-				if(!isinf(b->bound->min[i])) mn[i]=min(mn[i],b->bound->min[i]);
+				if(!std::isinf(b->bound->max[i])) mx[i]=max(mx[i],b->bound->max[i]);
+				if(!std::isinf(b->bound->min[i])) mn[i]=min(mn[i],b->bound->min[i]);
 			}
 		} else {
 	 		mx=mx.cwiseMax(b->state->pos);

=== modified file 'pkg/common/Collider.cpp'
--- pkg/common/Collider.cpp	2014-06-05 13:19:44 +0000
+++ pkg/common/Collider.cpp	2014-07-01 18:14:18 +0000
@@ -38,7 +38,7 @@
 void Collider::findBoundDispatcherInEnginesIfNoFunctorsAndWarn(){
 	if(boundDispatcher->functors.size()>0) return;
 	shared_ptr<BoundDispatcher> bd;
-	FOREACH(shared_ptr<Engine>& e, scene->engines){ bd=boost::dynamic_pointer_cast<BoundDispatcher>(e); if(bd) break; }
+	FOREACH(shared_ptr<Engine>& e, scene->engines){ bd=YADE_PTR_DYN_CAST<BoundDispatcher>(e); if(bd) break; }
 	if(!bd) return;
 	LOG_WARN("Collider.boundDispatcher had no functors defined, while there was a BoundDispatcher found in O.engines. Since version 0.60 (r2396), Collider has boundDispatcher integrated in itself; separate BoundDispatcher should not be used anymore. For now, I will fix it for you, but change your script! Where it reads e.g.\n\n\tO.engines=[...,\n\t\tBoundDispatcher([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),\n\t\t"<<getClassName()<<"(),\n\t\t...\n\t]\n\nit should become\n\n\tO.engines=[...,\n\t\t"<<getClassName()<<"([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),\n\t\t...\n\t]\n\ninstead.")
 	boundDispatcher=bd;

=== modified file 'pkg/common/InsertionSortCollider.cpp'
--- pkg/common/InsertionSortCollider.cpp	2014-05-23 13:05:19 +0000
+++ pkg/common/InsertionSortCollider.cpp	2014-07-01 18:14:18 +0000
@@ -274,7 +274,7 @@
 		if(verletDist>0){
 			// get NewtonIntegrator, to ask for the maximum velocity value
 			if(!newton){
-				FOREACH(shared_ptr<Engine>& e, scene->engines){ newton=boost::dynamic_pointer_cast<NewtonIntegrator>(e); if(newton) break; }
+				FOREACH(shared_ptr<Engine>& e, scene->engines){ newton=YADE_PTR_DYN_CAST<NewtonIntegrator>(e); if(newton) break; }
 				if(!newton){ throw runtime_error("InsertionSortCollider.verletDist>0, but unable to locate NewtonIntegrator within O.engines."); }
 			}
 		}

=== modified file 'pkg/common/ZECollider.cpp'
--- pkg/common/ZECollider.cpp	2014-05-23 13:05:19 +0000
+++ pkg/common/ZECollider.cpp	2014-07-01 18:14:18 +0000
@@ -92,7 +92,7 @@
 		if(verletDist>0){
 			// get NewtonIntegrator, to ask for the maximum velocity value
 			if(!newton){
-				FOREACH(shared_ptr<Engine>& e, scene->engines){ newton=boost::dynamic_pointer_cast<NewtonIntegrator>(e); if(newton) break; }
+				FOREACH(shared_ptr<Engine>& e, scene->engines){ newton=YADE_PTR_DYN_CAST<NewtonIntegrator>(e); if(newton) break; }
 				if(!newton){ throw runtime_error("ZECollider.verletDist>0, but unable to locate NewtonIntegrator within O.engines."); }
 			}
 		}

=== modified file 'pkg/dem/ConcretePM.cpp'
--- pkg/dem/ConcretePM.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/ConcretePM.cpp	2014-07-01 18:14:18 +0000
@@ -564,7 +564,7 @@
 	FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
 		if (!I) continue;
 		if (!I->isReal()) continue;
-		shared_ptr<CpmPhys> phys = boost::dynamic_pointer_cast<CpmPhys>(I->phys);
+		shared_ptr<CpmPhys> phys = YADE_PTR_DYN_CAST<CpmPhys>(I->phys);
 		if (!phys) continue;
 		const Body::id_t id1 = I->getId1(), id2 = I->getId2();
 		GenericSpheresContact* geom = YADE_CAST<GenericSpheresContact*>(I->geom.get());

=== modified file 'pkg/dem/DomainLimiter.cpp'
--- pkg/dem/DomainLimiter.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/DomainLimiter.cpp	2014-07-01 18:14:18 +0000
@@ -237,7 +237,7 @@
 	// scene object changed (after reload, for instance), for re-initialization
 	if(tester && tester->scene!=scene) tester=shared_ptr<LawTester>();
 
-	if(!tester){ FOREACH(shared_ptr<Engine> e, scene->engines){ tester=boost::dynamic_pointer_cast<LawTester>(e); if(tester) break; } }
+	if(!tester){ FOREACH(shared_ptr<Engine> e, scene->engines){ tester=YADE_PTR_DYN_CAST<LawTester>(e); if(tester) break; } }
 	if(!tester){ LOG_ERROR("No LawTester in O.engines, killing myself."); dead=true; return; }
 
 	//if(tester->renderLength<=0) return;

=== modified file 'pkg/dem/FacetTopologyAnalyzer.cpp'
--- pkg/dem/FacetTopologyAnalyzer.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/FacetTopologyAnalyzer.cpp	2014-07-01 18:14:18 +0000
@@ -17,7 +17,7 @@
 	// minimum facet edge length (tolerance scale)
 	Real minSqLen=numeric_limits<Real>::infinity();
 	FOREACH(const shared_ptr<Body>& b, *scene->bodies){
-		shared_ptr<Facet> f=boost::dynamic_pointer_cast<Facet>(b->shape);
+		shared_ptr<Facet> f=YADE_PTR_DYN_CAST<Facet>(b->shape);
 		if(!f) continue;
 		const Vector3r& pos=b->state->pos;
 		for(size_t i=0; i<3; i++){

=== modified file 'pkg/dem/FlatGridCollider.cpp'
--- pkg/dem/FlatGridCollider.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/FlatGridCollider.cpp	2014-07-01 18:14:18 +0000
@@ -21,7 +21,7 @@
 
 void FlatGridCollider::action(){
 	if(!newton){
-		FOREACH(const shared_ptr<Engine>& e, scene->engines){ newton=boost::dynamic_pointer_cast<NewtonIntegrator>(e); if(newton) break; }
+		FOREACH(const shared_ptr<Engine>& e, scene->engines){ newton=YADE_PTR_DYN_CAST<NewtonIntegrator>(e); if(newton) break; }
 		if(!newton){ throw runtime_error("FlatGridCollider: Unable to find NewtonIntegrator in engines."); }
 	}
 	fastestBodyMaxDist=0;

=== modified file 'pkg/dem/GeneralIntegratorInsertionSortCollider.cpp'
--- pkg/dem/GeneralIntegratorInsertionSortCollider.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/GeneralIntegratorInsertionSortCollider.cpp	2014-07-01 18:14:18 +0000
@@ -111,7 +111,7 @@
 		if(verletDist>0){
 			// get the Integrator, to ask for the maximum velocity value
 			if(!integrator){
- 				FOREACH(shared_ptr<Engine>& e, scene->engines){ integrator=boost::dynamic_pointer_cast<Integrator>(e); if(integrator) break; }
+ 				FOREACH(shared_ptr<Engine>& e, scene->engines){ integrator=YADE_PTR_DYN_CAST<Integrator>(e); if(integrator) break; }
 				if(!integrator){ throw runtime_error("InsertionSortCollider.verletDist>0, but unable to locate any Integrator within O.engines."); }
 			}
 		}

=== modified file 'pkg/dem/Polyhedra.cpp'
--- pkg/dem/Polyhedra.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/Polyhedra.cpp	2014-07-01 18:14:18 +0000
@@ -416,7 +416,7 @@
 void PolyhedraVolumetricLaw::go(shared_ptr<IGeom>& ig, shared_ptr<IPhys>& ip, Interaction* I){
 
 		if (!I->geom) {return;} 
-		const shared_ptr<PolyhedraGeom>& contactGeom(boost::dynamic_pointer_cast<PolyhedraGeom>(I->geom));
+		const shared_ptr<PolyhedraGeom>& contactGeom(YADE_PTR_DYN_CAST<PolyhedraGeom>(I->geom));
 		if(!contactGeom) {return;} 
 		const Body::id_t idA=I->getId1(), idB=I->getId2();
 		const shared_ptr<Body>& A=Body::byId(idA), B=Body::byId(idB);

=== modified file 'pkg/dem/Polyhedra_splitter.cpp'
--- pkg/dem/Polyhedra_splitter.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/Polyhedra_splitter.cpp	2014-07-01 18:14:18 +0000
@@ -83,8 +83,8 @@
 
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
 		if(!b || !b->material || !b->shape) continue;
-		shared_ptr<Polyhedra> p=boost::dynamic_pointer_cast<Polyhedra>(b->shape);
-		shared_ptr<PolyhedraMat> m=boost::dynamic_pointer_cast<PolyhedraMat>(b->material);
+		shared_ptr<Polyhedra> p=YADE_PTR_DYN_CAST<Polyhedra>(b->shape);
+		shared_ptr<PolyhedraMat> m=YADE_PTR_DYN_CAST<PolyhedraMat>(b->material);
 	
 		if(p && m->IsSplitable){
 			//not real strees, to get real one, it has to be divided by body volume

=== modified file 'pkg/dem/Shop_01.cpp'
--- pkg/dem/Shop_01.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/Shop_01.cpp	2014-07-01 18:14:18 +0000
@@ -159,7 +159,7 @@
 	rb->forces.sync();
 	shared_ptr<NewtonIntegrator> newton;
 	Vector3r gravity = Vector3r::Zero();
-	FOREACH(shared_ptr<Engine>& e, rb->engines){ newton=boost::dynamic_pointer_cast<NewtonIntegrator>(e); if(newton) {gravity=newton->gravity; break;} }
+	FOREACH(shared_ptr<Engine>& e, rb->engines){ newton=YADE_PTR_DYN_CAST<NewtonIntegrator>(e); if(newton) {gravity=newton->gravity; break;} }
 	// get maximum force on a body and sum of all forces (for averaging)
 	Real sumF=0,maxF=0,currF; int nb=0;
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
@@ -293,7 +293,7 @@
 
 	FOREACH(shared_ptr<Body> b, *scene->bodies){
 		if (!b->isDynamic()) continue;
-		shared_ptr<Sphere>	intSph=boost::dynamic_pointer_cast<Sphere>(b->shape);
+		shared_ptr<Sphere>	intSph=YADE_PTR_DYN_CAST<Sphere>(b->shape);
 		if(!intSph) continue;
 		const Vector3r& pos=b->state->pos;
 		f<<pos[0]<<" "<<pos[1]<<" "<<pos[2]<<" "<<intSph->radius<<endl; // <<" "<<1<<" "<<1<<endl;
@@ -441,8 +441,8 @@
 	Real dt=std::numeric_limits<Real>::infinity();
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
 		if(!b || !b->material || !b->shape) continue;
-		shared_ptr<ElastMat> ebp=boost::dynamic_pointer_cast<ElastMat>(b->material);
-		shared_ptr<Sphere> s=boost::dynamic_pointer_cast<Sphere>(b->shape);
+		shared_ptr<ElastMat> ebp=YADE_PTR_DYN_CAST<ElastMat>(b->material);
+		shared_ptr<Sphere> s=YADE_PTR_DYN_CAST<Sphere>(b->shape);
 		if(!ebp || !s) continue;
 		Real density=b->state->mass/((4/3.)*Mathr::PI*pow(s->radius,3));
 		dt=min(dt,s->radius/sqrt(ebp->young/density));

=== modified file 'pkg/dem/Shop_02.cpp'
--- pkg/dem/Shop_02.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/Shop_02.cpp	2014-07-01 18:14:18 +0000
@@ -67,8 +67,8 @@
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
 		if(!b || !b->material || !b->shape) continue;
 		
-		shared_ptr<ElastMat> ebp=boost::dynamic_pointer_cast<ElastMat>(b->material);
-		shared_ptr<Sphere> s=boost::dynamic_pointer_cast<Sphere>(b->shape);
+		shared_ptr<ElastMat> ebp=YADE_PTR_DYN_CAST<ElastMat>(b->material);
+		shared_ptr<Sphere> s=YADE_PTR_DYN_CAST<Sphere>(b->shape);
 		if(!ebp || !s) continue;
 		
 		Real density=b->state->mass/((4/3.)*Mathr::PI*pow(s->radius,3));

=== modified file 'pkg/dem/SpherePack.cpp'
--- pkg/dem/SpherePack.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/SpherePack.cpp	2014-07-01 18:14:18 +0000
@@ -75,7 +75,7 @@
 	Scene* scene=Omega::instance().getScene().get();
 	FOREACH(const shared_ptr<Body>& b, *scene->bodies){
 		if(!b) continue;
-		shared_ptr<Sphere> intSph=boost::dynamic_pointer_cast<Sphere>(b->shape);
+		shared_ptr<Sphere> intSph=YADE_PTR_DYN_CAST<Sphere>(b->shape);
 		if(!intSph) continue;
 		pack.push_back(Sph(b->state->pos,intSph->radius,(b->isClumpMember()?b->clumpId:-1)));
 	}

=== modified file 'pkg/dem/SpheresFactory.cpp'
--- pkg/dem/SpheresFactory.cpp	2014-06-17 10:18:00 +0000
+++ pkg/dem/SpheresFactory.cpp	2014-07-01 18:14:18 +0000
@@ -24,7 +24,7 @@
 void SpheresFactory::action(){
 
 	if(!collider){
-		FOREACH(const shared_ptr<Engine>& e, scene->engines){ collider=boost::dynamic_pointer_cast<Collider>(e); if(collider) break; }
+		FOREACH(const shared_ptr<Engine>& e, scene->engines){ collider=YADE_PTR_DYN_CAST<Collider>(e); if(collider) break; }
 		if(!collider) throw runtime_error("SpheresFactory: No Collider instance found in engines (needed for collision detection).");
 	}
 	

=== modified file 'pkg/dem/Tetra.cpp'
--- pkg/dem/Tetra.cpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/Tetra.cpp	2014-07-01 18:14:18 +0000
@@ -956,14 +956,14 @@
 	FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
 		// normally, we would test isReal(), but TetraVolumetricLaw doesn't use phys at all
 		if (!I->geom) continue; // Ig2_Tetra_Tetra_TTetraGeom::go returned false for this interaction, skip it
-		const shared_ptr<TTetraGeom>& contactGeom(boost::dynamic_pointer_cast<TTetraGeom>(I->geom));
+		const shared_ptr<TTetraGeom>& contactGeom(YADE_PTR_DYN_CAST<TTetraGeom>(I->geom));
 		if(!contactGeom) continue;
 
 		const Body::id_t idA=I->getId1(), idB=I->getId2();
 		const shared_ptr<Body>& A=Body::byId(idA), B=Body::byId(idB);
 			
-		const shared_ptr<ElastMat>& physA(boost::dynamic_pointer_cast<ElastMat>(A->material));
-		const shared_ptr<ElastMat>& physB(boost::dynamic_pointer_cast<ElastMat>(B->material));
+		const shared_ptr<ElastMat>& physA(YADE_PTR_DYN_CAST<ElastMat>(A->material));
+		const shared_ptr<ElastMat>& physB(YADE_PTR_DYN_CAST<ElastMat>(B->material));
 		
 
 		/* Cross-section is volumetrically equivalent to the penetration configuration */
@@ -1143,7 +1143,7 @@
 Quaternionr TetrahedronWithLocalAxesPrincipal(shared_ptr<Body>& tetraBody){
 	//const shared_ptr<RigidBodyParameters>& rbp(YADE_PTR_CAST<RigidBodyParameters>(tetraBody->physicalParameters));
 	State* rbp=tetraBody->state.get();
-	const shared_ptr<Tetra>& tMold(boost::dynamic_pointer_cast<Tetra>(tetraBody->shape));
+	const shared_ptr<Tetra>& tMold(YADE_PTR_DYN_CAST<Tetra>(tetraBody->shape));
 
 	#define v0 tMold->v[0]
 	#define v1 tMold->v[1]

=== modified file 'py/_polyhedra_utils.cpp'
--- py/_polyhedra_utils.cpp	2014-05-23 13:05:19 +0000
+++ py/_polyhedra_utils.cpp	2014-07-01 18:14:18 +0000
@@ -87,18 +87,18 @@
 	Real dt=std::numeric_limits<Real>::infinity();
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
 		if(!b || !b->material || !b->shape) continue;
-		shared_ptr<Sphere> s=boost::dynamic_pointer_cast<Sphere>(b->shape);
-		shared_ptr<Polyhedra> p=boost::dynamic_pointer_cast<Polyhedra>(b->shape);
+		shared_ptr<Sphere> s=YADE_PTR_DYN_CAST<Sphere>(b->shape);
+		shared_ptr<Polyhedra> p=YADE_PTR_DYN_CAST<Polyhedra>(b->shape);
 		if(!s && !p) continue;
 		if(!p){
 			//spheres
-			shared_ptr<ElastMat> ebp=boost::dynamic_pointer_cast<ElastMat>(b->material);
+			shared_ptr<ElastMat> ebp=YADE_PTR_DYN_CAST<ElastMat>(b->material);
  			if(!ebp) continue;
 			Real density=b->state->mass/((4./3.)*Mathr::PI*pow(s->radius,3));
 			dt=min(dt,s->radius/sqrt(ebp->young/density));
 		}else{
 			//polyhedrons
-			shared_ptr<PolyhedraMat> ebp=boost::dynamic_pointer_cast<PolyhedraMat>(b->material);
+			shared_ptr<PolyhedraMat> ebp=YADE_PTR_DYN_CAST<PolyhedraMat>(b->material);
  			if(!ebp) continue;
 			Real density=b->state->mass/p->GetVolume();
 			//get equivalent radius and use same equation as for sphere
@@ -163,7 +163,7 @@
 	double total_volume = 0;
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
 		if(!b || !b->shape) continue;
-		shared_ptr<Polyhedra> p=boost::dynamic_pointer_cast<Polyhedra>(b->shape);
+		shared_ptr<Polyhedra> p=YADE_PTR_DYN_CAST<Polyhedra>(b->shape);
 		if(p){
 			sieve_volume.push_back(std::pair<double,double>(SieveSize(p),p->GetVolume()));
 			total_volume += p->GetVolume();
@@ -191,7 +191,7 @@
   	myfile.open ("sizes.dat");
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
 		if(!b || !b->shape) continue;
-		shared_ptr<Polyhedra> p=boost::dynamic_pointer_cast<Polyhedra>(b->shape);
+		shared_ptr<Polyhedra> p=YADE_PTR_DYN_CAST<Polyhedra>(b->shape);
 		if(p){
 			myfile << SizeOfPolyhedra(p) << endl; 
 		}

=== modified file 'py/_utils.cpp'
--- py/_utils.cpp	2014-05-23 13:05:19 +0000
+++ py/_utils.cpp	2014-07-01 18:14:18 +0000
@@ -28,7 +28,7 @@
 	Real inf=std::numeric_limits<Real>::infinity();
 	Vector3r minimum(inf,inf,inf),maximum(-inf,-inf,-inf);
 	FOREACH(const shared_ptr<Body>& b, *Omega::instance().getScene()->bodies){
-		shared_ptr<Sphere> s=boost::dynamic_pointer_cast<Sphere>(b->shape); if(!s) continue;
+		shared_ptr<Sphere> s=YADE_PTR_DYN_CAST<Sphere>(b->shape); if(!s) continue;
 		Vector3r rrr(s->radius,s->radius,s->radius);
 		minimum=minimum.cwiseMin(b->state->pos-(centers?Vector3r::Zero():rrr));
 		maximum=maximum.cwiseMax(b->state->pos+(centers?Vector3r::Zero():rrr));
@@ -42,7 +42,7 @@
 	Real minCoord=py::extract<double>(extrema[0][axis])(),maxCoord=py::extract<double>(extrema[1][axis])();
 	py::list minIds,maxIds;
 	FOREACH(const shared_ptr<Body>& b, *Omega::instance().getScene()->bodies){
-		shared_ptr<Sphere> s=boost::dynamic_pointer_cast<Sphere>(b->shape); if(!s) continue;
+		shared_ptr<Sphere> s=YADE_PTR_DYN_CAST<Sphere>(b->shape); if(!s) continue;
 		if(b->state->pos[axis]-s->radius*distFactor<=minCoord) minIds.append(b->getId());
 		if(b->state->pos[axis]+s->radius*distFactor>=maxCoord) maxIds.append(b->getId());
 	}
@@ -234,7 +234,7 @@
 		switch(mode){
 			case none: wire=false; break;
 			case all: wire=true; break;
-			case noSpheres: wire=!(bool)(boost::dynamic_pointer_cast<Sphere>(b->shape)); break;
+			case noSpheres: wire=!(bool)(YADE_PTR_DYN_CAST<Sphere>(b->shape)); break;
 			default: throw logic_error("No such case possible");
 		}
 		b->shape->wire=wire;

=== modified file 'py/wrapper/yadeWrapper.cpp'
--- py/wrapper/yadeWrapper.cpp	2014-05-23 13:05:19 +0000
+++ py/wrapper/yadeWrapper.cpp	2014-07-01 18:14:18 +0000
@@ -776,7 +776,7 @@
 	void interactionContainer_set(string clss){
 		Scene* rb=OMEGA.getScene().get();
 		if(rb->interactions->size()>0) throw std::runtime_error("Interaction container not empty, will not change its class.");
-		shared_ptr<InteractionContainer> ic=boost::dynamic_pointer_cast<InteractionContainer>(ClassFactory::instance().createShared(clss));
+		shared_ptr<InteractionContainer> ic=YADE_PTR_DYN_CAST<InteractionContainer>(ClassFactory::instance().createShared(clss));
 		rb->interactions=ic;
 	}
 	string interactionContainer_get(string clss){ return OMEGA.getScene()->interactions->getClassName(); }
@@ -784,7 +784,7 @@
 	void bodyContainer_set(string clss){
 		Scene* rb=OMEGA.getScene().get();
 		if(rb->bodies->size()>0) throw std::runtime_error("Body container not empty, will not change its class.");
-		shared_ptr<BodyContainer> bc=boost::dynamic_pointer_cast<BodyContainer>(ClassFactory::instance().createShared(clss));
+		shared_ptr<BodyContainer> bc=YADE_PTR_DYN_CAST<BodyContainer>(ClassFactory::instance().createShared(clss));
 		rb->bodies=bc;
 	}
 	string bodyContainer_get(string clss){ return OMEGA.getScene()->bodies->getClassName(); }