← Back to team overview

yade-dev team mailing list archive

[svn] r1941 - in trunk: pkg/common/Engine/DeusExMachina pkg/common/Engine/StandAloneEngine pkg/realtime-rigidbody scripts/test

 

Author: eudoxos
Date: 2009-08-14 08:59:23 +0200 (Fri, 14 Aug 2009)
New Revision: 1941

Added:
   trunk/scripts/test/pack-cloud.py
Removed:
   trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.cpp
   trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.hpp
   trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.cpp
   trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.hpp
   trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.cpp
   trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.hpp
   trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
   trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.hpp
   trunk/pkg/realtime-rigidbody/DataClass/
Log:
1. Remove {,Distant}PersistentSAPCollider and Fixed{Position,Orientation}Engine classes
2. Add test script for generating packing


Deleted: trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.cpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.cpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.cpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,50 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2004 by Janek Kozicki                                   *
-*  cosurgi@xxxxxxxxxx                                                    *
-*                                                                        *
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#include "FixedOrientationEngine.hpp"
-#include<yade/core/MetaBody.hpp>
-#include<yade/lib-base/yadeWm3Extra.hpp>
-
-FixedOrientationEngine::FixedOrientationEngine()
-{
-	fixedOrientation=Quaternionr(1.0,0.0,0.0,0.0);
-}
-
-void FixedOrientationEngine::postProcessAttributes(bool deserializing)
-{
-	if(deserializing)
-	{
-		std::cerr << "fixedOrientation: " << fixedOrientation.W() << " " << fixedOrientation.X() << " " <<fixedOrientation.Y() << " " <<fixedOrientation.Z() << "\n\n";
-	}
-}
-
-
-
-void FixedOrientationEngine::applyCondition(MetaBody * ncb)
-{
-	shared_ptr<BodyContainer>& bodies = ncb->bodies;
-
-	std::vector<int>::const_iterator ii = subscribedBodies.begin();
-	std::vector<int>::const_iterator iiEnd = subscribedBodies.end();
-
-	for(;ii!=iiEnd;++ii)
-		if( bodies->exists(*ii) )
-			((*bodies)[*ii]->physicalParameters.get())->se3.orientation = fixedOrientation;
-
-//	BodyContainer::iterator bi    = bodies->begin();
-//	BodyContainer::iterator biEnd = bodies->end();
-//	for( ; bi!=biEnd ; ++bi )
-//	{
-//		shared_ptr<Body> b = *bi;
-//		if(mask[0] != 0)  (b->physicalParameters.get())->se3.position[0] = fixedPosition[0];
-//		if(mask[1] != 0)  (b->physicalParameters.get())->se3.position[1] = fixedPosition[1];
-//		if(mask[2] != 0)  (b->physicalParameters.get())->se3.position[2] = fixedPosition[2];
-//	}
-}
-
-YADE_PLUGIN((FixedOrientationEngine));
\ No newline at end of file

Deleted: trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.hpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.hpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/DeusExMachina/FixedOrientationEngine.hpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,32 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2007 by Janek Kozicki                                   *
-*  cosurgi@xxxxxxxxxx                                                    *
-*                                                                        *
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#pragma once
-
-#include<yade/core/DeusExMachina.hpp>
-#include <Wm3Vector3.h>
-#include<yade/lib-base/yadeWm3.hpp>
-
-class FixedOrientationEngine : public DeusExMachina
-{
-	public :
-		Quaternionr fixedOrientation;
-		void applyCondition(MetaBody *);
-
-		FixedOrientationEngine();
-
-	protected :
-		virtual void postProcessAttributes(bool);
-	REGISTER_ATTRIBUTES(DeusExMachina,(fixedOrientation));
-	REGISTER_CLASS_NAME(FixedOrientationEngine);
-	REGISTER_BASE_CLASS_NAME(DeusExMachina);
-};
-
-REGISTER_SERIALIZABLE(FixedOrientationEngine);
-
-

Deleted: trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.cpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.cpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.cpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,31 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2004 by Janek Kozicki                                   *
-*  cosurgi@xxxxxxxxxx                                                    *
-*                                                                        *
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#include"FixedPositionEngine.hpp"
-#include<yade/core/MetaBody.hpp>
-#include<boost/foreach.hpp>
-
-FixedPositionEngine::FixedPositionEngine(){
-	fixedPosition=Vector3r(0,0,0);
-	mask=Vector3r(0,0,1);
-}
-
-void FixedPositionEngine::postProcessAttributes(bool deserializing){}
-
-
-void FixedPositionEngine::applyCondition(MetaBody * ncb){
-	shared_ptr<BodyContainer>& bodies = ncb->bodies;
-	FOREACH(int id, subscribedBodies){
-		if(!bodies->exists(id)) continue;
-		if(mask[0]!=0) (*bodies)[id]->physicalParameters->se3.position[0]=fixedPosition[0];
-		if(mask[1]!=0) (*bodies)[id]->physicalParameters->se3.position[1]=fixedPosition[1];
-		if(mask[2]!=0) (*bodies)[id]->physicalParameters->se3.position[2]=fixedPosition[2];
-	}
-}
-
-YADE_PLUGIN((FixedPositionEngine));
\ No newline at end of file

