← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1800: 1. Fix crash when removing bodies with velocityBins and MetaInteractingGeometry2AABB

 

------------------------------------------------------------
revno: 1800
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Fri 2009-11-20 10:39:11 +0100
message:
  1. Fix crash when removing bodies with velocityBins and MetaInteractingGeometry2AABB
  2. Add option to draw normals for InteractingFacet (off by default); see scripts/test/remove-body.py (commented)
modified:
  pkg/common/DataClass/VelocityBins.cpp
  pkg/common/Engine/EngineUnit/MetaInteractingGeometry2AABB.cpp
  pkg/common/RenderingEngine/GLDrawInteractingFacet.cpp
  pkg/common/RenderingEngine/GLDrawInteractingFacet.hpp
  scripts/test/remove-body.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 'pkg/common/DataClass/VelocityBins.cpp'
--- pkg/common/DataClass/VelocityBins.cpp	2009-09-01 09:01:20 +0000
+++ pkg/common/DataClass/VelocityBins.cpp	2009-11-20 09:39:11 +0000
@@ -67,6 +67,7 @@
 		}
 	long moveFaster=0, moveSlower=0;
 	FOREACH(const shared_ptr<Body>& b, *rootBody->bodies){
+		if(!b) continue;
 		RigidBodyParameters* rbp=YADE_CAST<RigidBodyParameters*>(b->physicalParameters.get());
 		Real velSq=VelocityBins::getBodyVelSq(rbp);
 		binNo_t newBin=-1, oldBin=bodyBins[b->getId()];

=== modified file 'pkg/common/Engine/EngineUnit/MetaInteractingGeometry2AABB.cpp'
--- pkg/common/Engine/EngineUnit/MetaInteractingGeometry2AABB.cpp	2009-11-15 15:32:01 +0000
+++ pkg/common/Engine/EngineUnit/MetaInteractingGeometry2AABB.cpp	2009-11-20 09:39:11 +0000
@@ -26,22 +26,15 @@
 	Vector3r mn(inf,inf,inf);
 	
 	const MetaBody * ncb = YADE_CAST<const MetaBody*>(body);
-	const shared_ptr<BodyContainer>& bodies = ncb->bodies;
 	
-	BodyContainer::iterator bi    = bodies->begin();
-	BodyContainer::iterator biEnd = bodies->end();
-	for( ; bi!=biEnd ; ++bi )
-	{
-		shared_ptr<Body> b = *bi;
-		if(b->boundingVolume)
-		{
+	FOREACH(const shared_ptr<Body>& b, *ncb->bodies){
+		if(!b) continue;
+		if(b->boundingVolume){
 			for(int i=0; i<3; i++){
 				if(!isinf(b->boundingVolume->max[i])) mx[i]=max(mx[i],b->boundingVolume->max[i]);
 				if(!isinf(b->boundingVolume->min[i])) mn[i]=min(mn[i],b->boundingVolume->min[i]);
 			}
-		} 
-		else
-		{
+		} else {
 	 		mx=componentMaxVector(mx,b->physicalParameters->se3.position);
  			mn=componentMinVector(mn,b->physicalParameters->se3.position);
 		}
@@ -49,7 +42,7 @@
 	
 	aabb->center = (mx+mn)*0.5;
 	aabb->halfSize = (mx-mn)*0.5;
-	
+
 	aabb->min = mn;
 	aabb->max = mx;
 }

=== modified file 'pkg/common/RenderingEngine/GLDrawInteractingFacet.cpp'
--- pkg/common/RenderingEngine/GLDrawInteractingFacet.cpp	2009-11-18 13:34:36 +0000
+++ pkg/common/RenderingEngine/GLDrawInteractingFacet.cpp	2009-11-20 09:39:11 +0000
@@ -10,7 +10,7 @@
 #include <yade/pkg-common/InteractingFacet.hpp>
 #include<yade/lib-opengl/OpenGLWrapper.hpp>
 
-
+bool GLDrawInteractingFacet::normals=false;
 
 void GLDrawInteractingFacet::go(const shared_ptr<InteractingGeometry>& cm, const shared_ptr<PhysicalParameters>& ,bool,const GLViewInfo&)
 {   
@@ -29,6 +29,8 @@
 	    glVertex3v(vertices[2]);
     glEnd();
 
+	 if(!normals) return;
+
 	// facet's normal 
     glBegin(GL_LINES);
 		glColor3(0.0,0.0,1.0); 

=== modified file 'pkg/common/RenderingEngine/GLDrawInteractingFacet.hpp'
--- pkg/common/RenderingEngine/GLDrawInteractingFacet.hpp	2009-11-18 13:34:36 +0000
+++ pkg/common/RenderingEngine/GLDrawInteractingFacet.hpp	2009-11-20 09:39:11 +0000
@@ -12,13 +12,15 @@
 
 class GLDrawInteractingFacet : public GLDrawInteractingGeometryFunctor
 {	
-	
+	//! render facet's and edges' normals
+	static bool normals;
 	public :
 		virtual void go(const shared_ptr<InteractingGeometry>&, const shared_ptr<PhysicalParameters>&,bool,const GLViewInfo&);
 
 	RENDERS(InteractingFacet);
 	REGISTER_CLASS_NAME(GLDrawInteractingFacet);
 	REGISTER_BASE_CLASS_NAME(GLDrawInteractingGeometryFunctor);
+	REGISTER_ATTRIBUTES(GLDrawInteractingGeometryFunctor,(normals));
 };
 
 REGISTER_SERIALIZABLE(GLDrawInteractingFacet);

=== modified file 'scripts/test/remove-body.py'
--- scripts/test/remove-body.py	2009-11-17 12:26:35 +0000
+++ scripts/test/remove-body.py	2009-11-20 09:39:11 +0000
@@ -7,8 +7,8 @@
 
 O.engines=[
 	BexResetter(),
-	BoundingVolumeMetaEngine([InteractingSphere2AABB(),InteractingFacet2AABB()]),
-	InsertionSortCollider(),
+	BoundingVolumeMetaEngine([InteractingSphere2AABB(),InteractingFacet2AABB(),MetaInteractingGeometry2AABB()]),
+	InsertionSortCollider(nBins=5,sweepLength=5e-3),
 	#SpatialQuickSortCollider(),
 	InteractionDispatchers(
 		[ef2_Facet_Sphere_Dem3DofGeom()],
@@ -23,6 +23,8 @@
 	utils.facet([[1,-1,0],[0,1,0,],[1,.5,.5]],dynamic=False,young=1e3)
 ])
 
+#GLDrawInteractingFacet(normals=True)
+
 import random,sys
 
 def addRandomSphere():