← Back to team overview

yade-dev team mailing list archive

r954 - in trunk: yade-core/src/yade yade-guis/yade-gui-qt/src/QtGUI yade-packages/yade-package-common/src/Engine/DeusExMachina yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample yade-packages/yade-package-lattice/src/RenderingEngine/GLDrawLineSegment

 

Author: cosurgi
Date: 2005-11-18 20:35:09 +0100 (Fri, 18 Nov 2005)
New Revision: 954

Added:
   trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/
   trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.cpp
   trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.hpp
   trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.pro
Modified:
   trunk/yade-core/src/yade/NullGUI.cpp
   trunk/yade-core/src/yade/NullGUI.hpp
   trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.cpp
   trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.hpp
   trunk/yade-guis/yade-gui-qt/src/QtGUI/QGLThread.cpp
   trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DeusExMachina.pro
   trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.cpp
   trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.hpp
   trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.cpp
   trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.hpp
   trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.pro
   trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.cpp
   trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.hpp
   trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.pro
   trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.cpp
   trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.hpp
   trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.cpp
   trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.hpp
   trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.cpp
   trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.hpp
   trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.pro
   trunk/yade-packages/yade-package-lattice/src/RenderingEngine/GLDrawLineSegment/GLDrawLineSegment.cpp
Log:
I have just enabled commit-email.pl for SVN. we should get info about commits for yade-dev, I wonder it if works :)

- NullGUI can save to binary format
- graphical windows GLViewer displays a grid with cell size exacly 1 meter or 1 cm (depengind on the model size)
  previously that grid had some random size, which was totally useless
- added DisplacementEngine derived from DeuxExMachina - is like translation, but without velocity - purely kinematic displacement.
- disorder parameters in FileGenerators SDECSpheresPlane and LatticeExample are now Vector3r, so that we can
  specify different randomness in each direction. This is useful for flat 2D simulations
- major improvements to lattice model (rod model is working)


M    yade-guis/yade-gui-qt/src/QtGUI/GLViewer.cpp
M    yade-guis/yade-gui-qt/src/QtGUI/GLViewer.hpp
M    yade-guis/yade-gui-qt/src/QtGUI/QGLThread.cpp
M    yade-core/src/yade/NullGUI.hpp
M    yade-core/src/yade/NullGUI.cpp
M    yade-packages/yade-package-common/src/Engine/DeusExMachina/DeusExMachina.pro
A    yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine
A    yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.cpp
A    yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.hpp
A    yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.pro
M    yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.cpp
M    yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.hpp
M    yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.cpp
M    yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.hpp
M    yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.pro
M    yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.cpp
M    yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.hpp
M    yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.pro
M    yade-packages/yade-package-lattice/src/RenderingEngine/GLDrawLineSegment/GLDrawLineSegment.cpp
M    yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.cpp
M    yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.hpp
M    yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.hpp
M    yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.cpp
M    yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.pro
M    yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.cpp
M    yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.hpp


Modified: trunk/yade-core/src/yade/NullGUI.cpp
===================================================================
--- trunk/yade-core/src/yade/NullGUI.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-core/src/yade/NullGUI.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -21,6 +21,7 @@
 	snapshotInterval = -1;
 	snapshotName = "";
 	maxIteration = 0;
+	binary = 0;
 }
 
 
@@ -57,6 +58,7 @@
 	-m number	- specify maximum number of iterations\n\
 			  ( 0 = unlimited, tested every INTERVAL iteration).\n\
 	-t number	- set time step in seconds, default is 0.01 (FIXME - inside .xml)\n\
+	-b number	- save in binary .yade format instead of .xml\n\
 \n";
 //	-g number	- set gravity, default is 9.81 (FIXME - inside .xml)\n
 }
@@ -67,7 +69,7 @@
 
 	int ch;
 	opterr = 0;