Deleted: trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.hpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.hpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/DeusExMachina/FixedPositionEngine.hpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,32 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2007 by Janek Kozicki                                   *
-*  cosurgi@xxxxxxxxxx                                                    *
-*                                                                        *
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#pragma once
-
-#include<yade/core/DeusExMachina.hpp>
-#include <Wm3Vector3.h>
-#include<yade/lib-base/yadeWm3.hpp>
-
-/* Resets spatial position for all subscribed bodies to the desired value. */
-class FixedPositionEngine : public DeusExMachina {
-	public:
-		Vector3r fixedPosition;
-		//! Non-zero components determine which components of fixedPosition will be used 
-		Vector3r mask;
-		void applyCondition(MetaBody*);
-		FixedPositionEngine();
-	protected:
-		virtual void postProcessAttributes(bool);
-	REGISTER_ATTRIBUTES(DeusExMachina,(fixedPosition)(mask));
-	REGISTER_CLASS_NAME(FixedPositionEngine);
-	REGISTER_BASE_CLASS_NAME(DeusExMachina);
-};
-
-REGISTER_SERIALIZABLE(FixedPositionEngine);
-
-

Deleted: trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.cpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.cpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.cpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,257 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2007 by Bruno Chareyre                                  *
-*  bruno.chareyre@xxxxxxxxxxx                                            *
-*                                                                        *
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-YADE_REQUIRE_FEATURE(Say goodbye to this piece of crappy code!)
-
-#include"DistantPersistentSAPCollider.hpp"
-#include<yade/core/Body.hpp>
-#include<yade/core/MetaBody.hpp>
-#include<yade/core/BodyContainer.hpp>
-
-DistantPersistentSAPCollider::DistantPersistentSAPCollider() : Collider()
-{
-//	cerr << "DistantPersistentSAPCollider\n";
-
-	//this->maxObject = 150000;
-	nbObjects=0;
-
-	//xBounds.resize(2*maxObject);
-	//yBounds.resize(2*maxObject);
-	//zBounds.resize(2*maxObject);
-
-	//minimums = new Real[3*maxObject];
-	//maximums = new Real[3*maxObject];
-	
-	xBounds.clear();
-	yBounds.clear();
-	zBounds.clear();
-
-	minimums.clear();
-	maximums.clear();
-}
-
-DistantPersistentSAPCollider::~DistantPersistentSAPCollider()
-{
-
-}
-
-void DistantPersistentSAPCollider::action(MetaBody* ncb)
-{
-
-	shared_ptr<BodyContainer> bodies = ncb->bodies;
-	
-	if (2*bodies->size()!=xBounds.size())
-	{
-		xBounds.resize(2*bodies->size());
-		yBounds.resize(2*bodies->size());
-		zBounds.resize(2*bodies->size());
-
-		minimums.resize(3*bodies->size());
-		maximums.resize(3*bodies->size());
-	}
-
-	// Updates the minimums and maximums arrays according to the new center and radius of the spheres
-	int offset;
-	Vector3r min,max;
-	shared_ptr<Body> b;
-
-	BodyContainer::iterator bi    = bodies->begin();
-	BodyContainer::iterator biEnd = bodies->end();
-	for(unsigned int i=0 ; bi!=biEnd ; ++bi,i++ )
-	{
-		b = *bi;
-		
-		offset = 3*i;
-		//FIXME: this is broken: bodies without boundingVolume are just skipped, which means that some garbage values are used later!
-		if(b->boundingVolume) // can't assume that everybody has BoundingVolume
-		{
-			min = b->boundingVolume->min;
-			max = b->boundingVolume->max;
-			minimums[offset+0] = min[0];
-			minimums[offset+1] = min[1];
-			minimums[offset+2] = min[2];
-			maximums[offset+0] = max[0];
-			maximums[offset+1] = max[1];
-			maximums[offset+2] = max[2];
-		}
-	}
-	
-	transientInteractions = ncb->transientInteractions;
-	InteractionContainer::iterator ii    = transientInteractions->begin();
-	InteractionContainer::iterator iiEnd = transientInteractions->end();
-	for( ; ii!=iiEnd ; ++ii)
-	{
-		shared_ptr<Interaction> interaction = *ii;
-		//if (interaction->isReal()) // if a interaction was only potential then no geometry was created for it and so this time it is still a new one
-			// interaction->isNew = false;
-		//interaction->isReal = false;
-	}
-	
-	updateIds(bodies->size());
-	nbObjects = bodies->size();
-
-	// permutation sort of the AABBBounds along the 3 axis performed in a independant manner
-	sortBounds(xBounds, nbObjects);
-	sortBounds(yBounds, nbObjects);
-	sortBounds(zBounds, nbObjects);
-
-}
-
-
-void DistantPersistentSAPCollider::updateIds(unsigned int nbElements)
-{
-
-	// the first time broadInteractionTest is called nbObject=0
-	if (nbElements!=nbObjects)
-	{
-		int begin,end;
-
-		end = nbElements;
-		begin = 0;
-
-		if (nbElements>nbObjects)
-			begin = nbObjects;
-
-		// initialization if the xBounds, yBounds, zBounds
-		for(int i=begin;i<end;i++)
-		{
-			xBounds[2*i]	= shared_ptr<AABBBound>(new AABBBound(i,1));
-			xBounds[2*i+1]	= shared_ptr<AABBBound>(new AABBBound(i,0));
-			
-			yBounds[2*i]	= shared_ptr<AABBBound>(new AABBBound(i,1));
-			yBounds[2*i+1]	= shared_ptr<AABBBound>(new AABBBound(i,0));
-			
-			zBounds[2*i]	= shared_ptr<AABBBound>(new AABBBound(i,1));
-			zBounds[2*i+1]	= shared_ptr<AABBBound>(new AABBBound(i,0));
-		}
-
-		// initialization if the field "value" of the xBounds, yBounds, zBounds arrays
-		updateBounds(nbElements);
-
-		// modified quick sort of the xBounds, yBounds, zBounds arrays
-		// The first time these arrays are not sorted so it is faster to use such a sort instead
-		// of the permutation we are going to use next
-		std::sort(xBounds.begin(),xBounds.begin()+2*nbElements,AABBBoundComparator());
-		std::sort(yBounds.begin(),yBounds.begin()+2*nbElements,AABBBoundComparator());
-		std::sort(zBounds.begin(),zBounds.begin()+2*nbElements,AABBBoundComparator());
-
-		// initialize the overlappingBB collection
-		//for(unsigned int j=0;j<nbElements;j++)
-		//	overlappingBB[j].clear(); //attention memoire
-
-		findOverlappingBB(xBounds, nbElements);
-		findOverlappingBB(yBounds, nbElements);
-		findOverlappingBB(zBounds, nbElements);
-
-	}
-	else
-		updateBounds(nbElements);
-}
-
-
-void DistantPersistentSAPCollider::sortBounds(vector<shared_ptr<AABBBound> >& bounds, int nbElements)
-{
-	int i,j;
-	shared_ptr<AABBBound> tmp;
-
-	for (i=1; i<2*nbElements; i++)
-	{
-		tmp = bounds[i];
-		j = i;
-		while (j>0 && tmp->value<bounds[j-1]->value)
-		{
-			bounds[j] = bounds[j-1];
-			updateOverlapingBBSet(tmp->id,bounds[j-1]->id);
-			j--;
-		}
-		bounds[j] = tmp;
-	}
-}
-
-
-void DistantPersistentSAPCollider::updateOverlapingBBSet(int id1,int id2)
-{
-
-// 	// look if the pair (id1,id2) already exists in the overleppingBB collection
-	shared_ptr<Interaction> interaction = transientInteractions->find(body_id_t(id1),body_id_t(id2));//Bruno's Hack
-	//bool found = (transientInteractions->find(body_id_t(id1),body_id_t(id2))!=0);
-bool found = (interaction!=0);//Bruno's Hack
-
-	
-	// test if the AABBs of the spheres number "id1" and "id2" are overlapping
-	int offset1 = 3*id1;
-	int offset2 = 3*id2;
-	// FIXME: this is perhaps an expensive operation?!
-	const shared_ptr<Body>& b1(Body::byId(body_id_t(id1))), b2(Body::byId(body_id_t(id2)));
-	bool overlap =
-
-		(b1->isStandalone() || b2->isStandalone() || b1->clumpId!=b2->clumpId ) && // only collide if at least one particle is standalone or they belong to different clumps
-		!b1->isClump() && !b2->isClump() && // do not collide clumps, since they are just containers, never interact
-
-		!(maximums[offset1]<minimums[offset2] || maximums[offset2]<minimums[offset1] || 
-		maximums[offset1+1]<minimums[offset2+1] || maximums[offset2+1]<minimums[offset1+1] || 
-		maximums[offset1+2]<minimums[offset2+2] || maximums[offset2+2]<minimums[offset1+2]);
-
-	// inserts the pair p=(id1,id2) if the two AABB overlaps and if p does not exists in the overlappingBB
-	if (overlap && !found)
-		transientInteractions->insert(body_id_t(id1),body_id_t(id2));
-	// removes the pair p=(id1,id2) if the two AABB do not overlapp any more and if p already exists in the overlappingBB
-	else if (!overlap && found && !interaction->isReal())
-		transientInteractions->erase(body_id_t(id1),body_id_t(id2));//Bruno's hack
-//else if (!overlap && found)
-//		transientInteractions->erase(body_id_t(id1),body_id_t(id2));
-}
-
-
-void DistantPersistentSAPCollider::updateBounds(int nbElements)
-{
-
-	for(int i=0; i < 2*nbElements; i++)
-	{
-		if (xBounds[i]->lower)
-			xBounds[i]->value = minimums[3*xBounds[i]->id+0];
-		else
-			xBounds[i]->value = maximums[3*xBounds[i]->id+0];
-
-		if (yBounds[i]->lower)
-			yBounds[i]->value = minimums[3*yBounds[i]->id+1];
-		else
-			yBounds[i]->value = maximums[3*yBounds[i]->id+1];
-
-		if (zBounds[i]->lower)
-			zBounds[i]->value = minimums[3*zBounds[i]->id+2];
-		else
-			zBounds[i]->value = maximums[3*zBounds[i]->id+2];
-	}
-}
-
-
-
-
-void DistantPersistentSAPCollider::findOverlappingBB(std::vector<shared_ptr<AABBBound> >& bounds, int nbElements)
-{
-
-	int i,j;
-
-	i = j = 0;
-	while (i<2*nbElements)
-	{
-		while (i<2*nbElements && !bounds[i]->lower)
-			i++;
-		j=i+1;
-		while (j<2*nbElements && bounds[j]->id!=bounds[i]->id)
-		{
-			if (bounds[j]->lower)
-				updateOverlapingBBSet(bounds[i]->id,bounds[j]->id);
-			j++;
-		}
-		i++;
-	}
-}
-
-YADE_PLUGIN((DistantPersistentSAPCollider));

