← Back to team overview

yade-dev team mailing list archive

[svn] r1643 - in trunk/pkg/snow: . DataClass Engine PreProcessor RenderingEngine

 

Author: cosurgi
Date: 2009-01-26 04:34:03 +0100 (Mon, 26 Jan 2009)
New Revision: 1643

Added:
   trunk/pkg/snow/DataClass/IstSnowLayersContact.cpp
   trunk/pkg/snow/DataClass/IstSnowLayersContact.hpp
   trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.cpp
   trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.hpp
   trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.cpp
   trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.hpp
Modified:
   trunk/pkg/snow/DataClass/BshSnowGrain.cpp
   trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp
   trunk/pkg/snow/RenderingEngine/Ef1_BshSnowGrain_glDraw.cpp
   trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.cpp
   trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.hpp
   trunk/pkg/snow/SConscript
Log:
small snow update



Modified: trunk/pkg/snow/DataClass/BshSnowGrain.cpp
===================================================================
--- trunk/pkg/snow/DataClass/BshSnowGrain.cpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/DataClass/BshSnowGrain.cpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -213,8 +213,8 @@
 				if( point_plane_distance > depth*0.5 ) // (1-parallelepiped)
 				{ // that's close enough. We can speed up the computation by returning true at this point
 
-// therefore in fact, we are checking if point is inside a volume of parallelepiped (1) the height of 1/2 depth
-// within the polyhedron PLUS (that's the code below - the (2)) a polyhedron the height given by depth
+// therefore in fact, we are checking if point is inside a volume of parallelepiped (1-) the height of 1/2 depth
+// within the polyhedron PLUS (that's the code below - the (2-)) a polyhedron the height given by depth
 // like this:
 //              ____________     this weird shape is WHOLE polyhedron
 //             /         Z. \                                                         ------
@@ -225,9 +225,9 @@
 //        /          '         ` \______________ XX face (see description)                 |e - search below for
 //       /          '           `              /                                           |p 'arbitrary safety coefficient'
 //      /      ....'.............`......      /                                            |t
-//      \     '   '           1-parallelepiped with height equal to 1/2 of depth           |h
-//       \    '  '                 `   '    /                                              |
-//        \   ' '                   `  '   /                                               |
+//      \     '   '           1-parallelepiped with height equal to 1/2 of depth           |h ('Z' is orthogonal to triangle with 
+//       \    '  '                 `   '    /                                              |   'depth' distance from the
+//        \   ' '                   `  '   /                                               |   triangle's center point )
 //         \  ''                     ` '  /                                                |
 //          \ '                       `' /                                                 |
 //           \__________________________/                                             ------

Added: trunk/pkg/snow/DataClass/IstSnowLayersContact.cpp
===================================================================
--- trunk/pkg/snow/DataClass/IstSnowLayersContact.cpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/DataClass/IstSnowLayersContact.cpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -0,0 +1,15 @@
+#include<yade/pkg-snow/IstSnowLayersContact.hpp>
+
+IstSnowLayersContact::IstSnowLayersContact()
+{
+	createIndex();
+}
+
+IstSnowLayersContact::~IstSnowLayersContact()
+{}
+		
+void IstSnowLayersContact::registerAttributes()
+{
+	SpheresContactGeometry::registerAttributes();
+}
+

Added: trunk/pkg/snow/DataClass/IstSnowLayersContact.hpp
===================================================================
--- trunk/pkg/snow/DataClass/IstSnowLayersContact.hpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/DataClass/IstSnowLayersContact.hpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -0,0 +1,23 @@
+// 2009 Janek Kozicki <cosurgi@xxxxxxxxxx>
+
+#pragma once
+
+#include<yade/core/InteractionGeometry.hpp>
+#include<yade/pkg-dem/SpheresContactGeometry.hpp>
+
+class IstSnowLayersContact : public SpheresContactGeometry
+{
+	public:
+		IstSnowLayersContact();
+		virtual ~IstSnowLayersContact();
+
+	protected :
+		virtual void registerAttributes();
+
+	REGISTER_CLASS_NAME(IstSnowLayersContact);
+	REGISTER_BASE_CLASS_NAME(SpheresContactGeometry);
+	REGISTER_CLASS_INDEX(IstSnowLayersContact,SpheresContactGeometry);
+};
+
+REGISTER_SERIALIZABLE(IstSnowLayersContact);
+

Added: trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.cpp
===================================================================
--- trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.cpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.cpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -0,0 +1,82 @@
+// © 2004 Olivier Galizzi <olivier.galizzi@xxxxxxx>
+// © 2004 Janek Kozicki <cosurgi@xxxxxxxxxx>
+// © 2007 Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
+// © 2008 Václav Šmilauer <eudoxos@xxxxxxxx>
+
+#include"Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.hpp"
+#include<yade/pkg-dem/SpheresContactGeometry.hpp>
+#include<yade/pkg-snow/BssSnowGrain.hpp>
+#include<yade/pkg-common/InteractingSphere.hpp>
+
+#include<yade/lib-base/yadeWm3Extra.hpp>
+#include<yade/core/Omega.hpp>
+
+
+Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact::Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact()
+{
+}
+
+void Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact::registerAttributes()
+{	
+}
+
+bool Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact::go(	const shared_ptr<InteractingGeometry>& cm1,
+							const shared_ptr<InteractingGeometry>& cm2,
+							const Se3r& se31,
+							const Se3r& se32,
+							const shared_ptr<Interaction>& c)
+{
+//	bool result = g.go(cm1,cm2,se31,se32,c);
+//	std::cerr << "-----------------1- Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact\n";
+//	return result;
+
+	BssSnowGrain* s1=static_cast<BssSnowGrain*>(cm1.get()), *s2=static_cast<BssSnowGrain*>(cm2.get());
+	Vector3r normal=se32.position-se31.position;
+	Real penetrationDepthSq=pow((s1->radius+s2->radius),2) - normal.SquaredLength();
+	if (penetrationDepthSq>0 || c->isReal)
+	{
+		shared_ptr<SpheresContactGeometry> scm;
+		if(c->interactionGeometry) scm=YADE_PTR_CAST<SpheresContactGeometry>(c->interactionGeometry);
+		else { scm=shared_ptr<SpheresContactGeometry>(new SpheresContactGeometry()); c->interactionGeometry=scm; }
+
+		Real penetrationDepth=s1->radius+s2->radius-normal.Normalize(); /* Normalize() works in-place and returns length before normalization; from here, normal is unit vector */
+		scm->contactPoint=se31.position+(s1->radius-0.5*penetrationDepth)*normal;//0.5*(pt1+pt2);
+		scm->normal=normal;
+		scm->penetrationDepth=penetrationDepth;
+
+		int id1 = c->getId1();
+		int id2 = c->getId2();
+
+		if(s1->depth.find(id2) == s1->depth.end())
+			s1->depth[id2] = penetrationDepth;
+		if(s2->depth.find(id1) == s2->depth.end())
+			s2->depth[id1] = penetrationDepth;
+
+		Real d1 = s1->depth[id2];
+		Real d2 = s2->depth[id1];
+		if(d1 != d2)
+			std::cerr << "bad initial penetration?\n";
+
+		penetrationDepth -= d1;
+		scm->penetrationDepth=penetrationDepth;
+
+		scm->radius1=s1->radius;
+		scm->radius2=s2->radius;
+		return true;
+	}
+	return false;
+}
+
+
+bool Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact::goReverse(	const shared_ptr<InteractingGeometry>& cm1,
+								const shared_ptr<InteractingGeometry>& cm2,
+								const Se3r& se31,
+								const Se3r& se32,
+								const shared_ptr<Interaction>& c)
+{
+//	std::cerr << "-----------------2- Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact\n";
+	return go(cm1,cm2,se31,se32,c);
+}
+
+YADE_PLUGIN();
+

Added: trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.hpp
===================================================================
--- trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.hpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.hpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -0,0 +1,37 @@
+/*************************************************************************
+*  Copyright (C) 2008 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/pkg-common/InteractionGeometryEngineUnit.hpp>
+#include<yade/pkg-dem/InteractingSphere2InteractingSphere4SpheresContactGeometry.hpp>
+
+class Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact : public InteractionGeometryEngineUnit
+{
+	public :
+		InteractingSphere2InteractingSphere4SpheresContactGeometry g;
+
+		virtual bool go(const shared_ptr<InteractingGeometry>& cm1, const shared_ptr<InteractingGeometry>& cm2, const Se3r& se31, const Se3r& se32, const shared_ptr<Interaction>& c);
+		virtual bool goReverse(	const shared_ptr<InteractingGeometry>& cm1, const shared_ptr<InteractingGeometry>& cm2, const Se3r& se31, const Se3r& se32, const shared_ptr<Interaction>& c);
+					
+		Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact();		
+		
+	REGISTER_CLASS_NAME(Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact);
+	REGISTER_BASE_CLASS_NAME(InteractionGeometryEngineUnit);
+
+	FUNCTOR2D(BssSnowGrain,BssSnowGrain);
+	
+	DEFINE_FUNCTOR_ORDER_2D(BssSnowGrain,BssSnowGrain);
+	
+	protected :
+		virtual void registerAttributes();
+};
+
+REGISTER_SERIALIZABLE(Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact);
+
+

Added: trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.cpp
===================================================================
--- trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.cpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.cpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -0,0 +1,44 @@
+/*************************************************************************
+*  Copyright (C) 2004 by Olivier Galizzi                                 *
+*  olivier.galizzi@xxxxxxx                                               *
+*  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"Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.hpp"
+#include<yade/pkg-dem/SpheresContactGeometry.hpp>
+#include<yade/pkg-common/InteractingSphere.hpp>
+#include<yade/pkg-common/InteractingBox.hpp>
+
+#include<yade/lib-base/yadeWm3Extra.hpp>
+
+
+bool Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact::go(
+		const shared_ptr<InteractingGeometry>& cm1,
+		const shared_ptr<InteractingGeometry>& cm2,
+		const Se3r& se31,
+		const Se3r& se32,
+		const shared_ptr<Interaction>& c)
+{
+	bool result = g.go(cm1,cm2,se31,se32,c);
+//	std::cerr << "-----------------1- Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact\n";
+	return result;
+}
+
+
+bool Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact::goReverse(	const shared_ptr<InteractingGeometry>& cm1,
+						const shared_ptr<InteractingGeometry>& cm2,
+						const Se3r& se31,
+						const Se3r& se32,
+						const shared_ptr<Interaction>& c)
+{
+	bool result = g.goReverse(cm1,cm2,se31,se32,c);
+//	std::cerr << "-----------------2- Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact\n";
+	return result;
+}
+
+YADE_PLUGIN();
+

Added: trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.hpp
===================================================================
--- trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.hpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.hpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -0,0 +1,40 @@
+/*************************************************************************
+*  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. *
+*************************************************************************/
+
+#pragma once
+
+#include<yade/pkg-common/InteractionGeometryEngineUnit.hpp>
+#include<yade/pkg-dem/InteractingBox2InteractingSphere4SpheresContactGeometry.hpp>
+
+class Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact : public InteractionGeometryEngineUnit
+{
+	InteractingBox2InteractingSphere4SpheresContactGeometry g;
+	public :
+		virtual bool go(	const shared_ptr<InteractingGeometry>& cm1,
+					const shared_ptr<InteractingGeometry>& cm2,
+					const Se3r& se31,
+					const Se3r& se32,
+					const shared_ptr<Interaction>& c);
+
+		virtual bool goReverse(	const shared_ptr<InteractingGeometry>& cm1,
+					const shared_ptr<InteractingGeometry>& cm2,
+					const Se3r& se31,
+					const Se3r& se32,
+					const shared_ptr<Interaction>& c);
+
+	REGISTER_CLASS_NAME(Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact);
+	REGISTER_BASE_CLASS_NAME(InteractionGeometryEngineUnit);
+
+	FUNCTOR2D(InteractingBox,BssSnowGrain);
+
+	DEFINE_FUNCTOR_ORDER_2D(InteractingBox,BssSnowGrain);
+};
+
+REGISTER_SERIALIZABLE(Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact);
+
+

Modified: trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp
===================================================================
--- trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -68,8 +68,10 @@
 
 #include"SnowVoxelsLoader.hpp"
 #include<set>
-#include<yade/pkg-snow/Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.hpp>
-#include<yade/pkg-snow/Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry.hpp>
+#include<yade/pkg-snow/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.hpp>
+#include<yade/pkg-snow/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.hpp>
+//#include<yade/pkg-snow/Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.hpp>
+//#include<yade/pkg-snow/Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry.hpp>
 
 SnowVoxelsLoader::SnowVoxelsLoader() : FileGenerator()
 {
@@ -96,7 +98,7 @@
 
 	spheresColor		= Vector3r(0.8,0.3,0.3);
 
-// a pixel is 20.4 microns (2.04 × 10-5 meters)
+// a pixel is 20.4 microns (2.04 �10-5 meters)
 // the sample was 10.4mm high
 	one_voxel_in_meters_is	= 2.04e-5;
 
@@ -358,8 +360,10 @@
 	
 	shared_ptr<InteractionGeometryMetaEngine> interactionGeometryDispatcher(new InteractionGeometryMetaEngine);
 
-	shared_ptr<InteractionGeometryEngineUnit> s1(new Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry);  //GRR 
-	shared_ptr<InteractionGeometryEngineUnit> s2(new Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry);//GRR 
+	shared_ptr<InteractionGeometryEngineUnit> s1(new Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact);
+	shared_ptr<InteractionGeometryEngineUnit> s2(new Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact);
+	//shared_ptr<InteractionGeometryEngineUnit> s1(new Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry);
+	//shared_ptr<InteractionGeometryEngineUnit> s2(new Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry);
 	//shared_ptr<InteractionGeometryEngineUnit> s1(new InteractingSphere2InteractingSphere4SpheresContactGeometry);
 	//shared_ptr<InteractionGeometryEngineUnit> s2(new InteractingBox2InteractingSphere4SpheresContactGeometry);
 	
@@ -533,8 +537,8 @@
 	shared_ptr<BshSnowGrain> gSnowGrain(grain);
 	
 
-	shared_ptr<BssSnowGrain> iSphere(new BssSnowGrain(gSnowGrain.get(),one_voxel_in_meters_is));//GRR 
-	Real radius = iSphere->radius;                                                              //GRR 
+	shared_ptr<BssSnowGrain> iSphere(new BssSnowGrain(gSnowGrain.get(),one_voxel_in_meters_is)); 
+	Real radius = iSphere->radius;
 	//shared_ptr<InteractingSphere> iSphere(new InteractingSphere);
 	//Real radius = (grain->start-grain->end).Length()*0.5;
 	
@@ -564,7 +568,7 @@
 	gSnowGrain->visible		= true;
 	gSnowGrain->shadowCaster	= true;
 	
-	//iSphere->radius			= radius; // already calculated //GRR
+	//iSphere->radius			= radius; // already calculated
 	iSphere->diffuseColor		= grain->color;
 
 	body->interactingGeometry	= iSphere;

Modified: trunk/pkg/snow/RenderingEngine/Ef1_BshSnowGrain_glDraw.cpp
===================================================================
--- trunk/pkg/snow/RenderingEngine/Ef1_BshSnowGrain_glDraw.cpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/RenderingEngine/Ef1_BshSnowGrain_glDraw.cpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -42,7 +42,7 @@
 	Real LEN=(gr->start - gr->end).Length();
 
 	glColor3f(0.5,0.5,1.0);
-	glutSolidCube(LEN*0.1);
+	glutWireCube(LEN*0.1);
 
   	glMaterialv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Vector3f(gm->diffuseColor[0],gm->diffuseColor[1],gm->diffuseColor[2]));
 	glColor3v(gm->diffuseColor);
@@ -72,8 +72,8 @@
 		glDisable(GL_LIGHTING);
 		glBegin(GL_LINE_STRIP);
 			glColor3f(0,0,0);
-			glVertex3d(gr->start[0],gr->start[1],gr->start[2]);
-			glVertex3d(gr->end[0]  ,gr->end[1]  ,gr->end[2]);
+			glVertex3v(gr->start);
+			glVertex3v(gr->end);
 		glEnd();
 			glColor3v(gm->diffuseColor);
 			for(size_t i=0;i < gr->slices.size();++i)
@@ -132,9 +132,11 @@
 //	}
 */
 
+
+/*
+
 // check inside of selected grain, with grain 17
 
-
 //if(!surface)
 //{
 
@@ -227,10 +229,10 @@
 	}
 //}
 
+*/
 
 
 
-
 	// check current grain insides
 //if(!surface)
 //{

Modified: trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.cpp
===================================================================
--- trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.cpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.cpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -8,12 +8,142 @@
 
 #include"Ef1_BssSnowGrain_glDraw.hpp"
 #include<yade/pkg-snow/BssSnowGrain.hpp>
+#include<yade/pkg-snow/BshSnowGrain.hpp>
 #include<yade/lib-opengl/OpenGLWrapper.hpp>
 
+void triangle(Vector3r a,Vector3r b, Vector3r c,Vector3r n)
+{
+	glNormal3v(n);
+	glVertex3v(a);
+	glVertex3v(b);
+	glVertex3v(c);
+}
 
+void quad(Vector3r a,Vector3r b, Vector3r c, Vector3r d,Vector3r n)
+{
+	glNormal3v(n);
+	glVertex3v(a);
+	glVertex3v(b);
+	glVertex3v(c);
+	glVertex3v(d);
+}
+
 void Ef1_BssSnowGrain_glDraw::go(const shared_ptr<InteractingGeometry>& cm, const shared_ptr<PhysicalParameters>& pp,bool wire)
 {
-	s.go(cm,pp,wire);
+	bool surface = !wire;
+	BssSnowGrain* bssgr = static_cast<BssSnowGrain*>(cm.get());
+	BshSnowGrain& gr = bssgr->m_copy;
+
+  	glMaterialv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Vector3f(cm->diffuseColor[0],cm->diffuseColor[1],cm->diffuseColor[2]));
+	glColor3v(cm->diffuseColor);
+
+	const std::vector<boost::tuple<Vector3r,Vector3r,Vector3r,Vector3r> >& f(gr.get_faces_const_ref());
+	if(surface)
+	{
+		glDisable(GL_CULL_FACE);
+		glEnable(GL_LIGHTING);
+		glShadeModel(GL_FLAT);
+		glBegin(GL_TRIANGLES);
+			for(size_t i = 0; i < f.size() ; ++i)
+			{
+				Vector3r a(get<0>(f[i]));
+				Vector3r b(get<1>(f[i]));
+				Vector3r c(get<2>(f[i]));
+				Vector3r n(get<3>(f[i]));
+				// plot the triangular face
+				triangle(a,b,c,n);
+				
+				// plot the depth tetrahedron
+				Real depth = gr.depth(i);
+				Vector3r Z((a+b+c)/3.0 + n*depth);
+				Vector3r N1((Z - a).Cross(a - b));
+				Vector3r N2((Z - c).Cross(c - a));
+				Vector3r N3((Z - b).Cross(b - c));
+				
+				triangle(b,a,Z,N1);
+				triangle(a,c,Z,N2);
+				triangle(c,b,Z,N3);
+				
+				// plot the parallelepiped top-face at the half depth
+				Real depth2 = depth*0.5;
+				Vector3r N(n*depth2);
+				Vector3r A(a+N);
+				Vector3r B(b+N);
+				Vector3r C(c+N);
+				triangle(A,B,C,n);
+			}
+		glEnd();
+		glBegin(GL_QUADS);
+			for(size_t i = 0; i < f.size() ; ++i)
+			{
+				Vector3r a(get<0>(f[i]));
+				Vector3r b(get<1>(f[i]));
+				Vector3r c(get<2>(f[i]));
+				Vector3r n(get<3>(f[i]));
+				// plot the parallelepiped side faces (quads)
+				Real depth = gr.depth(i)*0.5;
+				Vector3r N(n*depth);
+				Vector3r A(a+N);
+				Vector3r B(b+N);
+				Vector3r C(c+N);
+
+				Vector3r Z((a+b+c)/3.0 + n*depth);
+				Vector3r N1((A - a).Cross(a - b));
+				Vector3r N2((C - c).Cross(c - a));
+				Vector3r N3((B - b).Cross(b - c));
+				
+				quad(b,a,A,B,N1);
+				quad(a,c,C,A,N2);
+				quad(c,b,B,C,N3);
+			}
+		glEnd();
+		glShadeModel(GL_SMOOTH);
+		glEnable(GL_CULL_FACE);
+	}
+	else
+	{
+		glDisable(GL_LIGHTING);
+			glColor3v(cm->diffuseColor);
+			for(size_t i=0;i < gr.slices.size();++i)
+			{
+				glBegin(GL_LINE_STRIP);
+					for(size_t j=0 ; j < gr.slices[i].size() ; ++j)
+						glVertex3v(gr.slices[i][j]);
+					glVertex3v(gr.slices[i][0]);
+				glEnd();
+			}
+		glBegin(GL_LINES);
+			for(size_t i = 0; i < f.size() ; ++i)
+			{
+				Vector3r a(get<0>(f[i]));
+				Vector3r b(get<1>(f[i]));
+				Vector3r c(get<2>(f[i]));
+				Vector3r n(get<3>(f[i]));
+				// plot the depth tetrahedron
+				Real depth = gr.depth(i);
+				Vector3r Z((a+b+c)/3.0 + n*depth);
+				glVertex3v(a);glVertex3v(Z);
+				glVertex3v(b);glVertex3v(Z);
+				glVertex3v(c);glVertex3v(Z);
+				
+				// plot the parallelepiped top-face at the half depth
+				Real depth2 = depth*0.5;
+				Vector3r N(n*depth2);
+				Vector3r A(a+N);
+				Vector3r B(b+N);
+				Vector3r C(c+N);
+
+				glVertex3v(A);glVertex3v(B);
+				glVertex3v(B);glVertex3v(C);
+				glVertex3v(C);glVertex3v(A);
+
+				glVertex3v(a);glVertex3v(A);
+				glVertex3v(b);glVertex3v(B);
+				glVertex3v(c);glVertex3v(C);
+			}
+		glEnd();
+		glEnable(GL_LIGHTING);
+	}
 }
 
 

