← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2194: 1. Some garbage removal

 

------------------------------------------------------------
revno: 2194
fixes bug(s): https://launchpad.net/bugs/573723
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-05-03 15:58:09 +0200
message:
  1. Some garbage removal
  2. Fix assertion in NewtonIntegrator
modified:
  SConstruct
  lib/base/Math.hpp
  lib/serialization/Archive.tpp
  pkg/common/RenderingEngine/Gl1_Box.cpp
  pkg/common/RenderingEngine/Gl1_Facet.cpp
  pkg/common/RenderingEngine/Gl1_Sphere.cpp
  pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp
  pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp
  py/yadeWrapper/yadeWrapper.cpp


--
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 'SConstruct'
--- SConstruct	2010-05-03 12:17:44 +0000
+++ SConstruct	2010-05-03 13:58:09 +0000
@@ -394,9 +394,8 @@
 		if not ok: featureNotOK('eigen',note="You might have to add eigen header directory (e.g. /usr/include/eigen2) to CPPPATH.")
 	if 'nowm3' in env['features'] and 'eigen' not in env['features']:
 		featureNotOK("You selected the 'nowm3' feature; you MUST also select the 'eigen' feature in such case.")
-	# different macros for different versions of eigen:
-	#  http://bitbucket.org/eigen/eigen/issue/96/eigen_dont_align-doesnt-exist-in-205-but-appears-in-web
-	if 'nowm3' in env['features']: env.Append(CPPDEFINES=['EIGEN_DONT_VECTORIZE','EIGEN_DONT_ALIGN','EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT'])
+	# moved to lib/base/Math.hpp instead
+	#if 'nowm3' in env['features']: env.Append(CPPDEFINES=['EIGEN_DONT_VECTORIZE','EIGEN_DONT_ALIGN','EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT'])
 
 	if env['useMiniWm3'] and not 'nowm3' in env['features']: env.Append(LIBS='miniWm3',CPPDEFINES=['MINIWM3'])
 

=== modified file 'lib/base/Math.hpp'
--- lib/base/Math.hpp	2010-05-03 12:17:44 +0000
+++ lib/base/Math.hpp	2010-05-03 13:58:09 +0000
@@ -21,14 +21,19 @@
 	#define EIGEN_DONT_ALIGN
 	#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
 	#include<Eigen/Core>
-	USING_PART_OF_NAMESPACE_EIGEN
+	#include<Eigen/Geometry>
+	// USING_PART_OF_NAMESPACE_EIGEN
 	//using namespace eigen; // for eigen3
+	// 
+	//template<typename Scalar> using Vector2=Eigen::Matrix<Scalar,2,1>;
+	//template<typename Scalar> using Vector3=Eigen::Matrix<Scalar,3,1>;
+	//template<typename Scalar> using Matrix3=Eigen::Matrix<Scalar,3,3>;
 	typedef Vector2<int> Vector2i;
 	typedef Vector2<Real> Vector2r;
 	typedef Vector3<int> Vector3i;
 	typedef Vector3<Real> Vector3r;
 	typedef Matrix3<Real> Matrix3r;
-	typedef Quaternion<Real> Quaternionr;
+	typedef Eigen::Quaternion<Real> Quaternionr;
 
 	// io
 	template<class ScalarType> std::ostream & operator<<(std::ostream &os, const Vector2<ScalarType>& v){ os << v.x()<<" "<<v.y(); return os; };
@@ -43,6 +48,29 @@
 	template<typename ScalarType> AngleAxis<ScalarType> angleAxisFromQuat(const Quaternion<ScalarType>& q){ return AngleAxis<ScalarType>(q); }
 	// http://eigen.tuxfamily.org/dox/TutorialGeometry.html
 	template<typename ScalarType> Matrix3<ScalarType> matrixFromEulerAnglesXYZ(ScalarType x, ScalarType y, ScalarType z){ Matrix3<ScalarType> ret=AngleAxis<ScalarType>(x,Vector3<ScalarType>::UnitX())*AngleAxis<ScalarType>(y,Vector3<ScalarType>::UnitY())*AngleAxis<ScalarType>(z,Vector3<ScalarType>::UnitZ()); return ret; }