Deleted: trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.hpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.hpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/StandAloneEngine/DistantPersistentSAPCollider.hpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,102 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2007 by Bruno Chareyre                                  *
-*  bruno.chareyre@xxxxxxxxxxx                                            *
-*                                                                        *
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#pragma once
-
-#include<yade/core/Collider.hpp>
-#include<yade/core/InteractionContainer.hpp>
-#include <list>
-#include <set>
-#include <vector>
-#include <algorithm>
-
-using namespace std;
-
-class DistantPersistentSAPCollider : public Collider
-{
-	private :
-		// represent an extrmity of an Axis ALigned bounding box
-		struct AABBBound
-		{
-			AABBBound(int i, char l) : id(i),lower(l) {};
-			int		id;		// AABB of the "id" shpere
-			char		lower;		// is it the lower or upper bound of the AABB
-			Real		value;		// value of the bound
-		};
-		// strucuture that compare 2 AABBBounds => used in the sort algorithm
-		struct AABBBoundComparator
-		{
-			bool operator() (shared_ptr<AABBBound> b1, shared_ptr<AABBBound> b2)
-			{
-				return b1->value<b2->value;
-			}
-		};
-
-	protected :
-		/// number of potential transientInteractions = number of interacting AABB
-		int nbPotentialInteractions;
-
-		/// number of AABB
-		unsigned int nbObjects;
-
-		/// AABB extremity of the sphere number "id" projected onto the X axis
-		vector<shared_ptr<AABBBound> > xBounds;
-
-		/// AABB extremity of the sphere number "id" projected onto the Y axis
-		vector<shared_ptr<AABBBound> > yBounds;
-
-		/// AABB extremity of the sphere number "id" projected onto the Z axis
-		vector<shared_ptr<AABBBound> > zBounds;
-
-		// collection of AABB that are in interaction
-		//protected : vector< set<unsigned int> > overlappingBB;
-		shared_ptr<InteractionContainer> transientInteractions;
-		/// upper right corner of the AABB of the objects =>  for spheres = center[i]-radius
-		vector<Real> maximums;
-
-		/// lower left corner of the AABB of the objects =>  for spheres = center[i]+radius
-		vector<Real> minimums;
-
-		/// Used the first time broadInteractionTest is called, to initialize and sort the xBounds, yBounds,
-		/// and zBounds arrays and to initialize the overlappingBB collection
-		void updateIds(unsigned int nbElements);
-
-		/// Permutation sort the xBounds, yBounds, zBounds arrays according to the "value" field
-		/// Calls updateOverlapingBBSet every time a permutation between 2 AABB i and j occurs
-		void sortBounds(vector<shared_ptr<AABBBound> >& bounds, int nbElements);
-
-		/// Tests if the AABBi and AABBj really overlap.
-		/// If yes, adds the pair (id1,id2) to the collection of overlapping AABBs
-		/// If no, removes the (id1,id2) to the collection of overlapping AABBs if necessary
-		void updateOverlapingBBSet(int id1,int id2);
-
-		/// update the "value" field of the xBounds, yBounds, zBounds arrays
-		void updateBounds(int nbElements);
-
-		/// Used the first time broadInteractionTest is called
-		/// It is necessary to initialise the overlapping AABB collection because this collection is only
-		/// incrementally udated each time step
-		void findOverlappingBB(vector<shared_ptr<AABBBound> >& bounds, int nbElements);
-
-	public :
-		DistantPersistentSAPCollider();
-
-		virtual ~DistantPersistentSAPCollider();
-
-		/// return a list "transientInteractions" of pairs of Body which Bounding volume are in potential interaction
-		void action(MetaBody *);
-
-
-	REGISTER_CLASS_NAME(DistantPersistentSAPCollider);
-	REGISTER_BASE_CLASS_NAME(Collider);
-
-};
-
-REGISTER_SERIALIZABLE(DistantPersistentSAPCollider);
-
-