-	while( ( ch = getopt(argc,argv,"Hf:s:S:v:pm:t:g:") ) != -1)
+	while( ( ch = getopt(argc,argv,"Hf:s:S:v:pm:t:g:b") ) != -1)
 		switch(ch)
 		{
 			case 'H'	: help(); 						return 1;
@@ -78,6 +80,7 @@
 			case 's'	: snapshotInterval = lexical_cast<int>(optarg);		break;
 			case 'S'	: snapshotName = optarg;				break;
 			case 'm'	: maxIteration = lexical_cast<long int>(optarg);	break;
+			case 'b'	: binary = true;	 				break;
 			case 't'	: Omega::instance().setTimeStep
 						(lexical_cast<Real>(optarg));			break;
 //			case 'g'	: Omega::instance().setGravity
@@ -127,11 +130,11 @@
 			{
 				// FIXME - call Omega::instance().saveSimulation(string);
 				shared_ptr<MetaBody> rootBody = Omega::instance().getRootBody();
-				IOFormatManager::saveToFile(	"XMLFormatManager",
-							"../data/" + snapshotName + "_" + lexical_cast<string>(Omega::instance().getCurrentIteration()) + ".xml",
+				IOFormatManager::saveToFile(	binary?"BINFormatManager":"XMLFormatManager",
+							"../data/" + snapshotName + "_" + lexical_cast<string>(Omega::instance().getCurrentIteration()) + (binary?".yade":".xml"),
 							"rootBody",
 							rootBody);
-				cerr << "saved snapshot: " << snapshotName + "_" + lexical_cast<string>(Omega::instance().getCurrentIteration()) + ".xml\n";
+				cerr << "saved snapshot: " << snapshotName + "_" + lexical_cast<string>(Omega::instance().getCurrentIteration()) + (binary?".yade\n":".xml\n");
 			}
 		}
 

Modified: trunk/yade-core/src/yade/NullGUI.hpp
===================================================================
--- trunk/yade-core/src/yade/NullGUI.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-core/src/yade/NullGUI.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -26,6 +26,7 @@
 				,snapshotInterval;
 
 		bool 		 progress;
+		bool 		 binary;
 		string		 snapshotName;
 		long int	 maxIteration;
 		

Modified: trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.cpp
===================================================================
--- trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -17,7 +17,7 @@
 
 GLViewer::GLViewer(int id, shared_ptr<RenderingEngine> renderer, const QGLFormat& format, QWidget * parent, QGLWidget * shareWidget) : QGLViewer(format,parent,"glview",shareWidget), qglThread(this,renderer)
 {
-
+	drawGrid = false;
 	viewId = id;
 	setAutoBufferSwap(false);
 	resize(320, 240);
@@ -137,9 +137,63 @@
 
 void GLViewer::keyPressEvent(QKeyEvent *e)
 {
-	if (e->key()=='F' || e->key()=='f')
-		wm.getWindow(0)->swapDisplayed();
-	else
+//	const Qt::ButtonState state = (Qt::ButtonState)(e->state() & Qt::KeyButtonMask);
+	
+	if ( e->key()==Qt::Key_F )
+		wm.getWindow(0)->swapDisplayed(); 
+	else if( e->key()==Qt::Key_G )
+//		if((state != Qt::ShiftButton)
+			drawGrid = !drawGrid;
+//		else
+//			scale = scale+1;
+	else if( e->key()!=Qt::Key_Escape )
 		QGLViewer::keyPressEvent(e);
 }
 
+void GLViewer::postDraw()
+{
+	if( drawGrid )
+	{
+//		glMatrixMode(GL_MODELVIEW);
+		glPushMatrix();
+		glPushAttrib(GL_ALL_ATTRIB_BITS);
+		qglColor(foregroundColor());
+		glDisable(GL_LIGHTING);
+		glLineWidth(0.1);
+		glBegin(GL_LINES);
+	
+		float sizef = QGLViewer::camera()->sceneRadius()*3.0f; 
+		int size = static_cast<int>(sizef);
+		qglviewer::Vec v = QGLViewer::camera()->sceneCenter();
+		int x = static_cast<int>(v[0]); int y = static_cast<int>(v[1]);
+		float xf = (static_cast<int>(v[0]*100.0))/100.0;
+		float yf = (static_cast<int>(v[1]*100.0))/100.0;
+//		float nbSubdivisions = size;
+//		for (int i=0; i<=nbSubdivisions; ++i)
+		for (int i= -size ; i<=size; ++i )
+		{
+//			const float pos = size*(2.0*i/nbSubdivisions-1.0);
+			glVertex2i( i   +x, -size+y);
+			glVertex2i( i   +x, +size+y);
+			glVertex2i(-size+x, i    +y);
+			glVertex2i( size+x, i    +y);
+		}
+		if(sizef <= 2.0)
+		{
+			glColor3f(0.9,0.9,0.9);
+			for (float i= -(static_cast<int>(sizef*100.0))/100.0 ; i<=sizef; i+=0.01 )
+			{
+				glVertex2f( i    +xf, -sizef+yf);
+				glVertex2f( i    +xf, +sizef+yf);
+				glVertex2f(-sizef+xf, i     +yf);
+				glVertex2f( sizef+xf, i     +yf);
+			}
+		}
+		
+		glEnd();
+		glPopAttrib();
+		glPopMatrix();
+	}
+	QGLViewer::postDraw();
+}
+

Modified: trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.hpp
===================================================================
--- trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-guis/yade-gui-qt/src/QtGUI/GLViewer.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -22,6 +22,7 @@
 		QGLThread		qglThread;
 		GLWindowsManager	wm;
 		int			viewId;
+		bool 			drawGrid;
 	
 	public :
 		GLViewer (int id, shared_ptr<RenderingEngine> renderer, const QGLFormat& format, QWidget * parent=0, QGLWidget * shareWidget=0);
@@ -44,6 +45,7 @@
 		void mouseReleaseEvent(QMouseEvent *e);
 		void keyPressEvent(QKeyEvent *e);
 		void mouseDoubleClickEvent(QMouseEvent *e);
+		void postDraw();
 	
 	public slots :
 		void updateGL();

Modified: trunk/yade-guis/yade-gui-qt/src/QtGUI/QGLThread.cpp
===================================================================
--- trunk/yade-guis/yade-gui-qt/src/QtGUI/QGLThread.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-guis/yade-gui-qt/src/QtGUI/QGLThread.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -112,7 +112,7 @@
 	glViewer->postDraw();
 
 	glViewer->swapBuffers();
-	glViewer->doneCurrent ();
+	glViewer->doneCurrent();
 
 }
 

Modified: trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DeusExMachina.pro
===================================================================
--- trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DeusExMachina.pro	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DeusExMachina.pro	2005-11-18 19:35:09 UTC (rev 954)
@@ -6,7 +6,8 @@
 SUBDIRS += ForceEngine \
            GravityEngine \
            RotationEngine \
-           TranslationEngine 
+           TranslationEngine \
+	   DisplacementEngine
 CONFIG += debug \
           thread \
 warn_on

Added: trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.cpp
===================================================================
--- trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -0,0 +1,54 @@
+/*************************************************************************
+*  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 "DisplacementEngine.hpp"
+#include <yade/yade-core/MetaBody.hpp>
+
+void DisplacementEngine::postProcessAttributes(bool deserializing)
+{
+	if(deserializing)
+		translationAxis.normalize();
+}
+
+
+void DisplacementEngine::registerAttributes()
+{
+	DeusExMachina::registerAttributes();
+	REGISTER_ATTRIBUTE(displacement);
+	REGISTER_ATTRIBUTE(translationAxis);
+}
+
+
+void DisplacementEngine::applyCondition(Body * body)
+{
+	MetaBody * ncb = static_cast<MetaBody*>(body);
+	shared_ptr<BodyContainer>& bodies = ncb->bodies;
+
+	std::vector<int>::const_iterator ii = subscribedBodies.begin();
+	std::vector<int>::const_iterator iiEnd = subscribedBodies.end();
+
+//
+// FIXME - we really need to set intervals for engines.
+//
+//	if(Omega::instance().getCurrentIteration() < 20)
+//	{
+	
+	
+	for(;ii!=iiEnd;++ii)
+		((*bodies)[*ii]->physicalParameters.get())->se3.position += displacement*translationAxis;
+		
+		
+//	}
+//	else
+//	{
+//	for(;ii!=iiEnd;++ii)
+//		((*bodies)[*ii])->isDynamic = true;
+//	}
+
+}
+

Added: trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.hpp
===================================================================
--- trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -0,0 +1,32 @@
+/*************************************************************************
+*  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. *
+*************************************************************************/
+
+#ifndef DISPLACEMENTENGINE_HPP
+#define DISPLACEMENTENGINE_HPP
+
+#include <yade/yade-core/DeusExMachina.hpp>
+#include <yade/yade-lib-wm3-math/Vector3.hpp>
+
+class DisplacementEngine : public DeusExMachina
+{
+	public :
+		Real displacement;
+		Vector3r translationAxis;
+		void applyCondition(Body * body);
+
+	protected :
+		virtual void postProcessAttributes(bool);
+		virtual void registerAttributes();
+	REGISTER_CLASS_NAME(DisplacementEngine);
+	REGISTER_BASE_CLASS_NAME(DeusExMachina);
+};
+
+REGISTER_SERIALIZABLE(DisplacementEngine,false);
+
+#endif //  DISPLACEMENTENGINE_HPP
+

Added: trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.pro
===================================================================
--- trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.pro	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-common/src/Engine/DeusExMachina/DisplacementEngine/DisplacementEngine.pro	2005-11-18 19:35:09 UTC (rev 954)
@@ -0,0 +1,25 @@
+isEmpty ( YADE_QMAKE_PATH ) {
+error( "YADE_QMAKE_PATH internal qmake variable is not set, you should run for example qmake YADE_QMAKE_PATH=/usr/local, this will not work from inside kdevelop (when they will fix it?)" )
+}
+
+
+LIBS += -lyade-lib-factory \
+        -lyade-lib-wm3-math \
+        -lyade-lib-serialization \
+        -lyade-lib-multimethods \
+        -rdynamic 
+INCLUDEPATH += $${YADE_QMAKE_PATH}/include/
+QMAKE_LIBDIR = ../../../../bin \
+               $${YADE_QMAKE_PATH}/lib/yade/yade-libs/ 
+QMAKE_CXXFLAGS_RELEASE += -lpthread \
+                          -pthread 
+QMAKE_CXXFLAGS_DEBUG += -lpthread \
+                        -pthread 
+DESTDIR = ../../../../bin 
+CONFIG += debug \
+          thread \
+          warn_on \
+          dll 
+TEMPLATE = lib 
+HEADERS += DisplacementEngine.hpp 
+SOURCES += DisplacementEngine.cpp 

Modified: trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.cpp
===================================================================
--- trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -69,7 +69,7 @@
 	density = 2600;
 	rotationBlocked = false;
 	gravity = Vector3r(0,-9.81,0);
-	disorder = 0.2;
+	disorder = Vector3r(0.2,0.2,0.2);
 	useSpheresAsGround = false;
 	spheresHeight = 0;
 }
@@ -225,7 +225,9 @@
 	
 	Vector3r position		= Vector3r(i,j+spheresHeight,k)*(2*maxRadius*1.1) // this formula is crazy !!
 					  - Vector3r( nbSpheres[0]/2*(2*maxRadius*1.1) , -7-maxRadius*2 , nbSpheres[2]/2*(2*maxRadius*1.1) )
-					  + Vector3r(Mathr::symmetricRandom(),Mathr::symmetricRandom(),Mathr::symmetricRandom())*disorder*maxRadius;
+					  + Vector3r( 	 Mathr::symmetricRandom()*disorder[0]
+					  		,Mathr::symmetricRandom()*disorder[1]
+							,Mathr::symmetricRandom()*disorder[2])*maxRadius;
 	
 	Real radius 			= (Mathr::intervalRandom(minRadius,maxRadius));
 	