+	/* replace all those by standard math functions
+		this is a non-templated version, to avoid compilation because of static constants;
+	*/
+	namespace Mathr{
+		const Real PI(4.*atan(1.));
+		const Real HALF_PI(.2*PI);
+		const Real TWO_PI(2*PI);
+		const Real MAX_REAL(DBL_MAX);
+		const Real DEG_TO_RAD(PI/180.);
+		const Real RAD_TO_DEG(180./PI);
+		const Real EPSILON(DBL_EPSILON);
+		Real Sign(Real f){ if(f<0) return -1; if(f>0) return 1; return 0; }
+		Real Sqrt(Real f){ return sqrt(f); }
+		Real Log(Real f){ return log(f); }
+		Real Exp(Real f){ return exp(f); }
+		Real ATan(Real f){ return atan(f); }
+		Real Tan(Real f){ return tan(f); }
+		Real Pow(Real base,exponent){ return pow(base,exponent); }
+
+		Real UnitRandom(){ return ((double)rand()/((double)(RAND_MAX))); }
+		Real SymmetricRandom(){ return 2.*(((double)rand())/((double)(RAND_MAX)))-1.; }
+		Real FastInvCos0(Real f){ Real fRoot = sqrt(((Real)1.0)-fValue); Real fResult = -(Real)0.0187293; fResult *= fValue; fResult += (Real)0.0742610; fResult *= fValue; fResult -= (Real)0.2121144; fResult *= fValue; fResult += (Real)1.5707288; fResult *= fRoot; return fResult; }
+	};
 #else
 	#include<Wm3Vector2.h>
 	#include<Wm3Vector3.h>
@@ -96,6 +124,7 @@
 template<typename ScalarType> Vector3<ScalarType> diagDiv(const Vector3<ScalarType>& a, const Vector3<ScalarType>& b){return Vector3<ScalarType>(a.x()/b.x(),a.y()/b.y(),a.z()/b.z());}
 
 
+
 /*
  * Extra yade math functions and classes
  */
@@ -164,9 +193,9 @@
 // fast serialization (no version infor and no tracking) for basic math types
 // http://www.boost.org/doc/libs/1_42_0/libs/serialization/doc/traits.html#bitwise
 BOOST_IS_BITWISE_SERIALIZABLE(Vector2r);
-BOOST_IS_BITWISE_SERIALIZABLE(Vector2<int>);
+BOOST_IS_BITWISE_SERIALIZABLE(Vector2i);
 BOOST_IS_BITWISE_SERIALIZABLE(Vector3r);
-BOOST_IS_BITWISE_SERIALIZABLE(Vector3<int>);
+BOOST_IS_BITWISE_SERIALIZABLE(Vector3i);
 BOOST_IS_BITWISE_SERIALIZABLE(Quaternionr);
 BOOST_IS_BITWISE_SERIALIZABLE(Se3r);
 BOOST_IS_BITWISE_SERIALIZABLE(Matrix3r);

=== modified file 'lib/serialization/Archive.tpp'
--- lib/serialization/Archive.tpp	2010-02-14 19:36:17 +0000
+++ lib/serialization/Archive.tpp	2010-05-03 13:58:09 +0000
@@ -40,34 +40,10 @@
 			typeid(Type)==typeid(Vector2r)		||
 			typeid(Type)==typeid(Vector2i)		||
 			typeid(Type)==typeid(Vector3r)		||
-			typeid(Type)==typeid(Vector3f)		||
 			typeid(Type)==typeid(Vector3i)		||
 			typeid(Type)==typeid(Matrix3r)		||
 			typeid(Type)==typeid(Quaternionr)	||
 			typeid(Type)==typeid(Se3r)
