← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3818: Fix some formatting issues.

 

------------------------------------------------------------
revno: 3818
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Thu 2016-03-24 23:08:26 +0100
message:
  Fix some formatting issues.
modified:
  pkg/dem/Polyhedra.cpp
  pkg/dem/Polyhedra.hpp
  pkg/dem/Polyhedra_Ig2.cpp
  pkg/dem/Polyhedra_Ig2.hpp
  pkg/dem/Polyhedra_splitter.cpp
  pkg/dem/Polyhedra_splitter.hpp


--
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 'pkg/dem/Polyhedra.cpp'
--- pkg/dem/Polyhedra.cpp	2016-03-24 22:08:07 +0000
+++ pkg/dem/Polyhedra.cpp	2016-03-24 22:08:26 +0000
@@ -3,11 +3,8 @@
 
 #ifdef YADE_CGAL
 
-#include <pkg/common/ElastMat.hpp>
 #include "Polyhedra.hpp"
 
-#define _USE_MATH_DEFINES
-
 YADE_PLUGIN(/* self-contained in hpp: */ (Polyhedra) (PolyhedraGeom) (Bo1_Polyhedra_Aabb) (PolyhedraPhys) (PolyhedraMat) (Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys) (Ip2_FrictMat_PolyhedraMat_FrictPhys) (Law2_PolyhedraGeom_PolyhedraPhys_Volumetric)
 	/* some code in cpp (this file): */ 
 	#ifdef YADE_OPENGL
@@ -19,9 +16,7 @@
 /* Polyhedra Constructor */
 
 void Polyhedra::Initialize(){
-
 	if (init) return;
-
 	bool isRandom = false;
 	
 	//get vertices
@@ -139,7 +134,6 @@
 		I_rot(1,2) = third[1];
 		I_rot(2,2) = third[2];
 		
-		
 		inertia = Vector3r(I_new(0,0),I_new(1,1),I_new(2,2));
 		orientation = Quaternionr(I_rot); 
 		//rotate the voronoi cell so that x - is maximal inertia axis and z - is minimal inertia axis
@@ -150,9 +144,11 @@
 		
 		//rotate also the CGAL structure Polyhedron
 		Matrix3r rot_mat = (orientation.conjugate()).toRotationMatrix();
-		Transformation t_rot(rot_mat(0,0),rot_mat(0,1),rot_mat(0,2),rot_mat(1,0),rot_mat(1,1),rot_mat(1,2),rot_mat(2,0),rot_mat(2,1),rot_mat(2,2),1.);	
+		Transformation t_rot(
+			rot_mat(0,0),rot_mat(0,1),rot_mat(0,2),
+			rot_mat(1,0),rot_mat(1,1),rot_mat(1,2),
+			rot_mat(2,0),rot_mat(2,1),rot_mat(2,2),1.);
 		std::transform( P.points_begin(), P.points_end(), P.points_begin(), t_rot);
-
 	}
 	//initialization done
 	init = 1;
@@ -248,7 +244,7 @@
 	Aabb* aabb=static_cast<Aabb*>(bv.get());
 	//Quaternionr invRot=se3.orientation.conjugate();
 	int N = (int) t->v.size();
-	Vector3r v_g, mincoords(0.,0.,0.), maxcoords(0.,0.,0.);		
+	Vector3r v_g, mincoords(0.,0.,0.), maxcoords(0.,0.,0.);
 	for(int i=0; i<N; i++) {
 		v_g=se3.orientation*t->v[i]; // vertices in global coordinates
 		mincoords = Vector3r(min(mincoords[0],v_g[0]),min(mincoords[1],v_g[1]),min(mincoords[2],v_g[2]));
@@ -292,11 +288,10 @@
 		}
 	}
 
-
-	void Gl1_PolyhedraGeom::go(const shared_ptr<IGeom>& ig, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool){ draw(ig);}
-
-	void Gl1_PolyhedraGeom::draw(const shared_ptr<IGeom>& ig){		
-	};
+	void Gl1_PolyhedraGeom::go(const shared_ptr<IGeom>& ig, const shared_ptr<Interaction>&,
+		const shared_ptr<Body>&, const shared_ptr<Body>&, bool) {draw(ig);}
+
+	void Gl1_PolyhedraGeom::draw(const shared_ptr<IGeom>& ig){};
 
 	GLUquadric* Gl1_PolyhedraPhys::gluQuadric=NULL;
 	Real Gl1_PolyhedraPhys::maxFn;