Modified: trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.hpp
===================================================================
--- trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-dem/src/PreProcessor/SDECSpheresPlane/SDECSpheresPlane.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -15,6 +15,7 @@
 {
 	private :
 		Vector3r	 nbSpheres
+				,disorder
 				,groundSize
 				,gravity;
 
@@ -25,7 +26,6 @@
 				,density
 				,maxRadius
 				,dampingForce
-				,disorder
 				,dampingMomentum
 				,spheresHeight
 				,sphereYoungModulus

Modified: trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.cpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -9,7 +9,7 @@
 #include "LatticeBeamParameters.hpp"
 
 
-LatticeBeamParameters::LatticeBeamParameters() : RigidBodyParameters()
+LatticeBeamParameters::LatticeBeamParameters() : PhysicalParameters()
 {
 	createIndex();
 }
@@ -23,9 +23,21 @@
 
 void LatticeBeamParameters::registerAttributes()
 {
-	RigidBodyParameters::registerAttributes();
+	PhysicalParameters::registerAttributes();
 	REGISTER_ATTRIBUTE(id1);
 	REGISTER_ATTRIBUTE(id2);
+	
 	REGISTER_ATTRIBUTE(initialLength);
 	REGISTER_ATTRIBUTE(length);
+	
+	REGISTER_ATTRIBUTE(direction);
+	REGISTER_ATTRIBUTE(initialDirection);
+	
+	REGISTER_ATTRIBUTE(criticalTensileStrain);
+	REGISTER_ATTRIBUTE(criticalCompressiveStrain);
+	
+	REGISTER_ATTRIBUTE(longitudalStiffness);
+	REGISTER_ATTRIBUTE(bendingStiffness);
+	
+	REGISTER_ATTRIBUTE(previousSe3)
 }

Modified: trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.hpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -9,14 +9,27 @@
 #ifndef LATTICE_BEAM_PARAMETERS_HPP
 #define LATTICE_BEAM_PARAMETERS_HPP 
 
-#include <yade/yade-package-common/RigidBodyParameters.hpp>
+#include <yade/yade-core/PhysicalParameters.hpp>
 
-class LatticeBeamParameters : public RigidBodyParameters
+class LatticeBeamParameters : public PhysicalParameters 
 {
 	public :
-		unsigned int 	id1,id2;
-		Real  		initialLength,length;
-		Vector3r 	direction;
+		unsigned int 	 id1
+				,id2;
+				
+		Real  		 initialLength
+				,length;
+				
+		Vector3r 	 initialDirection
+				,direction;
+				
+		Real 		 criticalTensileStrain
+				,criticalCompressiveStrain
+				
+				,longitudalStiffness
+				,bendingStiffness;
+				
+		Se3r 		 previousSe3;
 	
 		LatticeBeamParameters();
 		virtual ~LatticeBeamParameters();
@@ -25,10 +38,10 @@
 	protected :
 		void registerAttributes();
 	REGISTER_CLASS_NAME(LatticeBeamParameters);
-	REGISTER_BASE_CLASS_NAME(RigidBodyParameters);
+	REGISTER_BASE_CLASS_NAME(PhysicalParameters);
 	
 /// Indexable
-	REGISTER_CLASS_INDEX(LatticeBeamParameters,RigidBodyParameters);
+	REGISTER_CLASS_INDEX(LatticeBeamParameters,PhysicalParameters);
 
 };
 

Modified: trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.pro
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.pro	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeBeamParameters/LatticeBeamParameters.pro	2005-11-18 19:35:09 UTC (rev 954)
@@ -3,13 +3,11 @@
 }
 
 
-LIBS += -lRigidBodyParameters \
-        -lyade-lib-wm3-math \
+LIBS += -lyade-lib-wm3-math \
         -lyade-lib-multimethods \
         -lyade-lib-serialization \
         -rdynamic 
-QMAKE_LIBDIR = $${YADE_QMAKE_PATH}/lib/yade/yade-package-common/ \
-               $${YADE_QMAKE_PATH}/lib/yade/yade-libs/ 
+QMAKE_LIBDIR = $${YADE_QMAKE_PATH}/lib/yade/yade-libs/ 
 QMAKE_CXXFLAGS_RELEASE += -lpthread \
                           -pthread 
 QMAKE_CXXFLAGS_DEBUG += -lpthread \

Modified: trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.cpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -8,7 +8,7 @@
 
 #include "LatticeNodeParameters.hpp"
 
-LatticeNodeParameters::LatticeNodeParameters() : RigidBodyParameters()
+LatticeNodeParameters::LatticeNodeParameters() : PhysicalParameters()
 {
 	createIndex();
 	
@@ -23,7 +23,6 @@
 
 void LatticeNodeParameters::registerAttributes()
 {
-	RigidBodyParameters::registerAttributes();
-//	REGISTER_ATTRIBUTE(length);
+	PhysicalParameters::registerAttributes();
 }
 

Modified: trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.hpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -9,13 +9,13 @@
 #ifndef LATTICE_NODE_PARAMETERS_HPP
 #define LATTICE_NODE_PARAMETERS_HPP 
 
-#include <yade/yade-package-common/RigidBodyParameters.hpp>
+#include <yade/yade-core/PhysicalParameters.hpp>
 
-class LatticeNodeParameters : public RigidBodyParameters
+class LatticeNodeParameters : public PhysicalParameters 
 {
 	public : 
-		Real count;
-		Vector3r displacement;
+		Real 		count;
+		Vector3r 	displacement;
 	
 		LatticeNodeParameters();
 		virtual ~LatticeNodeParameters();
@@ -24,10 +24,10 @@
 	protected :
 		void registerAttributes();
 	REGISTER_CLASS_NAME(LatticeNodeParameters);
-	REGISTER_BASE_CLASS_NAME(RigidBodyParameters);
+	REGISTER_BASE_CLASS_NAME(PhysicalParameters);
 	
 /// Indexable
-	REGISTER_CLASS_INDEX(LatticeNodeParameters,RigidBodyParameters);
+	REGISTER_CLASS_INDEX(LatticeNodeParameters,PhysicalParameters);
 
 };
 

Modified: trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.pro
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.pro	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/DataClass/PhysicalParameters/LatticeNodeParameters/LatticeNodeParameters.pro	2005-11-18 19:35:09 UTC (rev 954)
@@ -3,13 +3,11 @@
 }
 
 
-LIBS += -lRigidBodyParameters \
-        -lyade-lib-wm3-math \
+LIBS += -lyade-lib-wm3-math \
         -lyade-lib-multimethods \
         -lyade-lib-serialization \
         -rdynamic 
-QMAKE_LIBDIR = $${YADE_QMAKE_PATH}/lib/yade/yade-package-common/ \
-               $${YADE_QMAKE_PATH}/lib/yade/yade-libs/ 
+QMAKE_LIBDIR = $${YADE_QMAKE_PATH}/lib/yade/yade-libs/ 
 QMAKE_CXXFLAGS_RELEASE += -lpthread \
                           -pthread 
 QMAKE_CXXFLAGS_DEBUG += -lpthread \

Modified: trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.cpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -12,53 +12,56 @@
 #include "LineSegment.hpp"
 #include <yade/yade-core/MetaBody.hpp>
 