-#if 0
-			typeid(Type)==typeid(Vector2<signed int>)	  		||
-			typeid(Type)==typeid(Vector2<unsigned int>)		||
-			typeid(Type)==typeid(Vector2<signed long>)		||
-			typeid(Type)==typeid(Vector2<unsigned long>)		||
-			typeid(Type)==typeid(Vector3<long double>)		||
-			typeid(Type)==typeid(Vector3<signed int>)			||
-			typeid(Type)==typeid(Vector3<unsigned int>)		||
-			typeid(Type)==typeid(Vector3<signed long>)		||
-			typeid(Type)==typeid(Vector3<unsigned long>)		||
-			typeid(Type)==typeid(Vector3f)		||
-			typeid(Type)==typeid(Vector3d)		||
-			typeid(Type)==typeid(Vector3i)		||
-			typeid(Type)==typeid(Matrix3f)		||
-			typeid(Type)==typeid(Matrix3d)		||
-			typeid(Type)==typeid(Matrix3<long double>)		||
-			typeid(Type)==typeid(Quaternionf)	||
-			typeid(Type)==typeid(Quaterniond)	||
-			typeid(Type)==typeid(Quaternion<long double>)	||
-			typeid(Type)==typeid(Se3f)		||
-			typeid(Type)==typeid(Se3d) ||
-			typeid(Type)==typeid(Se3<long double>)
-#endif
 		);
 }
 

=== modified file 'pkg/common/RenderingEngine/Gl1_Box.cpp'
--- pkg/common/RenderingEngine/Gl1_Box.cpp	2010-03-27 22:18:10 +0000
+++ pkg/common/RenderingEngine/Gl1_Box.cpp	2010-05-03 13:58:09 +0000
@@ -12,8 +12,6 @@
 
 void Gl1_Box::go(const shared_ptr<Shape>& cg, const shared_ptr<State>&,bool wire,const GLViewInfo&)
 {
-	// FIXME : check that : one of those 2 lines are useless
-  	glMaterialv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Vector3f(cg->color[0],cg->color[1],cg->color[2]));
 	glColor3v(cg->color);
 	
 	Vector3r &extents = (static_cast<Box*>(cg.get()))->extents;

=== modified file 'pkg/common/RenderingEngine/Gl1_Facet.cpp'
--- pkg/common/RenderingEngine/Gl1_Facet.cpp	2010-05-03 12:17:44 +0000
+++ pkg/common/RenderingEngine/Gl1_Facet.cpp	2010-05-03 13:58:09 +0000
@@ -43,8 +43,6 @@
 		glEnd();
 	} else {
 		glDisable(GL_CULL_FACE); 
-  		glMaterialv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,cm->color); glColor3v(cm->color); // one of those necessary as well
-		glEnable(GL_LIGHTING); // important
 		Vector3r normal=(facet->vertices[1]-facet->vertices[0]).cross(facet->vertices[2]-facet->vertices[1]); normal.normalize();
 		glBegin(GL_TRIANGLES);
 			glNormal3v(normal); // this makes every triangle different WRT the light direction; important!

=== modified file 'pkg/common/RenderingEngine/Gl1_Sphere.cpp'
--- pkg/common/RenderingEngine/Gl1_Sphere.cpp	2010-05-03 12:17:44 +0000
+++ pkg/common/RenderingEngine/Gl1_Sphere.cpp	2010-05-03 13:58:09 +0000
@@ -28,17 +28,7 @@
 		if (wire || wire2) glutWireSphere(r,glutSlices,glutStacks);
 		else {
  			if(stripes) { glScalef(r,r,r); drawSphere();}
-			else {
-// 				if(glSphereList<0) {
-// 					glSphereList = glGenLists(1);
-// 					glNewList(glSphereList,GL_COMPILE);
-// 					//glShadeModel(GL_SMOOTH); glDisable(GL_LIGHTING);
-// 					glutSolidSphere(1,glutSlices,glutStacks);
-// 					glEndList();}
-// 				
-// 				glScalef(r,r,r);
-// 				glCallList(glSphereList);}
-				glutSolidSphere(r,glutSlices,glutStacks);}
+			else { glutSolidSphere(r,glutSlices,glutStacks);}
 		}
 	if(glutNormalize) glPopAttrib();
 	return;