Deleted: trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,319 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2004,2007 by
-*  	Olivier Galizzi <olivier.galizzi@xxxxxxx>
-*  	Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
-*  	Václav Šmilauer <eudoxos@xxxxxxxx>
-*
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-YADE_REQUIRE_FEATURE(Say goodbye to this piece of crappy code!)
-
-#include"PersistentSAPCollider.hpp"
-#include<yade/core/Body.hpp>
-#include<yade/core/MetaBody.hpp>
-#include<yade/core/BodyContainer.hpp>
-#include<limits>
-
-CREATE_LOGGER(PersistentSAPCollider);
-
-PersistentSAPCollider::PersistentSAPCollider() : Collider()
-{
-	haveDistantTransient=false;
-	//ompBodiesMin=0;
-
-	nbObjects=0;
-	xBounds.clear();
-	yBounds.clear();
-	zBounds.clear();
-	minima.clear();
-	maxima.clear();
-
-//	timingDeltas=shared_ptr<TimingDeltas>(new TimingDeltas);
-}
-
-PersistentSAPCollider::~PersistentSAPCollider()
-{
-
-}
-
-// template void InteractionContainer::erasePending<PersistentSAPCollider>(const PersistentSAPCollider&);
-
-void PersistentSAPCollider::action(MetaBody* ncb)
-{
-	rootBody=ncb;
-	shared_ptr<BodyContainer> bodies=ncb->bodies;
-	transientInteractions=ncb->transientInteractions;
-
-//	timingDeltas->start();
-	
-	if (2*bodies->size()!=xBounds.size()){
-		xBounds.resize(2*bodies->size());
-		yBounds.resize(2*bodies->size());
-		zBounds.resize(2*bodies->size());
-		minima.resize(3*bodies->size());
-		maxima.resize(3*bodies->size());
-	}
-
-//	timingDeltas->checkpoint("resizeArrays");
-
-	// Updates the minima and maxima arrays according to the new center and radius of the spheres
-	int offset;
-	Vector3r min,max;
-
-	const long numBodies=(long)bodies->size();
-	//#pragma omp parallel for
-	for(int id=0; id<numBodies; id++){
-		const shared_ptr<Body>& b=(*bodies)[id];
-		offset=3*id;
-		if(b->boundingVolume){ // can't assume that everybody has BoundingVolume
-			min=b->boundingVolume->min; max=b->boundingVolume->max;
-			minima[offset+0]=min[0]; minima[offset+1]=min[1]; minima[offset+2]=min[2];
-			maxima[offset+0]=max[0]; maxima[offset+1]=max[1]; maxima[offset+2]=max[2];
-		}
-		else {
-			/* assign the center of gravity as zero-volume bounding box;
-			 * it should not create spurious interactions and
-			 * is a better solution that putting nan's into minima and maxima which crashes on _some_ machines */
-			const Vector3r& pos=b->physicalParameters->se3.position;
-			minima[offset+0]=pos[0]; minima[offset+1]=pos[1]; minima[offset+2]=pos[2];
-			maxima[offset+0]=pos[0]; maxima[offset+1]=pos[1]; maxima[offset+2]=pos[2];
-		}
-	}
-
-//	timingDeltas->checkpoint("minMaxUpdate");
-
-	ncb->interactions->erasePending(*this,ncb);
-
-//	timingDeltas->checkpoint("deleteInvalid");
-	
-	updateIds(bodies->size());
-
-//	timingDeltas->checkpoint("updateIds");
-
-	nbObjects=bodies->size();
-
-	// permutation sort of the AABBBounds along the 3 axis performed in a independant manner
-	// serial version
-	//if(nbObjects>ompBodiesMin || ompBodiesMin==0){ … }
-	sortBounds(xBounds,nbObjects); sortBounds(yBounds,nbObjects); sortBounds(zBounds,nbObjects);
-
-//	timingDeltas->checkpoint("sortBounds");
-}
-
-bool PersistentSAPCollider::probeBoundingVolume(const BoundingVolume& bv)
-{
-	probedBodies.clear();
-	for( vector<shared_ptr<AABBBound> >::iterator 
-			it=xBounds.begin(),et=xBounds.end(); it < et; ++it)
-	{
-		if ((*it)->value > bv.max[0]) break;
-		if (!(*it)->lower) continue;
-		int offset = 3*(*it)->id;
-		if (!(maxima[offset] < bv.min[0] ||
-				minima[offset+1] > bv.max[1] ||
-				maxima[offset+1] < bv.min[1] ||
-				minima[offset+2] > bv.max[2] ||
-				maxima[offset+2] < bv.min[2] )) 
-		{
-			probedBodies.push_back((*it)->id);
-		}
-	}
-	return (bool)probedBodies.size();
-}
-
-
-void PersistentSAPCollider::updateIds(unsigned int nbElements)
-{
-	// the first time broadInteractionTest is called nbObject=0
-	if (nbElements!=nbObjects){
-		int begin=0, end=nbElements;
-		if (nbElements>nbObjects) begin=nbObjects;
-
-		//timingDeltas->start();
-
-		// initialization if the xBounds, yBounds, zBounds
-		for(int i=begin;i<end;i++){
-			xBounds[2*i]	= shared_ptr<AABBBound>(new AABBBound(i,1));
-			xBounds[2*i+1]	= shared_ptr<AABBBound>(new AABBBound(i,0));
-			yBounds[2*i]	= shared_ptr<AABBBound>(new AABBBound(i,1));
-			yBounds[2*i+1]	= shared_ptr<AABBBound>(new AABBBound(i,0));
-			zBounds[2*i]	= shared_ptr<AABBBound>(new AABBBound(i,1));
-			zBounds[2*i+1]	= shared_ptr<AABBBound>(new AABBBound(i,0));
-		}
-
-		//timingDeltas->checkpoint("init");
-
-		// initialization if the field "value" of the xBounds, yBounds, zBounds arrays
-		updateBounds(nbElements);
-
-		/* Performance note: such was the timing result on initial step of 8k sphere in triaxial test.
-			the findX, findY, findZ take almost the totality of the time.
-			Parallelizing those is vastly beneficial (almost 3x speed increase, which can be quite sensible as the initial
-			findOverlappingBB is really slow http://yade.wikia.com/wiki/Colliders_performace and is done in 3
-			orthogonal directions. Therefore, it is enabled by default. updateOverlappingBBSet must be protected by 
-			critical section, since it is called from all threads!
-			
-			Now sortX is right before findX etc, in the same openMP section. Beware that timingDeltas will give garbage
-			results if used in parallelized code.
-
-			===
-
-			8k spheres:
-			Name                                                    Count                 Time            Rel. time
-			-------------------------------------------------------------------------------------------------------
-			PersistentSAPCollider                                 1            3568091us              100.00%      
-			  init                                                  1              21178us                0.59%    
-			  sortX                                                 1              33225us                0.93%    
-			  sortY                                                 1              29300us                0.82%    
-			  sortZ                                                 1              28334us                0.79%    
-			  findX                                                 1            1708426us               47.88%    
-			  findY                                                 1             869150us               24.36%    
-			  findZ                                                 1             867378us               24.31%    
-			  TOTAL                                                              3556994us               99.69%    
-
-		*/
-
-		// The first time these arrays are not sorted so it is faster to use such a sort instead
-		// of the permutation we are going to use next
-
-		// do not juse timingDeltas with openMP enabled, results will be garbage
-		#pragma omp parallel sections
-		{
-			#pragma omp section
-			{
-				std::sort(xBounds.begin(),xBounds.begin()+2*nbElements,AABBBoundComparator());
-				//timingDeltas->checkpoint("sortX");
-				findOverlappingBB(xBounds, nbElements);
-				//timingDeltas->checkpoint("findX");
-			}
-			#pragma omp section
-			{
-				std::sort(yBounds.begin(),yBounds.begin()+2*nbElements,AABBBoundComparator());
-				//timingDeltas->checkpoint("sortY");
-				findOverlappingBB(yBounds, nbElements);
-				//timingDeltas->checkpoint("findY");
-			}
-			#pragma omp section
-			{
-				std::sort(zBounds.begin(),zBounds.begin()+2*nbElements,AABBBoundComparator());
-				//timingDeltas->checkpoint("sortZ");
-				findOverlappingBB(zBounds, nbElements);
-				//timingDeltas->checkpoint("findZ");
-			}
-		}
-	}
-	else updateBounds(nbElements);
-}
-
-
-void PersistentSAPCollider::sortBounds(vector<shared_ptr<AABBBound> >& bounds, int nbElements){
-	int j;
-	for (int i=1; i<2*nbElements; i++){
-		shared_ptr<AABBBound> tmp(bounds[i]);
-		j=i;
-		while (j>0 && tmp->value<bounds[j-1]->value) {
-			bounds[j]=bounds[j-1];
-			updateOverlapingBBSet(tmp->id,bounds[j-1]->id);
-			j--;
-		}
-		bounds[j]=tmp;
-	}
-}
-
-
-bool PersistentSAPCollider::shouldBeErased(body_id_t id1, body_id_t id2) const {
-	// if there is no bbox overlap
-	int offset1=3*id1, offset2=3*id2;
-	return (
-		maxima[offset1  ]<minima[offset2  ] || maxima[offset2  ]<minima[offset1  ] || 
-		maxima[offset1+1]<minima[offset2+1] || maxima[offset2+1]<minima[offset1+1] || 
-		maxima[offset1+2]<minima[offset2+2] || maxima[offset2+2]<minima[offset1+2] );
-}
-
-/* Note that this function is called only for bodies that actually overlap along some axis */
-void PersistentSAPCollider::updateOverlapingBBSet(int id1,int id2){
-		// look if the pair (id1,id2) already exists in the overlappingBB collection
-		const shared_ptr<Interaction>& interaction=transientInteractions->find(body_id_t(id1),body_id_t(id2));
-		bool found=(bool)interaction;
-		
-		// test if the AABBs of the spheres number "id1" and "id2" are overlapping
-		int offset1=3*id1, offset2=3*id2;
-		const shared_ptr<Body>& b1(Body::byId(body_id_t(id1),rootBody)), b2(Body::byId(body_id_t(id2),rootBody));
-		bool overlap =
-			Collider::mayCollide(b1.get(),b2.get()) &&
-			// AABB collisions: 
-			!(
-				maxima[offset1  ]<minima[offset2  ] || maxima[offset2  ]<minima[offset1  ] || 
-				maxima[offset1+1]<minima[offset2+1] || maxima[offset2+1]<minima[offset1+1] || 
-				maxima[offset1+2]<minima[offset2+2] || maxima[offset2+2]<minima[offset1+2]);
-		// inserts the pair p=(id1,id2) if the two AABB overlaps and if p does not exists in the overlappingBB
-		//if((id1==0 && id2==1) || (id1==1 && id2==0)) LOG_DEBUG("Processing #0 #1");
-		//if(interaction&&!interaction->isReal){ LOG_DEBUG("Unreal interaction #"<<id1<<"=#"<<id2<<" (overlap="<<overlap<<", haveDistantTransient="<<haveDistantTransient<<")");}
-		if(overlap && !found){
-			//LOG_DEBUG("Creating interaction #"<<id1<<"=#"<<id2);
-			transientInteractions->insert(body_id_t(id1),body_id_t(id2));
-		}
-		// removes the pair p=(id1,id2) if the two AABB do not overlapp any more and if p already exists in the overlappingBB
-		else if(!overlap && found && (haveDistantTransient ? !interaction->isReal() : true) ){
-			//LOG_DEBUG("Erasing interaction #"<<id1<<"=#"<<id2<<" (isReal="<<interaction->isReal<<")");
-			transientInteractions->erase(body_id_t(id1),body_id_t(id2));
-		}
-}
-
-
-void PersistentSAPCollider::updateBounds(int nbElements)
-{
-	#define _BOUND_UPDATE(bounds,offset) \
-		if (bounds[i]->lower) bounds[i]->value = minima[3*bounds[i]->id+offset]; \
-		else bounds[i]->value = maxima[3*bounds[i]->id+offset];
-	// for small number of bodies, run sequentially
-	#if 0
-	if(nbElements<ompBodiesMin || ompBodiesMin==0){
-	#endif
-		for(int i=0; i < 2*nbElements; i++){
-			_BOUND_UPDATE(xBounds,0);
-			_BOUND_UPDATE(yBounds,1);
-			_BOUND_UPDATE(zBounds,2);
-		}
-	#if 0
-	}
-	else{
-		// parallelize for large number of bodies (not used, updateBounds takes only about 5% of collider time
-		#pragma omp parallel sections
-		{
-			#pragma omp section
-			for(int i=0; i < 2*nbElements; i++){ _BOUND_UPDATE(xBounds,0); }
-			#pragma omp section
-			for(int i=0; i < 2*nbElements; i++){ _BOUND_UPDATE(yBounds,1); }
-			#pragma omp section
-			for(int i=0; i < 2*nbElements; i++){ _BOUND_UPDATE(zBounds,2); }
-		}
-	}
-	#endif
-	#undef _BOUND_UPDATE
-}
-
-
-void PersistentSAPCollider::findOverlappingBB(std::vector<shared_ptr<AABBBound> >& bounds, int nbElements){
-	int i=0,j=0;
-	while (i<2*nbElements) {
-		while (i<2*nbElements && !bounds[i]->lower) i++;
-		j=i+1;
-		while (j<2*nbElements && bounds[j]->id!=bounds[i]->id){
-			if (bounds[j]->lower){
-				/* findOverlappingBB is called in parallel for different data at initialization,
-				 * but updateOverlapingBBSet touches shared global data, therefore must be protected by critical section;
-				 * normally updateOverlapingBBSet is also called sequentially from sortBounds, where the critical section
-				 * would penalize performance; therefore we have to protect it from here */
-				#pragma omp critical 
-					updateOverlapingBBSet(bounds[i]->id,bounds[j]->id);
-			}
-			j++;
-		}
-		i++;
-	}
-}
-
-YADE_PLUGIN((PersistentSAPCollider));