-void LatticeSet2LatticeBeams::calcBeamsPositionOrientationNewLength(shared_ptr<Body>& body, const shared_ptr<BodyContainer>& bodies)
-{
-
-// FIXME - this copying of length between latticeBeam geometry and physics, inside MetaBody could
-//         be done just once, if length was inside shared_ptr. This can be improved once we make
-//         indexable Parameters: Velocity, Position, Orientation, ....
-// FIXME - verify that this updating of length, position, orientation and color is in correct place/plugin
-
-	LineSegment* line 		= dynamic_cast<LineSegment*>		(body->geometricalModel.get());
-	LatticeBeamParameters* beam 	= dynamic_cast<LatticeBeamParameters*>  (body->physicalParameters.get());
-
-	shared_ptr<Body>& bodyA 	= (*(bodies))[beam->id1];
-	shared_ptr<Body>& bodyB 	= (*(bodies))[beam->id2];
-	Se3r& se3A 			= bodyA->physicalParameters->se3;
-	Se3r& se3B 			= bodyB->physicalParameters->se3;
-	
-	Se3r se3Beam;
-	se3Beam.position 		= (se3A.position + se3B.position)*0.5;
-	Vector3r dist 			= se3A.position - se3B.position;
-	
-	Real length 			= dist.normalize();
-	beam->direction 		= dist;
-	beam->length 			= length;
-	
-	se3Beam.orientation.align( Vector3r::UNIT_X , dist );
-	beam->se3 			= se3Beam;
-	
-	
-	line->length       		= beam->length;
-	line->diffuseColor 		= Vector3f(0.8,0.8,0.8) + ((beam->length / beam->initialLength)-1.0) * Vector3f(-1.0,0.0,1.0) * 10.0;
-
-}
-
 void LatticeSet2LatticeBeams::go(	  const shared_ptr<PhysicalParameters>& ph
 					, shared_ptr<GeometricalModel>& 
 					, const Body* body)
 {
-	int beamGroupMask = dynamic_cast<const LatticeSetParameters*>(ph.get())->beamGroupMask;
-	const MetaBody * ncb = dynamic_cast<const MetaBody*>(body);
+	int beamGroupMask = static_cast<const LatticeSetParameters*>(ph.get())->beamGroupMask;
+	const MetaBody * ncb = static_cast<const MetaBody*>(body);
 	const shared_ptr<BodyContainer>& bodies = ncb->bodies;
 
+	static Real maxTensileFactor = 0.0; // FIXME - thread unsafe
+	static Real maxCompressFactor = 0.0; // FIXME - thread unsafe
+
 	BodyContainer::iterator bi    = bodies->begin();
 	BodyContainer::iterator biEnd = bodies->end();
 	for(  ; bi!=biEnd ; ++bi )
 	{
-		shared_ptr<Body> b = *bi;	
+		Body* b = (*bi).get();
 		if( b->getGroupMask() & beamGroupMask )
-			calcBeamsPositionOrientationNewLength(b,bodies);
+		{
+			LineSegment* line 		= static_cast<LineSegment*>	     (b->geometricalModel.get());
+			LatticeBeamParameters* beam 	= static_cast<LatticeBeamParameters*>(b->physicalParameters.get());
+
+// FIXME - this copying of length between latticeBeam geometry and physics, inside MetaBody could
+//         be done just once, if length was inside shared_ptr. This can be improved once we make
+//         indexable Parameters: Velocity, Position, Orientation, ....
+			Real strain 			= (beam->length - beam->initialLength) / beam->initialLength;
+			Real factor;
+			if( strain > 0 ) // FIXME - strain is a property of beam
+				factor 			= strain / beam->criticalTensileStrain; // positive
+			else
+				factor 			= strain / beam->criticalCompressiveStrain; // negative
+			
+			} // compute optimal red/blue colors	
+				maxTensileFactor		= std::max(factor,maxTensileFactor);
+				maxCompressFactor 		= std::min(factor,maxCompressFactor);
+				if(factor > 0 && maxTensileFactor > 0)
+				{
+					factor 			/= maxTensileFactor;
+					line->diffuseColor 	= Vector3f(0.9,0.9,1.0) - factor * Vector3f(0.9,0.9,0.0);
+				}
+				else if (factor < 0 && maxCompressFactor < 0)
+				{
+					factor 			/= maxCompressFactor;
+					line->diffuseColor 	= Vector3f(1.0,0.9,0.9) - factor * Vector3f(0.0,0.9,0.9);
+				}
+				else
+					line->diffuseColor 	= Vector3f(0.9,0.9,0.9);
+			}
+		
+			line->length       		= beam->length;
+		}
 	}
 }
+

