Author: cosurgi
Date: 2009-01-09 14:09:26 +0100 (Fri, 09 Jan 2009)
New Revision: 1618

Modified:
   trunk/pkg/snow/DataClass/BssSnowGrain.hpp
   
trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.cpp
   
trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry.cpp
   trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp
Log:
another small snow update



Modified: trunk/pkg/snow/DataClass/BssSnowGrain.hpp
===================================================================
--- trunk/pkg/snow/DataClass/BssSnowGrain.hpp   2009-01-09 11:44:44 UTC (rev 
1617)
+++ trunk/pkg/snow/DataClass/BssSnowGrain.hpp   2009-01-09 13:09:26 UTC (rev 
1618)
@@ -21,8 +21,8 @@
        protected :
                void registerAttributes();
        REGISTER_CLASS_NAME(BssSnowGrain);
-       REGISTER_BASE_CLASS_NAME(GeometricalModel);
-       REGISTER_CLASS_INDEX(BssSnowGrain,GeometricalModel);
+       REGISTER_BASE_CLASS_NAME(InteractingSphere);
+       REGISTER_CLASS_INDEX(BssSnowGrain,InteractingSphere);
 };
 
 REGISTER_SERIALIZABLE(BssSnowGrain);

Modified: 
trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.cpp
===================================================================
--- 
trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.cpp
  2009-01-09 11:44:44 UTC (rev 1617)
+++ 
trunk/pkg/snow/Engine/Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.cpp
  2009-01-09 13:09:26 UTC (rev 1618)
@@ -5,6 +5,7 @@
 
 #include"Ef2_BssSnowGrain_BssSnowGrain_makeSpheresContactGeometry.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>
@@ -25,9 +26,45 @@
                                                        const Se3r& se32,
                                                        const 
shared_ptr<Interaction>& c)
 {
-       bool result = g.go(cm1,cm2,se32,se32,c);
-       std::cerr << "-------------------1a\n";
-       return result;
+//     bool result = g.go(cm1,cm2,se31,se32,c);
+////   std::cerr << "-------------------1a\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;
 }
 
 
@@ -37,8 +74,7 @@
                                                                const Se3r& 
se32,
                                                                const 
shared_ptr<Interaction>& c)
 {
-       std::cerr << "-------------------2a\n";
-       return g.goReverse(cm1,cm2,se31,se32,c);
+       return go(cm1,cm2,se31,se32,c);
 }
 
 YADE_PLUGIN();

Modified: 
trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry.cpp
===================================================================
--- 
trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry.cpp
        2009-01-09 11:44:44 UTC (rev 1617)
+++ 
trunk/pkg/snow/Engine/Ef2_InteractingBox_BssSnowGrain_makeSpheresContactGeometry.cpp
        2009-01-09 13:09:26 UTC (rev 1618)
@@ -23,8 +23,8 @@
                const Se3r& se32,
                const shared_ptr<Interaction>& c)
 {
-       bool result = g.go(cm1,cm2,se32,se32,c);
-       std::cerr << "-------------------1\n";
+       bool result = g.go(cm1,cm2,se31,se32,c);
+//     std::cerr << "-------------------1\n";
        return result;
 }
 
@@ -35,8 +35,8 @@
                                                const Se3r& se32,
                                                const shared_ptr<Interaction>& 
c)
 {
-       bool result = g.goReverse(cm1,cm2,se32,se32,c);
-       std::cerr << "-------------------2\n";
+       bool result = g.goReverse(cm1,cm2,se31,se32,c);
+//     std::cerr << "-------------------2\n";
        return result;
 }
 

Modified: trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp
===================================================================
--- trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp    2009-01-09 11:44:44 UTC 
(rev 1617)
+++ trunk/pkg/snow/PreProcessor/SnowVoxelsLoader.cpp    2009-01-09 13:09:26 UTC 
(rev 1618)
@@ -358,10 +358,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 
InteractingSphere2InteractingSphere4SpheresContactGeometry);
-       shared_ptr<InteractionGeometryEngineUnit> s2(new 
InteractingBox2InteractingSphere4SpheresContactGeometry);
+       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 
InteractingSphere2InteractingSphere4SpheresContactGeometry);
+       //shared_ptr<InteractionGeometryEngineUnit> s2(new 
InteractingBox2InteractingSphere4SpheresContactGeometry);
        
        interactionGeometryDispatcher->add(s1);
        interactionGeometryDispatcher->add(s2);
@@ -533,10 +533,10 @@
        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<InteractingSphere> iSphere(new InteractingSphere);
-       Real radius = (grain->start-grain->end).Length()*0.5;
+       shared_ptr<BssSnowGrain> iSphere(new 
BssSnowGrain(gSnowGrain.get(),one_voxel_in_meters_is));//GRR 
+       Real radius = iSphere->radius;                                          
                    //GRR 
+       //shared_ptr<InteractingSphere> iSphere(new InteractingSphere);
+       //Real radius = (grain->start-grain->end).Length()*0.5;
        
        Quaternionr 
q;//(Mathr::SymmetricRandom(),Mathr::SymmetricRandom(),Mathr::SymmetricRandom(),Mathr::SymmetricRandom());
        q.FromAxisAngle( Vector3r(0,0,1),0);
@@ -564,7 +564,7 @@
        gSnowGrain->visible             = true;
        gSnowGrain->shadowCaster        = true;
        
-       iSphere->radius                 = radius; // already calculated //GRR
+       //iSphere->radius                       = radius; // already calculated 
//GRR
        iSphere->diffuseColor           = grain->color;
 
        body->interactingGeometry       = iSphere;


_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to