@@ -67,24 +57,21 @@
 		Real angle = atan(v[2]/v[0])/v.norm();
 		GLfloat matAmbient[4];
 		if (angle>-Mathr::PI/6.0 && angle<=Mathr::PI/6.0){
-			matAmbient[0] = 1.0;
-			matAmbient[1] = 1.0;
-			matAmbient[2] = 1.0;
-			matAmbient[3] = 1.0;
+			matAmbient[0] = .3;
+			matAmbient[1] = .3;
+			matAmbient[2] = .3;
+			matAmbient[3] = 1;
 		}else{
 			matAmbient[0] = 0.0;
 			matAmbient[1] = 0.0;
 			matAmbient[2] = 0.0;
-			matAmbient[3] = 1.0;
+			matAmbient[3] = 0;
 		}
 		glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,matAmbient);
 		glBegin(GL_TRIANGLES);
-			glNormal3v(v3);
-			glVertex3v(v3);
-			glNormal3v(v2);
-			glVertex3v(v2);
-			glNormal3v(v1);
-			glVertex3v(v1);
+			glNormal3v(v3); glVertex3v(v3);
+			glNormal3v(v2); glVertex3v(v2);
+			glNormal3v(v1); glVertex3v(v1);
 		glEnd();
 		return;
 	}

=== modified file 'pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp'
--- pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp	2010-05-03 12:17:44 +0000
+++ pkg/common/RenderingEngine/OpenGLRenderingEngine.cpp	2010-05-03 13:58:09 +0000
@@ -142,7 +142,7 @@
 
 void OpenGLRenderingEngine::resetSpecularEmission(){
 	const GLfloat specular[4]={.3,.3,.3,1};
-	const GLfloat emission[4]={.1,.1,.1,1};
+	const GLfloat emission[4]={0,0,0,0};
 	glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,specular);
 	glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission);
 }

=== modified file 'pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp'
--- pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp	2010-05-03 12:17:44 +0000
+++ pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp	2010-05-03 13:58:09 +0000
@@ -134,7 +134,7 @@
 				if (exactAsphericalRot && ((state->inertia[0]!=state->inertia[1] || state->inertia[1]!=state->inertia[2]))){
 					FOREACH(Clump::memberMap::value_type mm, static_cast<Clump*>(b.get())->members){
 						const body_id_t& memberId=mm.first;
-						const shared_ptr<Body>& member=Body::byId(memberId,scene); assert(b->isClumpMember());
+						const shared_ptr<Body>& member=Body::byId(memberId,scene); assert(member->isClumpMember());
 						State* memberState=member->state.get();
 						handleClumpMemberAccel(scene,memberId,memberState,state);
 						handleClumpMemberTorque(scene,memberId,memberState,state,M);

=== modified file 'py/yadeWrapper/yadeWrapper.cpp'
--- py/yadeWrapper/yadeWrapper.cpp	2010-04-26 16:09:18 +0000
+++ py/yadeWrapper/yadeWrapper.cpp	2010-05-03 13:58:09 +0000
@@ -113,13 +113,17 @@
 		#endif
 		vector<body_id_t> ret; FOREACH(shared_ptr<Body>& b, bb){ret.push_back(append(b));} return ret;
 	}
-	python::tuple appendClump(vector<shared_ptr<Body> > bb){/*clump: first add constitutents, then add clump, then add constitutents to the clump, then update clump props*/
+	python::tuple appendClump(vector<shared_ptr<Body> > bb){
+		// update clump members
 		vector<body_id_t> ids(appendList(bb));
+		// create and add clump itself
 		shared_ptr<Clump> clump=shared_ptr<Clump>(new Clump());
 		shared_ptr<Body> clumpAsBody=static_pointer_cast<Body>(clump);
 		clump->isDynamic=true;
 		proxee->insert(clumpAsBody);
+		// add clump members to the clump
 		FOREACH(body_id_t id, ids) clump->add(id);
+		// update clump
 		clump->updateProperties(false);
 		return python::make_tuple(clump->getId(),ids);
 	}