@@ -306,8 +301,12 @@
 	int Gl1_PolyhedraPhys::slices;
 	int Gl1_PolyhedraPhys::stacks;
 
-	void Gl1_PolyhedraPhys::go(const shared_ptr<IPhys>& ip, const shared_ptr<Interaction>& i, const shared_ptr<Body>& b1, const shared_ptr<Body>& b2, bool wireFrame){
-		if(!gluQuadric){ gluQuadric=gluNewQuadric(); if(!gluQuadric) throw runtime_error("Gl1_PolyhedraPhys::go unable to allocate new GLUquadric object (out of memory?)."); }
+	void Gl1_PolyhedraPhys::go(const shared_ptr<IPhys>& ip, const shared_ptr<Interaction>& i,
+		const shared_ptr<Body>& b1, const shared_ptr<Body>& b2, bool wireFrame){
+		if(!gluQuadric){
+			gluQuadric=gluNewQuadric();
+			if(!gluQuadric) throw runtime_error("Gl1_PolyhedraPhys::go unable to allocate new GLUquadric object (out of memory?).");
+		}
 		PolyhedraPhys* np=static_cast<PolyhedraPhys*>(ip.get());
 		shared_ptr<IGeom> ig(i->geom); if(!ig) return; // changed meanwhile?
 		PolyhedraGeom* geom=YADE_CAST<PolyhedraGeom*>(ig.get());
@@ -331,7 +330,7 @@
 		Vector3r relPos;
 		relPos=p2-p1;
 		Real dist=relPos.norm();
-				
+		
 		glDisable(GL_CULL_FACE); 
 		glPushMatrix();
 			glTranslatef(p1[0],p1[1],p1[2]);
@@ -348,8 +347,8 @@
 //**********************************************************************************
 //!Precompute data needed for rotating tangent vectors attached to the interaction
 
-void PolyhedraGeom::precompute(const State& rbp1, const State& rbp2, const Scene* scene, const shared_ptr<Interaction>& c, const Vector3r& 
-currentNormal, bool isNew, const Vector3r& shift2){
+void PolyhedraGeom::precompute(const State& rbp1, const State& rbp2, const Scene* scene,
+	const shared_ptr<Interaction>& c, const Vector3r& currentNormal, bool isNew, const Vector3r& shift2) {
 	
 	if(!isNew) {
 		orthonormal_axis = normal.cross(currentNormal);
@@ -377,14 +376,12 @@
 	return shearForce;
 }
 
-
 //**********************************************************************************
 /* Material law, physics */
 
 void Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys::go( const shared_ptr<Material>& b1
 					, const shared_ptr<Material>& b2
-					, const shared_ptr<Interaction>& interaction)
-{
+					, const shared_ptr<Interaction>& interaction) {
 	if(interaction->phys) return;
 	const shared_ptr<PolyhedraMat>& mat1 = YADE_PTR_CAST<PolyhedraMat>(b1);
 	const shared_ptr<PolyhedraMat>& mat2 = YADE_PTR_CAST<PolyhedraMat>(b2);
@@ -407,7 +404,6 @@
 }
 
 //**************************************************************************************
-#if 1
 Real Law2_PolyhedraGeom_PolyhedraPhys_Volumetric::getPlasticDissipation() {return (Real) plasticDissipation;}
 void Law2_PolyhedraGeom_PolyhedraPhys_Volumetric::initPlasticDissipation(Real initVal) {plasticDissipation.reset(); plasticDissipation+=initVal;}
 Real Law2_PolyhedraGeom_PolyhedraPhys_Volumetric::elasticEnergy()
@@ -421,13 +417,10 @@
 	}
 	return energy;
 }
-#endif
-
 
 //**************************************************************************************
 // Apply forces on polyhedrons in collision based on geometric configuration
 bool Law2_PolyhedraGeom_PolyhedraPhys_Volumetric::go(shared_ptr<IGeom>& ig, shared_ptr<IPhys>& ip, Interaction* I){
-
 		if (!I->geom) {return true;} 
 		const shared_ptr<PolyhedraGeom>& contactGeom(YADE_PTR_DYN_CAST<PolyhedraGeom>(I->geom));
 		if(!contactGeom) {return true;} 

=== modified file 'pkg/dem/Polyhedra.hpp'
--- pkg/dem/Polyhedra.hpp	2016-03-24 22:08:07 +0000
+++ pkg/dem/Polyhedra.hpp	2016-03-24 22:08:26 +0000
@@ -1,7 +1,6 @@
 // © 2013 Jan Elias, http://www.fce.vutbr.cz/STM/elias.j/, elias.j@xxxxxxxxxxxx
 // https://www.vutbr.cz/www_base/gigadisk.php?i=95194aa9a
 
-
 #pragma once
 
 #ifdef YADE_CGAL
@@ -14,7 +13,9 @@
 #include <pkg/dem/FrictPhys.hpp>
 #include <pkg/common/Wall.hpp>
 #include <pkg/common/Facet.hpp>
+#include <pkg/common/Sphere.hpp>
 #include <pkg/common/Dispatching.hpp>
+#include <pkg/common/ElastMat.hpp>
 
 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
 #include <CGAL/Delaunay_triangulation_3.h>

=== modified file 'pkg/dem/Polyhedra_Ig2.cpp'
--- pkg/dem/Polyhedra_Ig2.cpp	2016-03-24 22:08:07 +0000
+++ pkg/dem/Polyhedra_Ig2.cpp	2016-03-24 22:08:26 +0000
@@ -3,11 +3,8 @@
 
 #ifdef YADE_CGAL
 
-#include "Polyhedra.hpp"
 #include "Polyhedra_Ig2.hpp"
 
-#define _USE_MATH_DEFINES
-
 YADE_PLUGIN(/* self-contained in hpp: */ (Ig2_Polyhedra_Polyhedra_PolyhedraGeom) (Ig2_Wall_Polyhedra_PolyhedraGeom) (Ig2_Facet_Polyhedra_PolyhedraGeom) (Ig2_Sphere_Polyhedra_ScGeom) );
 
 //**********************************************************************************
@@ -84,8 +81,8 @@
 	//calculate area of projection of Intersection into the normal plane
 	//Real area = CalculateProjectionArea(Int, ToCGALVector(normal));
 	//if(isnan(area) || area<=1E-20) {bang->equivalentPenetrationDepth=0; return true;}
-        //Real area = volume/1E-8;
-        Real area = std::pow(volume,2./3.);
+	//Real area = volume/1E-8;
+	Real area = std::pow(volume,2./3.);
 	// store calculated stuff in bang; some is redundant
 	bang->equivalentCrossSection=area;
 	bang->contactPoint=centroid;
@@ -104,14 +101,27 @@
 	PrintPolyhedron2File(Int,fin);
 	fclose(fin);
 	*/
-	return true;	
+	return true;
 }
 
 //**********************************************************************************
+
+bool Ig2_Polyhedra_Polyhedra_PolyhedraGeom::goReverse(
+		const shared_ptr<Shape>& shape1,
+		const shared_ptr<Shape>& shape2,
+		const State& state1,
+		const State& state2,
+		const Vector3r& shift2,
+		const bool& force,
+		const shared_ptr<Interaction>& c) {
+			return go(shape1,shape2,state2,state1,-shift2,force,c);
+		}
+//**********************************************************************************
 /*! Create Polyhedra (collision geometry) from colliding Polyhedron and Wall. */
 
-bool Ig2_Wall_Polyhedra_PolyhedraGeom::go(const shared_ptr<Shape>& shape1,const shared_ptr<Shape>& shape2,const State& state1,const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& interaction){
-
+bool Ig2_Wall_Polyhedra_PolyhedraGeom::go(const shared_ptr<Shape>& shape1,const shared_ptr<Shape>& shape2,
+		const State& state1,const State& state2, const Vector3r& shift2, const bool& force,
+		const shared_ptr<Interaction>& interaction) {
 	const int& PA(shape1->cast<Wall>().axis); 
 	const int& sense(shape1->cast<Wall>().sense);
 	const Se3r& se31=state1.se3; const Se3r& se32=state2.se3;	
@@ -137,7 +147,7 @@
 		if (dot<1) { normal[PA] = -1; }
 	}
 	CGALvector CGALnormal = CGALvector(normal[0],normal[1],normal[2]);
-        Plane A = Plane(CGALpoint(se31.position[0],se31.position[1],se31.position[2]),CGALvector(normal[0],normal[1],normal[2]));
+	Plane A = Plane(CGALpoint(se31.position[0],se31.position[1],se31.position[2]),CGALvector(normal[0],normal[1],normal[2]));
 
 	shared_ptr<PolyhedraGeom> bang;
 	if (isNew) {
@@ -146,9 +156,9 @@
 		bang->contactPoint = Vector3r(0,0,0);
 		bang->isShearNew = true;
 		interaction->geom = bang;
-	}else{	
+	}else{
 		// use data from old interaction
-  		bang=YADE_PTR_CAST<PolyhedraGeom>(interaction->geom);
+		bang=YADE_PTR_CAST<PolyhedraGeom>(interaction->geom);
 		bang->isShearNew = bang->equivalentPenetrationDepth<=0;
 	}
 
@@ -158,13 +168,13 @@
 
 	//volume and centroid of intersection
 	Real volume;
-	Vector3r centroid;	
+	Vector3r centroid;
 	P_volume_centroid(Int, &volume, &centroid);
 	if(isnan(volume) || volume<=1E-25 || volume > B->GetVolume())  {bang->equivalentPenetrationDepth=0; return true;}
 	if (!Is_inside_Polyhedron(PB, ToCGALPoint(centroid)))  {bang->equivalentPenetrationDepth=0; return true;}
 
 	//calculate area of projection of Intersection into the normal plane
-        Real area = volume/1E-8;
+	Real area = volume/1E-8;
 	//Real area = CalculateProjectionArea(Int, CGALnormal);
 	//if(isnan(area) || area<=1E-20) {bang->equivalentPenetrationDepth=0; return true;}
 
@@ -214,7 +224,7 @@
 	//chage normal + change order of vertices to get outwarding facet normal for initial tetrahedron
  	if ((ToCGALPoint(se32.position)-f_center)*(f_normal) < 0) {
 		f_normal = (-1)*f_normal;
-  		CGALpoint help;
+		CGALpoint help;
 		help = v[0];
 		v[0]=v[1];
 		v[1]=help;

=== modified file 'pkg/dem/Polyhedra_Ig2.hpp'
--- pkg/dem/Polyhedra_Ig2.hpp	2016-03-08 09:18:20 +0000
+++ pkg/dem/Polyhedra_Ig2.hpp	2016-03-24 22:08:26 +0000
@@ -3,8 +3,7 @@
 
 #ifdef YADE_CGAL
 
-#include"Polyhedra.hpp"
-#include<pkg/common/Sphere.hpp>
+#include "Polyhedra.hpp"
 
 //***************************************************************************
 /*! Create Polyhedra (collision geometry) from colliding Polyhedras. */
@@ -12,13 +11,14 @@
 {
 	public:
 		virtual ~Ig2_Polyhedra_Polyhedra_PolyhedraGeom(){};
-		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
-		virtual bool goReverse(	const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c) { return go(shape1,shape2,state2,state1,-shift2,force,c); }
+		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1,
+			const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
+		virtual bool goReverse(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1,
+			const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
 		FUNCTOR2D(Polyhedra,Polyhedra);
 		DEFINE_FUNCTOR_ORDER_2D(Polyhedra,Polyhedra);
 		YADE_CLASS_BASE_DOC(Ig2_Polyhedra_Polyhedra_PolyhedraGeom,IGeomFunctor,"Create/update geometry of collision between 2 Polyhedras");	
-		DECLARE_LOGGER;	
-	private:
+		DECLARE_LOGGER;
 };
 REGISTER_SERIALIZABLE(Ig2_Polyhedra_Polyhedra_PolyhedraGeom);
 
@@ -28,12 +28,12 @@
 {
 	public:
 		virtual ~Ig2_Wall_Polyhedra_PolyhedraGeom(){};
-		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
+		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1,
+			const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
 		FUNCTOR2D(Wall,Polyhedra);
 		DEFINE_FUNCTOR_ORDER_2D(Wall,Polyhedra);
 		YADE_CLASS_BASE_DOC(Ig2_Wall_Polyhedra_PolyhedraGeom,IGeomFunctor,"Create/update geometry of collision between Wall and Polyhedra");	
-		DECLARE_LOGGER;	
-	private:		
+		DECLARE_LOGGER;
 };
 REGISTER_SERIALIZABLE(Ig2_Wall_Polyhedra_PolyhedraGeom);
 
@@ -43,12 +43,12 @@
 {
 	public:
 		virtual ~Ig2_Facet_Polyhedra_PolyhedraGeom(){};
-		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
+		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1,
+			const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
 		FUNCTOR2D(Facet,Polyhedra);
 		DEFINE_FUNCTOR_ORDER_2D(Facet,Polyhedra);
 		YADE_CLASS_BASE_DOC(Ig2_Facet_Polyhedra_PolyhedraGeom,IGeomFunctor,"Create/update geometry of collision between Facet and Polyhedra");	
-		DECLARE_LOGGER;	
-	private:		
+		DECLARE_LOGGER;
 };
 REGISTER_SERIALIZABLE(Ig2_Facet_Polyhedra_PolyhedraGeom);
 
@@ -59,15 +59,15 @@
 	public:
 		enum PointTriangleRelation { inside, edge, vertex, none };
 		virtual ~Ig2_Sphere_Polyhedra_ScGeom(){};
-		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
+		virtual bool go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1,
+			const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& c);
 		FUNCTOR2D(Sphere,Polyhedra);
 		DEFINE_FUNCTOR_ORDER_2D(Sphere,Polyhedra);
 		YADE_CLASS_BASE_DOC_ATTRS(Ig2_Sphere_Polyhedra_ScGeom,IGeomFunctor,"Create/update geometry of collision between Sphere and Polyhedra",
 			((Real,edgeCoeff,1.0,,"multiplier of penetrationDepth when sphere contacts edge (simulating smaller volume of actual intersection or when several polyhedrons has common edge)"))
 			((Real,vertexCoeff,1.0,,"multiplier of penetrationDepth when sphere contacts vertex (simulating smaller volume of actual intersection or when several polyhedrons has common vertex)"))
-		);	
-		DECLARE_LOGGER;	
-	private:
+		);
+		DECLARE_LOGGER;
 };
 REGISTER_SERIALIZABLE(Ig2_Sphere_Polyhedra_ScGeom);
 

=== modified file 'pkg/dem/Polyhedra_splitter.cpp'
--- pkg/dem/Polyhedra_splitter.cpp	2016-03-24 22:07:41 +0000
+++ pkg/dem/Polyhedra_splitter.cpp	2016-03-24 22:08:26 +0000
@@ -3,8 +3,7 @@
 
 #ifdef YADE_CGAL
 
-#include<pkg/dem/Polyhedra_splitter.hpp>
-
+#include <pkg/dem/Polyhedra_splitter.hpp>
 
 YADE_PLUGIN((PolyhedraSplitter));
 CREATE_LOGGER(PolyhedraSplitter);
@@ -53,14 +52,12 @@
 //**********************************************************************************
 //split polyhedra
 void SplitPolyhedraDouble(const shared_ptr<Body>& body, Vector3r direction1, Vector3r direction2){
-
 	const Se3r& se3=body->state->se3; 
 	Vector3r point = se3.position;
 
 	shared_ptr<Body> B2 = SplitPolyhedra(body, direction1, point);
 	shared_ptr<Body> B3 = SplitPolyhedra(B2, direction2, point);
 	shared_ptr<Body> B4 = SplitPolyhedra(body, direction2, point);
-
 }
 
 
@@ -76,8 +73,6 @@
 	vector<Vector3r > directions1, directions2;
 	vector<double > sigmas;
 
-
-
 	vector<Matrix3r> bStresses;
 	getStressForEachBody(bStresses);
 

=== modified file 'pkg/dem/Polyhedra_splitter.hpp'
--- pkg/dem/Polyhedra_splitter.hpp	2016-03-24 22:07:41 +0000
+++ pkg/dem/Polyhedra_splitter.hpp	2016-03-24 22:08:26 +0000
@@ -6,10 +6,8 @@
 
 #ifdef YADE_CGAL
 
-#include<pkg/common/PeriodicEngines.hpp>
-#include<core/Interaction.hpp>
-
-#include"Polyhedra.hpp"
+#include <pkg/common/PeriodicEngines.hpp>
+#include "Polyhedra.hpp"
 
 //*********************************************************************************
 /* Polyhedra Splitter */