Modified: trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.hpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/Engine/EngineUnit/LatticeSet2LatticeBeams/LatticeSet2LatticeBeams.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -16,9 +16,6 @@
 
 class LatticeSet2LatticeBeams : public GeometricalModelEngineUnit
 {
-	private :
-		void calcBeamsPositionOrientationNewLength(shared_ptr<Body>& body, const shared_ptr<BodyContainer>& bodies);
-
 	public : 
 		void go(	  const shared_ptr<PhysicalParameters>&
 				, shared_ptr<GeometricalModel>&

Modified: trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.cpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -13,13 +13,31 @@
 #include <yade/yade-core/BodyContainer.hpp>
 #include <yade/yade-core/MetaBody.hpp>
 
+/*
+	LatticeBeamParameters 
+	
+		unsigned int 	 id1
+				,id2;
+				
+		Real  		 initialLength
+				,length;
+				
+		Vector3r 	 initialDirection
+				,direction;
+				
+		Real 		 criticalTensileStrain
+				,criticalCompressiveStrain
+				
+				,longitudalStiffness
+				,bendingStiffness;
+		
+		Vector3r 	 previousSe3;
+*/
 
 LatticeLaw::LatticeLaw() : InteractionSolver() , actionForce(new Force)
 {
 	nodeGroupMask = 1;
 	beamGroupMask = 2;
-	
-	maxDispl     = 0.0004;
 }
 
 
@@ -34,73 +52,107 @@
 	InteractionSolver::registerAttributes();
 	REGISTER_ATTRIBUTE(nodeGroupMask);
 	REGISTER_ATTRIBUTE(beamGroupMask);
-	REGISTER_ATTRIBUTE(maxDispl);
 }
 
+bool LatticeLaw::deleteBeam(MetaBody* metaBody , LatticeBeamParameters* beam , Real stretch)
+{
+	Real strain = stretch / beam->initialLength;
+	return 	   strain < -beam->criticalCompressiveStrain
+		|| strain >  beam->criticalTensileStrain;
+}
 
+
+void LatticeLaw::calcBeamsPositionOrientationNewLength(Body* body, BodyContainer* bodies)
+{
+// FIXME - verify that this updating of length, position, orientation and color is in correct place/plugin
+	LatticeBeamParameters* beam 	= static_cast<LatticeBeamParameters*>(body->physicalParameters.get());
+
+//	cerr << "beam: " << body->getId() << "id1: " << beam->id1 << " id2: " << beam->id2 << "\n";
+	Body* bodyA 			= (*(bodies))[beam->id1].get();
+	Body* bodyB 			= (*(bodies))[beam->id2].get();
+	Se3r& se3A 			= bodyA->physicalParameters->se3;
+	Se3r& se3B 			= bodyB->physicalParameters->se3;
+	
+	Se3r se3Beam;
+	se3Beam.position 		= (se3A.position + se3B.position)*0.5;
+	Vector3r dist 			= se3A.position - se3B.position;
+	
+	Real length 			= dist.normalize();
+	beam->direction 		= dist;
+	beam->length 			= length;
+	
+	beam->previousSe3 		= beam->se3;
+	se3Beam.orientation.align( Vector3r::UNIT_X , dist );
+	beam->se3 			= se3Beam;
+}
+
 void LatticeLaw::action(Body* body)
 {
+	futureDeletes.clear();
 
 	MetaBody * lattice = static_cast<MetaBody*>(body);
-	shared_ptr<BodyContainer>& bodies = lattice->bodies;
-	shared_ptr<PhysicalActionContainer>& actionParameters = lattice->actionParameters;
-	
-//	Real dt = Omega::instance().getTimeStep();
-	
+	BodyContainer* bodies = lattice->bodies.get();
+
 	BodyContainer::iterator bi    = bodies->begin();
 	BodyContainer::iterator biEnd = bodies->end();
+	
 	for(  ; bi!=biEnd ; ++bi )  // loop over all beams
 	{
-		shared_ptr<Body> body = *bi;
+		Body* body = (*bi).get();
 		if( ! ( body->getGroupMask() & beamGroupMask ) )
 			continue; // skip non-beams
 		
+		// next beam
 		LatticeBeamParameters* beam = static_cast<LatticeBeamParameters*>(body->physicalParameters.get() );
 		
-//		Vector3r  force = beam->direction * ((beam->length/beam->initialLength)-1.0)/stiffness;
-
-		Vector3r  displacement = beam->direction * (beam->length - beam->initialLength) * 0.5;
+		Real      stretch      = beam->length - beam->initialLength;
 		
-		if( displacement.squaredLength() > maxDispl /*FIXME - different name*/ ) // delete beam
-		{
-			bodies->erase(body->getId());
-			continue;
+		// 'D' from picture. how much beam wants to change length at each node, to bounce back through original length to mirror position.
+		Vector3r  displacement = beam->direction * stretch;
+		
+		{ // check E_min, E_max criterion
+			if( deleteBeam(lattice , beam , stretch) )
+			{
+				futureDeletes.push_back(body->getId());
+				continue;
+			}
 		}
 		
-//		cerr << beam->direction.length() << endl;
-//		static_cast<Force*> ( actionParameters->find( beam->id1 , actionForce ->getClassIndex() ).get() )->force  -= force;
-//		static_cast<Force*> ( actionParameters->find( beam->id2 , actionForce ->getClassIndex() ).get() )->force  += force;
-
-//		shared_ptr<Body>& bodyA = (*(rootBody->bodies))[beam->id1];
-//		shared_ptr<Body>& bodyB = (*(rootBody->bodies))[beam->id2];
-		
 		LatticeNodeParameters* node1 = static_cast<LatticeNodeParameters*>(((*(bodies))[beam->id1])->physicalParameters.get());
 		LatticeNodeParameters* node2 = static_cast<LatticeNodeParameters*>(((*(bodies))[beam->id2])->physicalParameters.get());
-
-//		cerr << node1 << endl;
-//		cerr << node2 << endl; 
-	
-		++(node1->count);
-		++(node2->count);
 		
-		node1->displacement -= displacement;
-		node2->displacement += displacement;
-
+		{ // give 'D' to nodes
+			++(node1->count);
+			++(node2->count);
+			node1->displacement -= displacement;
+			node2->displacement += displacement;
+		}
+		
+		{ // 'W' from picture - previous displacement of the beam. try to do it again.
+			Vector3r previousDisplacement = beam->se3.position - beam->previousSe3.position;
+			node1->displacement += previousDisplacement;
+			node2->displacement += previousDisplacement;
+		} 
 	}
-
+	
 	bi    = bodies->begin();
-	biEnd    = bodies->end();
+	biEnd = bodies->end();
 	for(  ; bi!=biEnd ; ++bi )  // loop over all nodes
 	{
-		shared_ptr<Body> body = *bi;
+		Body* body = (*bi).get();
 
 		if( ! ( body->getGroupMask() & nodeGroupMask ) )
 			continue; // skip non-nodes
 		
 		LatticeNodeParameters* node = static_cast<LatticeNodeParameters*>(body->physicalParameters.get() );
 		
-		if(node->count == 0) 
-			continue; 
+		{ // check nodes if they have any beams left
+			if(node->count == 0) 
+			{ // node not moving (marked for deletion)
+			//	futureDeletes.push_back(body->getId()); // FIXME - crashes ....
+				continue; 
+			}
+		}
 		
 		Vector3r displacement 	= node->displacement / node->count;
 		node->displacement  	= Vector3r(0.0,0.0,0.0);
@@ -108,8 +160,30 @@
 		
 		if(body->isDynamic)
 			node->se3.position 	+= displacement;
+			
+		/* FIXME FIXME FIXME FIXME FIXME FIXME FIXME
+		else // FIXME - else move only in x direction
+			node->se3.position[0] 	+= displacement[0];
+		*/
 	}
-
+	
+	{ // store previousSe3 in the beam, calc new beam position: X_b = ( X_n1 + X_n2 ) / 2
+		bi    = bodies->begin();
+		biEnd = bodies->end(); 
+		for(  ; bi!=biEnd ; ++bi )  // loop over all beams
+		{
+			Body* body = (*bi).get();
+			if( body->getGroupMask() & beamGroupMask )
+				calcBeamsPositionOrientationNewLength(body,bodies);
+		}
+	} 
+	
+	{ // delete all beams and nodes marked for deletion 
+	  // - beams that exceeded critical tensile/compressive strain
+	  // - nodes that have no more beams
+		vector<unsigned int>::iterator vend = futureDeletes.end();
+		for( vector<unsigned int>::iterator vsta = futureDeletes.begin() ; vsta != vend ; ++vsta)
+			bodies->erase(*vsta); 
+	}
 }
 
-

Modified: trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.hpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/Engine/StandAloneEngine/LatticeLaw/LatticeLaw.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -10,7 +10,9 @@
 #define LATTICELAW_HPP
 
 
+#include "LatticeBeamParameters.hpp"
 #include <yade/yade-core/InteractionSolver.hpp>
+#include <yade/yade-core/BodyContainer.hpp>
 
 
 class PhysicalAction;
@@ -23,13 +25,15 @@
 	
 	private :
 		shared_ptr<PhysicalAction> actionForce;
+		vector<unsigned int> futureDeletes;
+		
+		bool deleteBeam(MetaBody* lattice , LatticeBeamParameters* beam , Real stretch);
+		void calcBeamsPositionOrientationNewLength(Body* body, BodyContainer* bodies);
 
 	public :
 		int	 nodeGroupMask
 			,beamGroupMask;
-
-		Real	 maxDispl;
-
+		
 		LatticeLaw();
 		virtual ~LatticeLaw();
 		void action(Body* body);

Modified: trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.cpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -28,7 +28,7 @@
 #include <yade/yade-package-common/InteractionVecSet.hpp>
 #include <yade/yade-package-common/PhysicalActionVectorVector.hpp>
 
-#include <yade/yade-package-common/TranslationEngine.hpp>
+#include <yade/yade-package-common/DisplacementEngine.hpp>
 #include <yade/yade-package-common/PhysicalParametersMetaEngine.hpp>
 #include <yade/yade-package-common/PhysicalActionApplier.hpp>
 
@@ -44,20 +44,39 @@
 	nodeGroupMask 		= 1;
 	beamGroupMask 		= 2;
 	
-	nbNodes 		= Vector3r(4,10,4);
-	disorder 		= 0.23;
-	maxLength 		= 1.7;
+	speciemen_size_in_meters = Vector3r(0.1,0.1,0.0001);
+	cellsizeUnit_in_meters	 = 0.003;
+	minAngle_betweenBeams_deg= 20.0;
+	disorder_in_cellsizeUnit = Vector3r(0.6,0.6,0.0);
+	maxLength_in_cellsizeUnit= 1.9;
+	triangularBaseGrid 	 = true;
+				
+	crit_TensileStrain_percent = 100.0;	// E_min
+	crit_ComprStrain_percent   = 50.0;	// E_max
+			
+	longitudalStiffness_noUnit = 1.0;	// k_l
+	bendingStiffness_noUnit    = 0.0;	// k_b
 	
-	regionA_min 		= Vector3r(-1,-1,-1);
-	regionA_max 		= Vector3r(11,0.6,11);
-	direction_A 		= Vector3r(0,-1,0);
-	velocity_A 		= 0.01;
-	regionB_min 		= Vector3r(-1,8.4,-1);
-	regionB_max 		= Vector3r(11,11,11);
-	direction_B 		= Vector3r(0,1,0);
-	velocity_B 		= 0.01;
+	region_A_min 		= Vector3r(-0.006, 0.096,-1);
+	region_A_max 		= Vector3r( 0.16 , 0.16 , 1);
+	direction_A 		= Vector3r(0,1,0);
+	displacement_A_meters	= 0.0001;
 	
-	maxDeformationSquared 	= 0.0004;
+	region_B_min 		= Vector3r(-0.006,-0.006,-1);
+	region_B_max 		= Vector3r( 0.16 , 0.004, 1);
+	direction_B 		= Vector3r(0,-1,0);
+	displacement_B_meters	= 0.0001;
+
+	region_C_min 		= Vector3r(-0.006, 0.096,-1);
+	region_C_max 		= Vector3r( 0.16 , 0.16 , 1);
+	direction_C 		= Vector3r(0,1,0);
+	displacement_C_meters	= 0.0001;
+	
+	region_D_min 		= Vector3r(-0.006,-0.006,-1);
+	region_D_max 		= Vector3r( 0.16 , 0.004, 1);
+	direction_D 		= Vector3r(0,-1,0);
+	displacement_D_meters	= 0.0001;
+	
 }
 
 
@@ -69,25 +88,38 @@
 
 void LatticeExample::registerAttributes()
 {
-	REGISTER_ATTRIBUTE(nbNodes); 
-	REGISTER_ATTRIBUTE(disorder);
-	REGISTER_ATTRIBUTE(maxLength);
-//	REGISTER_ATTRIBUTE(stiffness);
-	REGISTER_ATTRIBUTE(regionA_min);
-	REGISTER_ATTRIBUTE(regionA_max);
+	REGISTER_ATTRIBUTE(speciemen_size_in_meters); 	// size
+	REGISTER_ATTRIBUTE(cellsizeUnit_in_meters);	// g [m]  	- cell size
+	REGISTER_ATTRIBUTE(minAngle_betweenBeams_deg); 	// a [deg] 	- min angle
+	REGISTER_ATTRIBUTE(disorder_in_cellsizeUnit); 	// s [-] 	- disorder 
+	REGISTER_ATTRIBUTE(maxLength_in_cellsizeUnit);	// r [-] 	- max beam length
+	
+	REGISTER_ATTRIBUTE(crit_TensileStrain_percent); // E_min [%]    - default 0.02 %
+	REGISTER_ATTRIBUTE(crit_ComprStrain_percent);   // E_max [%]    - default 0.2 %
+	REGISTER_ATTRIBUTE(longitudalStiffness_noUnit); // k_l [-]      - default 1.0
+	REGISTER_ATTRIBUTE(bendingStiffness_noUnit);    // k_b [-]      - default 0.6
+	
+	REGISTER_ATTRIBUTE(triangularBaseGrid); 	// 		- triangles
+	
+	REGISTER_ATTRIBUTE(region_A_min);
+	REGISTER_ATTRIBUTE(region_A_max);
 	REGISTER_ATTRIBUTE(direction_A);
-	REGISTER_ATTRIBUTE(velocity_A);
-	REGISTER_ATTRIBUTE(regionB_min);
-	REGISTER_ATTRIBUTE(regionB_max);
+	REGISTER_ATTRIBUTE(displacement_A_meters);
+	
+	REGISTER_ATTRIBUTE(region_B_min);
+	REGISTER_ATTRIBUTE(region_B_max);
 	REGISTER_ATTRIBUTE(direction_B);
-	REGISTER_ATTRIBUTE(velocity_B);
-//	REGISTER_ATTRIBUTE(regionC_min);
-//	REGISTER_ATTRIBUTE(regionC_max);
-//	REGISTER_ATTRIBUTE(direction_C);
-//	REGISTER_ATTRIBUTE(velocity_C);
-
-	REGISTER_ATTRIBUTE(maxDeformationSquared);
-
+	REGISTER_ATTRIBUTE(displacement_B_meters);
+	
+	REGISTER_ATTRIBUTE(region_C_min);
+	REGISTER_ATTRIBUTE(region_C_max);
+	REGISTER_ATTRIBUTE(direction_C);
+	REGISTER_ATTRIBUTE(displacement_C_meters);
+	
+	REGISTER_ATTRIBUTE(region_D_min);
+	REGISTER_ATTRIBUTE(region_D_max);
+	REGISTER_ATTRIBUTE(direction_D);
+	REGISTER_ATTRIBUTE(displacement_D_meters);
 }
 
 string LatticeExample::generate()
@@ -105,68 +137,126 @@
 	
 	shared_ptr<Body> body;
 	
-	for( int i=0 ; i<nbNodes[0] ; i++ )
-		for( int j=0 ; j<nbNodes[1] ; j++ )
-			for( int k=0 ; k<nbNodes[2] ; k++)
+	Vector3r nbNodes = speciemen_size_in_meters / cellsizeUnit_in_meters;
+	if(triangularBaseGrid)
+		nbNodes[1] *= 1.15471; // bigger by sqrt(3)/2 factor
+/* 
+ * speeding up creation of beams....
+ * 
+
+	vector<vector<vector<unsigned int> > > node_matrix; // matrix that spatially remembers nodes position.
+	node_matrix.resize(nbNodes[0]+1);
+	for( int i=0 ; i<=nbNodes[0] ; i++ )
+	{
+		node_matrix[i].resize(nbNodes[1]+1);
+		for( int j=0 ; j<=nbNodes[1] ; j++ )
+			node_matrix[i][j].resize(nbNodes[2]+1);
+	}
+*/		
+	for( int i=0 ; i<=nbNodes[0] ; i++ )
+		for( int j=0 ; j<=nbNodes[1] ; j++ )
+			for( int k=0 ; k<=nbNodes[2] ; k++)
 			{
 				shared_ptr<Body> node;
-				createNode(node,i,j,k);
-				rootBody->bodies->insert(node);
+				if(createNode(node,i,j,k))
+					rootBody->bodies->insert(node);
 			}
-			
+
 	BodyRedirectionVector bc;
 	bc.clear();
 
 	BodyContainer::iterator bi    = rootBody->bodies->begin();
 	BodyContainer::iterator bi2;
 	BodyContainer::iterator biEnd = rootBody->bodies->end();
-	for(  ; bi!=biEnd ; ++bi )  // loop over all beams
+	int beam_counter = 0;
+	float nodes_a=0;
+	float nodes_all = rootBody->bodies->size();
+	for(  ; bi!=biEnd ; ++bi )  // loop over all nodes, to create beams
 	{
-		shared_ptr<Body> bodyA = *bi;
+		Body* bodyA = (*bi).get(); // first_node
 	
-		cerr << "creating beams: " << bodyA->getId() << endl;
 		bi2 = bi;
 		++bi2;
+		nodes_a+=1.0;
 		
 		for( ; bi2!=biEnd ; ++bi2 )
 		{
-			shared_ptr<Body> bodyB = *bi2;
-			shared_ptr<LatticeNodeParameters> a = dynamic_pointer_cast<LatticeNodeParameters>(bodyA->physicalParameters);
-			shared_ptr<LatticeNodeParameters> b = dynamic_pointer_cast<LatticeNodeParameters>(bodyB->physicalParameters);
-
-			if (a && b && (a->se3.position - b->se3.position).squaredLength() < (maxLength*maxLength))  
+			Body* bodyB = (*bi2).get(); // all other nodes
+			// warning - I'm assuming that there are ONLY Nodes in the rootBody
+			LatticeNodeParameters* a = static_cast<LatticeNodeParameters*>(bodyA->physicalParameters.get());
+			LatticeNodeParameters* b = static_cast<LatticeNodeParameters*>(bodyB->physicalParameters.get());
+			
+			if ((a->se3.position - b->se3.position).squaredLength() < std::pow(maxLength_in_cellsizeUnit*cellsizeUnit_in_meters,2) )  
 			{
 				shared_ptr<Body> beam;
 				createBeam(beam,bodyA->getId(),bodyB->getId());
-				bc.insert(beam);
+				calcBeamPositionOrientationLength(beam);
+				if(checkMinimumAngle(bc,beam))
+				{
+					if( ++beam_counter % 100 == 0 )
+						cerr << "creating beam: " << beam_counter << " , " << ((nodes_a/nodes_all)*100.0)  << " %\n"; 
+					bc.insert(beam);
+				}
 			}
 		}
 	}
 
 	bi    = bc.begin();
 	biEnd = bc.end();
-	for(  ; bi!=biEnd ; ++bi )  // loop over all beams
+	for(  ; bi!=biEnd ; ++bi )  // loop over all newly created beams ...
 	{
 		shared_ptr<Body> b = *bi;
-		rootBody->bodies->insert(b);
+		rootBody->bodies->insert(b); // .. to insert then into rootBody
 	}
 	
-	cerr<< "calcBeamsPositionOrientationLength\n";
-	calcBeamsPositionOrientationLength(rootBody);
+	imposeTranslation(rootBody,region_A_min,region_A_max,direction_A,displacement_A_meters);
+	imposeTranslation(rootBody,region_B_min,region_B_max,direction_B,displacement_B_meters);
+	imposeTranslation(rootBody,region_C_min,region_C_max,direction_C,displacement_C_meters);
+	imposeTranslation(rootBody,region_D_min,region_D_max,direction_D,displacement_D_meters);
 
-	imposeTranslation(rootBody,regionA_min,regionA_max,direction_A,velocity_A);
-	imposeTranslation(rootBody,regionB_min,regionB_max,direction_B,velocity_B);
-//	imposeTranslation(rootBody,regionC_min,regionC_max,direction_C,velocity_C);
-
 	cerr << "finished.. saving\n";
 
- 	return ""; 
+ 	return "Number of nodes created:\n" + lexical_cast<string>(nbNodes[0]) + ","
+	 				    + lexical_cast<string>(nbNodes[1]) + ","
+					    + lexical_cast<string>(nbNodes[2]);
 
 }
 