Deleted: trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.hpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.hpp	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.hpp	2009-08-14 06:59:23 UTC (rev 1941)
@@ -1,115 +0,0 @@
-/*************************************************************************
-*  Copyright (C) 2004 by Olivier Galizzi                                 *
-*  olivier.galizzi@xxxxxxx                                               *
-*                                                                        *
-*  This program is free software; it is licensed under the terms of the  *
-*  GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
-
-#pragma once
-
-#error PersistentSAPCollider is forbidden
-
-#include<yade/core/Collider.hpp>
-#include<yade/core/InteractionContainer.hpp>
-#include <list>
-#include <set>
-#include <vector>
-#include <algorithm>
-
-using namespace std;
-
-class PersistentSAPCollider : public Collider
-{
-	private :
-		// represent an extrmity of an Axis ALigned bounding box
-		struct AABBBound
-		{
-			AABBBound(int i, char l) : id(i),lower(l) {};
-			int		id;		// AABB of the "id" shpere
-			char		lower;		// is it the lower or upper bound of the AABB
-			Real		value;		// value of the bound
-		};
-		// strucuture that compare 2 AABBBounds => used in the sort algorithm
-		struct AABBBoundComparator
-		{
-			bool operator() (shared_ptr<AABBBound> b1, shared_ptr<AABBBound> b2)
-			{
-				return b1->value<b2->value;
-			}
-		};
-
-		MetaBody* rootBody; // refreshed at every iteration; to avoid passing it to called members on stack
-
-	protected :
-		/// number of potential transientInteractions = number of interacting AABB
-		int nbPotentialInteractions;
-
-		/// number of AABB
-		unsigned int nbObjects;
-
-		/// AABB extremity of the sphere number "id" projected onto the X axis
-		vector<shared_ptr<AABBBound> > xBounds;
-
-		/// AABB extremity of the sphere number "id" projected onto the Y axis
-		vector<shared_ptr<AABBBound> > yBounds;
-
-		/// AABB extremity of the sphere number "id" projected onto the Z axis
-		vector<shared_ptr<AABBBound> > zBounds;
-
-		// collection of AABB that are in interaction
-		//protected : vector< set<unsigned int> > overlappingBB;
-		shared_ptr<InteractionContainer> transientInteractions;
-		/// upper right corner of the AABB of the objects =>  for spheres = center[i]-radius
-		vector<Real> maxima;
-
-		/// lower left corner of the AABB of the objects =>  for spheres = center[i]+radius
-		vector<Real> minima;
-
-		/// Used the first time broadInteractionTest is called, to initialize and sort the xBounds, yBounds,
-		/// and zBounds arrays and to initialize the overlappingBB collection
-		void updateIds(unsigned int nbElements);
-
-		/// Permutation sort the xBounds, yBounds, zBounds arrays according to the "value" field
-		/// Calls updateOverlapingBBSet every time a permutation between 2 AABB i and j occurs
-		void sortBounds(vector<shared_ptr<AABBBound> >& bounds, int nbElements);
-
-		/// Tests if the AABBi and AABBj really overlap.
-		/// If yes, adds the pair (id1,id2) to the collection of overlapping AABBs
-		/// If no, removes the (id1,id2) to the collection of overlapping AABBs if necessary
-		void updateOverlapingBBSet(int id1,int id2);
-
-		/// update the "value" field of the xBounds, yBounds, zBounds arrays
-		void updateBounds(int nbElements);
-
-		/// Used the first time broadInteractionTest is called
-		/// It is necessary to initialise the overlapping AABB collection because this collection is only
-		/// incrementally udated each time step
-		void findOverlappingBB(vector<shared_ptr<AABBBound> >& bounds, int nbElements);
-
-	public :
-		PersistentSAPCollider();
-
-		virtual ~PersistentSAPCollider();
-
-		/// return a list "transientInteractions" of pairs of Body which Bounding volume are in potential interaction
-		void action(MetaBody *);
-
-		/// return true if BoundingVolume is in potential interaction
-		bool probeBoundingVolume(const BoundingVolume& bv);
-
-		//! Don't break transient interaction once bodies don't overlap anymore; material law will be responsible for breaking it.
-		bool haveDistantTransient;
-
-		bool shouldBeErased(body_id_t, body_id_t) const;
-
-	REGISTER_ATTRIBUTES(Collider,(haveDistantTransient));
-	DECLARE_LOGGER;
-	REGISTER_CLASS_NAME(PersistentSAPCollider);
-	REGISTER_BASE_CLASS_NAME(Collider);
-
-};
-
-REGISTER_SERIALIZABLE(PersistentSAPCollider);
-
-

Added: trunk/scripts/test/pack-cloud.py
===================================================================
--- trunk/scripts/test/pack-cloud.py	2009-08-13 09:01:41 UTC (rev 1940)
+++ trunk/scripts/test/pack-cloud.py	2009-08-14 06:59:23 UTC (rev 1941)
@@ -0,0 +1,10 @@
+""" Generate random periodic sphere packing using SpherePack::makeCloud """
+from yade import pack
+p=pack.SpherePack()
+O.periodicCell=(0,0,0),(10,10,10)
+print p.makeCloud(O.periodicCell[0],O.periodicCell[1],.5,.5,1200,True)
+for s in p:
+	O.bodies.append(utils.sphere(s[0],s[1]))
+O.runEngine(BoundingVolumeMetaEngine([InteractingSphere2AABB()]))
+from yade import qt
+qt.View()