← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3445: Merge github.com:yade/trunk into chaoUnsat

 

Merge authors:
  Anton Gladky (gladky-anton)
------------------------------------------------------------
revno: 3445 [merge]
committer: cyuan <chaoyuan2012@xxxxxxxxx>
timestamp: Thu 2014-07-17 15:41:45 +0800
message:
  Merge github.com:yade/trunk into chaoUnsat
modified:
  core/BodyContainer.cpp
  core/BodyContainer.hpp
  pkg/dem/VTKRecorder.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/BodyContainer.cpp'
--- core/BodyContainer.cpp	2014-05-21 12:37:11 +0000
+++ core/BodyContainer.cpp	2014-07-17 06:34:00 +0000
@@ -10,51 +10,25 @@
 
 
 CREATE_LOGGER(BodyContainer);
- 
-BodyContainer::BodyContainer(): lowestFree(0)
-{}
-
-
-BodyContainer::~BodyContainer(){}
 
 void BodyContainer::clear(){
-	body.clear(); lowestFree=0;
-}
-
-Body::id_t BodyContainer::findFreeId(){
-	Body::id_t max=body.size();
-	for(; lowestFree<max; lowestFree++){
-		if(!(bool)body[lowestFree]) return lowestFree;
-	}
-	return body.size();
+	body.clear();
 }
 
 Body::id_t BodyContainer::insert(shared_ptr<Body>& b){
-	Body::id_t newId=findFreeId();
-	return insert(b,newId);
-}
-
-Body::id_t BodyContainer::insert(shared_ptr<Body>& b, Body::id_t id){
-	assert(id>=0);
-	if((size_t)id>=body.size()) body.resize(id+1);
-	
 	const shared_ptr<Scene>& scene=Omega::instance().getScene(); 
 	b->iterBorn=scene->iter;
 	b->timeBorn=scene->time;
-	b->id=id;
-	
+	b->id=body.size();
 	scene->doSort = true;
-	
-	body[id]=b;
-
+	body.push_back(b);
 	// Notify ForceContainer about new id
-	scene->forces.addMaxId(id);
-	return id;
+	scene->forces.addMaxId(b->id);
+	return b->id;
 }
 
 bool BodyContainer::erase(Body::id_t id, bool eraseClumpMembers){//default is false (as before)
-	if(!exists(id)) return false;
-	lowestFree=min(lowestFree,id);
+	if(!body[id]) return false;
 	
 	const shared_ptr<Body>& b=Body::byId(id);
 	
@@ -81,7 +55,7 @@
 	for(Body::MapId2IntrT::iterator it=b->intrs.begin(),end=b->intrs.end(); it!=end; ++it) {  //Iterate over all body's interactions
 		scene->interactions->requestErase((*it).second);
 	}
-	body[id]=shared_ptr<Body>();
+	body[id]=nullptr;
 	
 	return true;
 }

=== modified file 'core/BodyContainer.hpp'
--- core/BodyContainer.hpp	2014-07-03 17:20:40 +0000
+++ core/BodyContainer.hpp	2014-07-17 06:34:00 +0000
@@ -30,8 +30,6 @@
 		typedef std::vector<shared_ptr<Body> > ContainerT;
 		typedef std::map<Body::id_t,Se3r> MemberMap;
 		ContainerT body;
-		Body::id_t lowestFree;
-		Body::id_t findFreeId();
 	public:
 		friend class InteractionContainer;  // accesses the body vector directly
 		
@@ -50,25 +48,13 @@
 			smart_iterator(const ContainerT::iterator& source) {(*this)=source;}
 			smart_iterator(const smart_iterator& source) {(*this)=source; end=source.end;}
 		};
-
-// 		typedef ContainerT::iterator iterator;
-// 		typedef ContainerT::const_iterator const_iterator;
 		typedef smart_iterator iterator;
 		typedef const smart_iterator const_iterator;
 
-		BodyContainer();
-		virtual ~BodyContainer();
+		BodyContainer() {};
+		virtual ~BodyContainer() {};
 		Body::id_t insert(shared_ptr<Body>&);
-		Body::id_t insert(shared_ptr<Body>& b, Body::id_t id);
-	
-		// mimick some STL api
 		void clear();
-		// by using simple vector<>::iterator's, we can hit null bodies 
-// 		iterator begin() { return body.begin(); }
-// 		iterator end() { return body.end(); }
-// 		const_iterator begin() const { return body.begin(); }
-// 		const_iterator end() const { return body.end(); }
-// 		//with smart iterators
 		iterator begin() {
 			iterator temp(body.begin()); temp.end=body.end();
 			return (body.begin()==body.end() || *temp)?temp:++temp;}

=== modified file 'pkg/dem/VTKRecorder.cpp'
--- pkg/dem/VTKRecorder.cpp	2014-07-16 15:50:43 +0000
+++ pkg/dem/VTKRecorder.cpp	2014-07-17 06:53:17 +0000
@@ -857,11 +857,11 @@
 		std::ifstream file (fileCracks.c_str(),std::ios::in);
 		vtkSmartPointer<vtkUnstructuredGrid> crackUg = vtkSmartPointer<vtkUnstructuredGrid>::New();
 		
-		 if(file){
+		if(file){
 			 while ( !file.eof() ){
 				std::string line;
 				Real i,p0,p1,p2,t,s,n0,n1,n2;
-				while ( std::getline(file, line) {/* writes into string "line", a line of file "file". To go along diff. lines*/ ) 
+				while ( std::getline(file, line)) {/* writes into string "line", a line of file "file". To go along diff. lines*/
 					file >> i >> p0 >> p1 >> p2 >> t >> s >> n0 >> n1 >> n2;
 					vtkIdType pid[1];
 					pid[0] = crackPos->InsertNextPoint(p0, p1, p2);
@@ -870,8 +870,11 @@
 					crackSize->InsertNextValue(s);
 					iter->InsertNextValue(i);
 					Real n[3] = { n0, n1, n2 };
-					crackNorm->InsertNextTupleValue(n); } }
-			 file.close(); }
+					crackNorm->InsertNextTupleValue(n);
+				}
+			}
+			 file.close();
+		}
 // 
 		crackUg->SetPoints(crackPos);
 		crackUg->SetCells(VTK_VERTEX, crackCells);