+/// returns true if angle is bigger than minAngle_betweenBeams_deg
+bool LatticeExample::checkAngle( Vector3r a, Vector3r& b)
+{
+	Quaternionr al;
+	al.align(a,b);
+	Vector3r axis;
+	Real angle;
+	al.toAxisAngle(axis, angle);
+	angle *= 180.0/Mathr::PI ;
+//	cerr << " angle: " << angle << "\n";
+	return angle > minAngle_betweenBeams_deg;
+}
 
+/// returns true if angle is bigger than minAngle_betweenBeams_deg
+bool LatticeExample::checkMinimumAngle(BodyRedirectionVector& bc,shared_ptr<Body>& body)
+{
+	bool answer = true;
+	LatticeBeamParameters* newBeam = static_cast<LatticeBeamParameters*>(body->physicalParameters.get());
+	
+	BodyContainer::iterator bi    = bc.begin();
+	BodyContainer::iterator biEnd = bc.end();
+	for(  ; bi!=biEnd ; ++bi )  // loop over all beams - they MUST be beams, for static_cast<> 
+	{ 
+		LatticeBeamParameters* oldBeam = static_cast<LatticeBeamParameters*>((*bi)->physicalParameters.get());
+		if( 	   (oldBeam->id1 == newBeam->id1)
+			|| (oldBeam->id2 == newBeam->id2))
+			answer = answer && checkAngle(   oldBeam->direction ,  newBeam->direction );
+		if( 	   (oldBeam->id2 == newBeam->id1)
+			|| (oldBeam->id1 == newBeam->id2))
+			answer = answer && checkAngle( - oldBeam->direction ,  newBeam->direction );
+	} 
+	return answer;
+}
 