Modified: trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.hpp
===================================================================
--- trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.hpp	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/RenderingEngine/Ef1_BssSnowGrain_glDraw.hpp	2009-01-26 03:34:03 UTC (rev 1643)
@@ -9,12 +9,10 @@
 #pragma once
 
 #include<yade/pkg-common/GLDrawFunctors.hpp>
-#include<yade/pkg-common/GLDrawInteractingSphere.hpp>
 
 class Ef1_BssSnowGrain_glDraw : public GLDrawInteractingGeometryFunctor
 {
 	public :
-		GLDrawInteractingSphere s;
 		virtual void go(const shared_ptr<InteractingGeometry>&, const shared_ptr<PhysicalParameters>&,bool);
 
 	RENDERS(BssSnowGrain);

Modified: trunk/pkg/snow/SConscript
===================================================================
--- trunk/pkg/snow/SConscript	2009-01-25 22:32:18 UTC (rev 1642)
+++ trunk/pkg/snow/SConscript	2009-01-26 03:34:03 UTC (rev 1643)
@@ -4,20 +4,34 @@
 env.Install('$PREFIX/lib/yade$SUFFIX/pkg-snow',[
 
 
+	env.SharedLibrary('IstSnowLayersContact',
+		['DataClass/IstSnowLayersContact.cpp'],
+		LIBS=env['LIBS']+['yade-serialization','yade-base','SpheresContactGeometry']),
+
+	env.SharedLibrary('Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact',
+	['Engine/Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact.cpp'],
+		LIBS=env['LIBS']+['BshSnowGrain','yade-opengl','yade-base',
+		'BssSnowGrain','InteractingBox','InteractingBox2InteractingSphere4SpheresContactGeometry']),
+	
+	env.SharedLibrary('Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact',
+	['Engine/Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact.cpp'],
+		LIBS=env['LIBS']+['BshSnowGrain','yade-opengl','yade-base',
+		'BssSnowGrain','InteractingSphere','InteractingSphere2InteractingSphere4SpheresContactGeometry']),
+
 	env.SharedLibrary('Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry',
 	['Engine/Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry.cpp'],
 		LIBS=env['LIBS']+['BshSnowGrain','yade-opengl','yade-base',
 		'BssSnowGrain','InteractingBox','InteractingBox2InteractingSphere4SpheresContactGeometry']),
 	
-	env.SharedLibrary('Ef2_BssSnowGrain_AABB_makeAABB',['Engine/Ef2_BssSnowGrain_AABB_makeAABB.cpp'],
-		LIBS=env['LIBS']+['BoundingVolumeMetaEngine','InteractingSphere','BssSnowGrain','AABB']),
-	
 	env.SharedLibrary('Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry',['Engine/Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.cpp'],
 		LIBS=env['LIBS']+['BshSnowGrain','yade-opengl','yade-base',
 		'BssSnowGrain','InteractingSphere','InteractingSphere2InteractingSphere4SpheresContactGeometry']),
 
+	env.SharedLibrary('Ef2_BssSnowGrain_AABB_makeAABB',['Engine/Ef2_BssSnowGrain_AABB_makeAABB.cpp'],
+		LIBS=env['LIBS']+['BoundingVolumeMetaEngine','InteractingSphere','BssSnowGrain','AABB']),
+	
 	env.SharedLibrary('Ef1_BssSnowGrain_glDraw',['RenderingEngine/Ef1_BssSnowGrain_glDraw.cpp'],
-		LIBS=env['LIBS']+['BshSnowGrain','yade-opengl','yade-base','GLDrawInteractingSphere','BssSnowGrain','$QGLVIEWER_LIB']),
+		LIBS=env['LIBS']+['BshSnowGrain','yade-opengl','yade-base','BssSnowGrain','$QGLVIEWER_LIB']),
 
 	env.SharedLibrary('Ef1_BshSnowGrain_glDraw',['RenderingEngine/Ef1_BshSnowGrain_glDraw.cpp'],
 		LIBS=env['LIBS']+['BshSnowGrain','yade-opengl','yade-base','$QGLVIEWER_LIB']),
@@ -39,6 +53,8 @@
 			'BshSnowGrain',
 			'BssSnowGrain',
 			'VelocityRecorder',
+			'Ef2_InteractingBox_BssSnowGrain_makeIstSnowLayersContact',
+			'Ef2_BssSnowGrain_BssSnowGrain_makeIstSnowLayersContact',
 			'Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry',
 			'Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry',
 			'ForceRecorder',




Follow ups