← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3645: Fix bug in InteractionContainer::eraseNonReal

 

------------------------------------------------------------
revno: 3645
committer: Janek Kozicki <janek@xxxxxxxxxx>
timestamp: Thu 2015-04-30 18:53:30 +0200
message:
  Fix bug in InteractionContainer::eraseNonReal
  
  It was calling erase( ) with linPos=-1, which was always failing the
  assert, aborting the calculations. This bug is visible only when using
  SpatialQuickSortCollider (which was reformatted a little also)
modified:
  core/InteractionContainer.cpp
  core/InteractionContainer.hpp
  pkg/common/SpatialQuickSortCollider.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 'core/InteractionContainer.cpp'
--- core/InteractionContainer.cpp	2014-06-16 08:13:21 +0000
+++ core/InteractionContainer.cpp	2015-04-30 16:53:30 +0000
@@ -130,7 +130,7 @@
 }
 
 void InteractionContainer::eraseNonReal(){
-	FOREACH(const shared_ptr<Interaction>& i, *this) if(!i->isReal()) this->erase(i->getId1(),i->getId2());
+	FOREACH(const shared_ptr<Interaction>& i, *this) if(!i->isReal()) this->erase(i->getId1(),i->getId2(),i->linIx);
 }
 
 // compare interaction based on their first id

=== modified file 'core/InteractionContainer.hpp'
--- core/InteractionContainer.hpp	2014-10-15 06:44:01 +0000
+++ core/InteractionContainer.hpp	2015-04-30 16:53:30 +0000
@@ -72,7 +72,7 @@
 		bool insert(Body::id_t id1,Body::id_t id2);
 		bool insert(const shared_ptr<Interaction>& i);
 		//3rd parameter is used to remove I from linIntrs (in conditionalyEraseNonReal()) when body b1 has been removed
-		bool erase(Body::id_t id1,Body::id_t id2,int linPos=-1);
+		bool erase(Body::id_t id1,Body::id_t id2,int linPos);
 		const shared_ptr<Interaction>& find(Body::id_t id1,Body::id_t id2);
 // 		bool found(Body::id_t id1,Body::id_t id2);
 		inline bool found(const Body::id_t& id1,const Body::id_t& id2){

=== modified file 'pkg/common/SpatialQuickSortCollider.cpp'
--- pkg/common/SpatialQuickSortCollider.cpp	2014-10-15 06:44:01 +0000
+++ pkg/common/SpatialQuickSortCollider.cpp	2015-04-30 16:53:30 +0000
@@ -38,36 +38,32 @@
 	}
 
 	Vector3r min,max;
-	shared_ptr<Body> b;
 	int i=0;
 	FOREACH(const shared_ptr<Body>& b, *bodies){
 		if(!b->bound) continue;
-	   
-	   min = b->bound->min;
-	   max = b->bound->max;
-
-	   rank[i]->id = b->getId();
-	   rank[i]->min = min;
-	   rank[i]->max = max;
-
+		min = b->bound->min;
+		max = b->bound->max;
+		rank[i]->id = b->getId();
+		rank[i]->min = min;
+		rank[i]->max = max;
 		i++;
 	}
 	
 	const shared_ptr<InteractionContainer>& interactions=scene->interactions;
 	scene->interactions->iterColliderLastRun=scene->iter;
 
-	sort(rank.begin(), rank.end(), xBoundComparator()); // sotring along X
+	sort(rank.begin(), rank.end(), xBoundComparator()); // sorting along X
 
 	int id,id2; size_t j;
 	shared_ptr<Interaction> interaction;
 	for(int i=0,e=nbElements-1; i<e; ++i)
 	{
-	    id  = rank[i]->id;
-	    min = rank[i]->min; 
-	    max = rank[i]->max; 
-	    j=i;
-	    while(++j<nbElements)
-	    {
+		id  = rank[i]->id;
+		min = rank[i]->min;
+		max = rank[i]->max;
+		j=i;
+		while(++j<nbElements)
+		{
 			if ( rank[j]->min[0] > max[0]) break;
 			if ( rank[j]->min[1] < max[1]
 			&& rank[j]->max[1] > min[1]
@@ -82,7 +78,7 @@
 				}
 				interaction->iterLastSeen=scene->iter; 
 			}
-	    }
+		}
 	}
 }