-void LatticeExample::createNode(shared_ptr<Body>& body, int i, int j, int k)
+bool LatticeExample::createNode(shared_ptr<Body>& body, int i, int j, int k)
 {
 	body = shared_ptr<Body>(new Body(0,nodeGroupMask));
 	shared_ptr<LatticeNodeParameters> physics(new LatticeNodeParameters);
@@ -175,29 +265,37 @@
 	Quaternionr q;
 	q.fromAxisAngle( Vector3r(Mathr::unitRandom(),Mathr::unitRandom(),Mathr::unitRandom()) , Mathr::unitRandom()*Mathr::PI );
 	
-	Vector3r position		=   Vector3r(i,j,k)
-					  + Vector3r( 	  Mathr::symmetricRandom()*disorder
-					  		, Mathr::symmetricRandom()*disorder
-							, Mathr::symmetricRandom()*disorder);
+	float  triang_x = triangularBaseGrid ? (static_cast<float>(j%2))*0.5 : 0;
+	double triang_y = triangularBaseGrid ? 0.86602540378443864676        : 1; // sqrt(3)/2
+	
+	Vector3r position		= ( Vector3r(i+triang_x,j*triang_y,k)
+					  + Vector3r( 	  Mathr::symmetricRandom()*disorder_in_cellsizeUnit[0]
+					  		, Mathr::symmetricRandom()*disorder_in_cellsizeUnit[1]
+							, Mathr::symmetricRandom()*disorder_in_cellsizeUnit[2]
+						    ) * 0.5 // *0.5 because symmetricRandom is (-1,1), and disorder is whole size where nodes can appear
+					  )*cellsizeUnit_in_meters;
 
-	Real radius 			= 0.1;
+	if( 	   position[0] >= speciemen_size_in_meters[0] 
+		|| position[1] >= speciemen_size_in_meters[1]
+		|| position[2] >= speciemen_size_in_meters[2] )
+		return false;
+
+	Real radius 			= cellsizeUnit_in_meters*0.05;
 	
 	body->isDynamic			= true;
 	
-	physics->angularVelocity	= Vector3r(0,0,0);
-	physics->velocity		= Vector3r(0,0,0);
-	physics->mass			= 1;
-	physics->inertia		= Vector3r(1,1,1);
 	physics->se3			= Se3r(position,q);
 
 	gSphere->radius			= radius;
-	gSphere->diffuseColor		= Vector3f(0.5,0.5,0.5);
+	gSphere->diffuseColor		= Vector3f(0.8,0.8,0.8);
 	gSphere->wire			= false;
 	gSphere->visible		= true;
-	gSphere->shadowCaster		= true;
+	gSphere->shadowCaster		= false;
 	
 	body->geometricalModel		= gSphere;
 	body->physicalParameters	= physics;
+	
+	return true;
 }
 
 
@@ -207,62 +305,52 @@
 	shared_ptr<LatticeBeamParameters> physics(new LatticeBeamParameters);
 	shared_ptr<LineSegment> gBeam(new LineSegment);
 	
-	Real length 			= 0.6;
+	Real length 			= 1.0; // unspecified for now, calcBeamsPositionOrientationLength will calculate it
 	
 	body->isDynamic			= true;
 	
-	physics->angularVelocity	= Vector3r(0,0,0);
-	physics->velocity		= Vector3r(0,0,0);
-	physics->mass			= 1; // FIXME
-	physics->inertia		= Vector3r(1,1,1); // FIXME
 	physics->id1 			= i;
 	physics->id2 			= j;
 
 	gBeam->length			= length;
-//	gBeam->diffuseColor		= Vector3f(Mathf::unitRandom(),Mathf::unitRandom(),Mathf::unitRandom());
-	gBeam->diffuseColor		= Vector3f(0.8,0.8,0.8);
+	gBeam->diffuseColor		= Vector3f(0.6,0.6,0.6);
 	gBeam->wire			= false;
 	gBeam->visible			= true;
-	gBeam->shadowCaster		= true;
+	gBeam->shadowCaster		= false;
 	
 	body->geometricalModel		= gBeam;
 	body->physicalParameters	= physics;
 }
 
 
-void LatticeExample::calcBeamsPositionOrientationLength(shared_ptr<MetaBody>& body)
+void LatticeExample::calcBeamPositionOrientationLength(shared_ptr<Body>& body)
 {
-	BodyContainer::iterator bi    = body->bodies->begin();
-	BodyContainer::iterator biEnd = body->bodies->end();
-	for(  ; bi!=biEnd ; ++bi )  // loop over all beams
-	{
-		shared_ptr<Body> body = *bi;
-		if( body->getGroupMask() & beamGroupMask )
-		{
-			cerr << "calcBeamsPositionOrientationLength: " << body->getId() << endl;
-			
-			LatticeBeamParameters* beam = static_cast<LatticeBeamParameters*>(body->physicalParameters.get());
-			shared_ptr<Body>& bodyA = (*(rootBody->bodies))[beam->id1];
-			shared_ptr<Body>& bodyB = (*(rootBody->bodies))[beam->id2];
-			Se3r& se3A 		= bodyA->physicalParameters->se3;
-			Se3r& se3B 		= bodyB->physicalParameters->se3;
-			
-			Se3r se3Beam;
-			se3Beam.position 	= (se3A.position + se3B.position)*0.5;
-			Vector3r dist 		= se3A.position - se3B.position;
-			
-			Real length 		= dist.normalize();
-			beam->length 		= length;
-			beam->initialLength 	= length;
-			
-			se3Beam.orientation.align( Vector3r::UNIT_X , dist );
-			beam->se3 		= se3Beam;
-		}
-	}
+	LatticeBeamParameters* beam = static_cast<LatticeBeamParameters*>(body->physicalParameters.get());
+	shared_ptr<Body>& bodyA = (*(rootBody->bodies))[beam->id1];
+	shared_ptr<Body>& bodyB = (*(rootBody->bodies))[beam->id2];
+	Se3r& se3A 		= bodyA->physicalParameters->se3;
+	Se3r& se3B 		= bodyB->physicalParameters->se3;
+	
+	Se3r se3Beam;
+	se3Beam.position 	= (se3A.position + se3B.position)*0.5;
+	Vector3r dist 		= se3A.position - se3B.position;
+	
+	Real length 		= dist.normalize();
+	beam->direction 	= dist;
+	beam->initialDirection 	= dist;
+	beam->length 		= length;
+	beam->initialLength 	= length;
+	
+	beam->criticalTensileStrain 	= crit_TensileStrain_percent/100.0;
+	beam->criticalCompressiveStrain = crit_ComprStrain_percent/100.0;
+	beam->longitudalStiffness 	= longitudalStiffness_noUnit;
+	beam->bendingStiffness 		= bendingStiffness_noUnit;
+	
+	se3Beam.orientation.align( Vector3r::UNIT_X , dist );
+	beam->se3 		= se3Beam;
+	beam->previousSe3 	= se3Beam;
 }
 
-
-
 void LatticeExample::createActors(shared_ptr<MetaBody>& )
 {
 	shared_ptr<BoundingVolumeMetaEngine> boundingVolumeDispatcher	= shared_ptr<BoundingVolumeMetaEngine>(new BoundingVolumeMetaEngine);
@@ -271,31 +359,16 @@
 	shared_ptr<GeometricalModelMetaEngine> geometricalModelDispatcher	= shared_ptr<GeometricalModelMetaEngine>(new GeometricalModelMetaEngine);
 	geometricalModelDispatcher->add("LatticeSetParameters","LatticeSetGeometry","LatticeSet2LatticeBeams");
 	
-//	shared_ptr<PhysicalParametersMetaEngine> positionIntegrator(new PhysicalParametersMetaEngine);
-//	positionIntegrator->add("ParticleParameters","LeapFrogPositionIntegrator");
-	
-//	shared_ptr<PhysicalActionApplier> applyActionDispatcher(new PhysicalActionApplier);
-//	applyActionDispatcher->add("Force","ParticleParameters","NewtonsForceLaw");
-	
-//	shared_ptr<PhysicalActionContainerInitializer> actionParameterInitializer(new PhysicalActionContainerInitializer);
-//	actionParameterInitializer->actionParameterNames.push_back("Force");
-//	actionParameterInitializer->actionParameterNames.push_back("Momentum"); // FIXME - should be unnecessery, but BUG in PhysicalActionVectorVector
-	
 	shared_ptr<LatticeLaw> latticeLaw(new LatticeLaw);
 	latticeLaw->nodeGroupMask = nodeGroupMask;
 	latticeLaw->beamGroupMask = beamGroupMask;
-	latticeLaw->maxDispl = maxDeformationSquared;
 
 	rootBody->engines.clear();
 	rootBody->engines.push_back(boundingVolumeDispatcher);
+	rootBody->engines.push_back(latticeLaw);
 	rootBody->engines.push_back(geometricalModelDispatcher);
-	rootBody->engines.push_back(latticeLaw);
-//	rootBody->engines.push_back(applyActionDispatcher); // ????
-//	rootBody->engines.push_back(positionIntegrator);
 	
-	
 	rootBody->initializers.clear();
-//	rootBody->initializers.push_back(actionParameterInitializer); // FIXME - should be automatic!
 	rootBody->initializers.push_back(boundingVolumeDispatcher);
 	rootBody->initializers.push_back(geometricalModelDispatcher);
 }	
@@ -332,14 +405,16 @@
 }
 	
  
-void LatticeExample::imposeTranslation(shared_ptr<MetaBody>& rootBody, Vector3r min, Vector3r max, Vector3r direction, Real velocity)
+void LatticeExample::imposeTranslation(shared_ptr<MetaBody>& rootBody, Vector3r min, Vector3r max, Vector3r direction, Real displacement)
 {
-	shared_ptr<TranslationEngine> translationCondition = shared_ptr<TranslationEngine>(new TranslationEngine);
- 	translationCondition->velocity  = velocity;
+	shared_ptr<DisplacementEngine> translationCondition = shared_ptr<DisplacementEngine>(new DisplacementEngine);
+ 	translationCondition->displacement  = displacement;
 	direction.normalize();
  	translationCondition->translationAxis = direction;
 	
-	rootBody->engines.push_back(translationCondition);
+	rootBody->engines.push_back((rootBody->engines)[rootBody->engines.size()-1]);
+	(rootBody->engines)[rootBody->engines.size()-2]=(rootBody->engines)[rootBody->engines.size()-3];
+	(rootBody->engines)[rootBody->engines.size()-3]=translationCondition;
 	translationCondition->subscribedBodies.clear();
 	
 	BodyContainer::iterator bi    = rootBody->bodies->begin();
@@ -361,7 +436,7 @@
 				)
 			{
 				b->isDynamic = false;
-				b->geometricalModel->diffuseColor = Vector3f(1,0,0);
+				b->geometricalModel->diffuseColor = Vector3f(0.3,0.3,0.3);
 				translationCondition->subscribedBodies.push_back(b->getId());
 			}
 		}

Modified: trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.hpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.hpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.hpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -11,26 +11,53 @@
 
 #include <yade/yade-core/FileGenerator.hpp>
 #include <yade/yade-lib-wm3-math/Vector3.hpp>
+#include <yade/yade-package-common/BodyRedirectionVector.hpp>
 
 class LatticeExample : public FileGenerator
 {
 	private :
 		int 		nodeGroupMask,beamGroupMask;
 		
-		Vector3r 	 nbNodes
-			 	,regionA_min
-			 	,regionA_max
+	// mesh generation	
+		Vector3r 	 speciemen_size_in_meters 	// size
+				,disorder_in_cellsizeUnit;	// s
+		
+		Real 		 maxLength_in_cellsizeUnit	// r
+				,minAngle_betweenBeams_deg 	// a
+				,cellsizeUnit_in_meters 	// g
+				
+				,crit_TensileStrain_percent	// E_min
+				,crit_ComprStrain_percent	// E_max
+				
+				,longitudalStiffness_noUnit 	// k_l
+				,bendingStiffness_noUnit;	// k_b
+				
+		bool 		 triangularBaseGrid;
+		
+		
+	// conditions
+		Vector3r 	 region_A_min
+			 	,region_A_max
 			 	,direction_A
-			 	,regionB_min
-			 	,regionB_max
-			 	,direction_B;
-		
-		Real 		 disorder
-		 		,maxLength
-		 		,velocity_B
-		 		,velocity_A
-		 		,maxDeformationSquared;
-
+				 
+			 	,region_B_min
+			 	,region_B_max
+			 	,direction_B
+				 
+			 	,region_C_min
+			 	,region_C_max
+			 	,direction_C
+				 
+			 	,region_D_min
+			 	,region_D_max
+			 	,direction_D;
+				 
+						
+		Real		 displacement_A_meters
+		 		,displacement_B_meters
+		 		,displacement_C_meters
+		 		,displacement_D_meters;
+				
 	public : 
 		LatticeExample();
 		virtual ~LatticeExample();
@@ -39,9 +66,11 @@
 	
 		void createActors(shared_ptr<MetaBody>& rootBody);
 		void positionRootBody(shared_ptr<MetaBody>& rootBody);
-		void createNode(shared_ptr<Body>& body, int i, int j, int k);
+		bool createNode(shared_ptr<Body>& body, int i, int j, int k);
 		void createBeam(shared_ptr<Body>& body, unsigned int i, unsigned int j);
-		void calcBeamsPositionOrientationLength(shared_ptr<MetaBody>& body);
+		void calcBeamPositionOrientationLength(shared_ptr<Body>& body);
+		bool checkMinimumAngle(BodyRedirectionVector&,shared_ptr<Body>&);
+		bool checkAngle( Vector3r , Vector3r& );
 		void imposeTranslation(shared_ptr<MetaBody>& rootBody, Vector3r min, Vector3r max, Vector3r direction, Real velocity);
 
 		virtual void registerAttributes();

Modified: trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.pro
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.pro	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/PreProcessor/LatticeExample/LatticeExample.pro	2005-11-18 19:35:09 UTC (rev 954)
@@ -20,7 +20,7 @@
         -lParticleParameters \
         -lAABB \
         -lSphere \
-        -lTranslationEngine \
+        -lDisplacementEngine \
         -lLatticeLaw \
         -rdynamic 
 INCLUDEPATH += $${YADE_QMAKE_PATH}/include/ \

Modified: trunk/yade-packages/yade-package-lattice/src/RenderingEngine/GLDrawLineSegment/GLDrawLineSegment.cpp
===================================================================
--- trunk/yade-packages/yade-package-lattice/src/RenderingEngine/GLDrawLineSegment/GLDrawLineSegment.cpp	2005-11-15 01:45:42 UTC (rev 953)
+++ trunk/yade-packages/yade-package-lattice/src/RenderingEngine/GLDrawLineSegment/GLDrawLineSegment.cpp	2005-11-18 19:35:09 UTC (rev 954)
@@ -18,7 +18,7 @@
 	
 	Real len = (static_cast<LineSegment*>(gm.get()))->length;
 	
-	glScalef(len,0.05,0.05); // it's a box, not a line. looks better :)
+	glScalef(len,0.0012,0.0012); // it's a box, not a line. looks better :)
 
 	if (gm->wire || wire)
 	{

_______________________________________________
yade-dev mailing list
yade-dev@xxxxxxxxxxxxxxxx
http://lists.berlios.de/mailman/listinfo/yade-dev



Follow ups