yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #00725
[svn] r1546 - in trunk: extra gui/py gui/qt3 pkg/common/RenderingEngine/GLDrawGeometricalModel
Author: eudoxos
Date: 2008-10-16 12:26:12 +0200 (Thu, 16 Oct 2008)
New Revision: 1546
Modified:
trunk/extra/Brefcom.cpp
trunk/extra/Brefcom.hpp
trunk/gui/py/yadeControl.cpp
trunk/gui/qt3/YadeQtMainWindow.cpp
trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawFacet.cpp
Log:
1. Add Body().mask in python
2. Add PhysicalParameters().pos and .ori instead of ugly pp['se3'][:3] and pp['se3'][3:]
3. Add dmgPlane plot in brefcom
4. Do not delete renderer if we close the last view (loses all renderer settings)
Modified: trunk/extra/Brefcom.cpp
===================================================================
--- trunk/extra/Brefcom.cpp 2008-10-14 09:48:01 UTC (rev 1545)
+++ trunk/extra/Brefcom.cpp 2008-10-16 10:26:12 UTC (rev 1546)
@@ -139,6 +139,11 @@
BC=YADE_PTR_CAST<BrefcomContact>(I->interactionPhysics);
contGeom=YADE_PTR_CAST<SpheresContactGeometry>(I->interactionGeometry);
assert(BC); assert(contGeom);
+ /* kept fully damaged contacts; note that normally the contact is deleted _after_ the BREFCOM_MATERIAL_MODEL,
+ * i.e. if it is 1.0 here, omegaThreshold is >= 1.0 for sure.
+ * &&'ing that just to make sure anyway ...
+ */
+ if(BC->omega>=1.0 && BC->omegaThreshold>=1.0) continue;
// shorthands
Real& epsN(BC->epsN); Vector3r& epsT(BC->epsT); Real& kappaD(BC->kappaD); const Real& xiShear(BC->xiShear); const Real& E(BC->E); const Real& undamagedCohesion(BC->undamagedCohesion); const Real& tanFrictionAngle(BC->tanFrictionAngle); const Real& G(BC->G); const Real& crossSection(BC->crossSection); const Real& tau(BC->tau); const Real& expDmgRate(BC->expDmgRate); const Real& omegaThreshold(BC->omegaThreshold); const Real& transStrainCoeff(BC->transStrainCoeff); const Real& epsTrans(BC->epsTrans); const Real& epsCrackOnset(BC->epsCrackOnset);
@@ -188,6 +193,7 @@
bool GLDrawBrefcomContact::contactLine=true;
bool GLDrawBrefcomContact::dmgLabel=true;
+bool GLDrawBrefcomContact::dmgPlane=false;
bool GLDrawBrefcomContact::epsNLabel=true;
bool GLDrawBrefcomContact::epsT=false;
bool GLDrawBrefcomContact::epsTAxes=false;
@@ -206,9 +212,29 @@
min(1.,max(0.,BC->epsTrans/BC->epsCrackOnset)),
min(1.,max(0.,abs(BC->epsTrans)/BC->epsCrackOnset-1)));
- if(contactLine) GLUtils::GLDrawLine(b1->physicalParameters->dispSe3.position,b2->physicalParameters->dispSe3.position,lineColor);
+ if(contactLine) GLUtils::GLDrawLine(b1->physicalParameters->dispSe3.position,b2->physicalParameters->dispSe3.position,.5*lineColor);
if(dmgLabel){ GLUtils::GLDrawNum(BC->omega,0.5*(b1->physicalParameters->dispSe3.position+b2->physicalParameters->dispSe3.position),lineColor); }
else if(epsNLabel){ GLUtils::GLDrawNum(BC->epsN,0.5*(b1->physicalParameters->dispSe3.position+b2->physicalParameters->dispSe3.position),lineColor); }
+ if(BC->omega>0 && dmgPlane){
+ Real halfSize=sqrt(BC->omega)*.705*sqrt(BC->crossSection);
+ Vector3r midPt=.5*Vector3r(b1->physicalParameters->dispSe3.position+b2->physicalParameters->dispSe3.position);
+ glDisable(GL_CULL_FACE);
+ glPushMatrix();
+ glTranslatev(midPt);
+ Quaternionr q; q.Align(Vector3r::UNIT_Z,geom->normal);
+ Vector3r axis; Real angle; q.ToAxisAngle(axis,angle);
+ glRotatef(angle*Mathr::RAD_TO_DEG,axis[0],axis[1],axis[2]);
+ glBegin(GL_POLYGON);
+ glColor3v(lineColor);
+ glVertex3d(halfSize,0.,0.);
+ glVertex3d(.5*halfSize,.866*halfSize,0.);
+ glVertex3d(-.5*halfSize,.866*halfSize,0.);
+ glVertex3d(-halfSize,0.,0.);
+ glVertex3d(-.5*halfSize,-.866*halfSize,0.);
+ glVertex3d(.5*halfSize,-.866*halfSize,0.);
+ glEnd();
+ glPopMatrix();
+ }
const Vector3r& cp=static_pointer_cast<SpheresContactGeometry>(i->interactionGeometry)->contactPoint;
if(epsT){
Modified: trunk/extra/Brefcom.hpp
===================================================================
--- trunk/extra/Brefcom.hpp 2008-10-14 09:48:01 UTC (rev 1545)
+++ trunk/extra/Brefcom.hpp 2008-10-16 10:26:12 UTC (rev 1546)
@@ -233,12 +233,12 @@
class GLDrawBrefcomContact: public GLDrawInteractionPhysicsFunctor {
public: virtual void go(const shared_ptr<InteractionPhysics>&,const shared_ptr<Interaction>&,const shared_ptr<Body>&,const shared_ptr<Body>&,bool wireFrame);
virtual ~GLDrawBrefcomContact() {};
- virtual void registerAttributes(){ REGISTER_ATTRIBUTE(contactLine); REGISTER_ATTRIBUTE(dmgLabel); REGISTER_ATTRIBUTE(epsT); REGISTER_ATTRIBUTE(epsTAxes); REGISTER_ATTRIBUTE(normal); REGISTER_ATTRIBUTE(colorStrain); REGISTER_ATTRIBUTE(epsNLabel);}
+ virtual void registerAttributes(){ REGISTER_ATTRIBUTE(contactLine); REGISTER_ATTRIBUTE(dmgLabel); REGISTER_ATTRIBUTE(dmgPlane); REGISTER_ATTRIBUTE(epsT); REGISTER_ATTRIBUTE(epsTAxes); REGISTER_ATTRIBUTE(normal); REGISTER_ATTRIBUTE(colorStrain); REGISTER_ATTRIBUTE(epsNLabel);}
RENDERS(BrefcomContact);
REGISTER_CLASS_NAME(GLDrawBrefcomContact);
REGISTER_BASE_CLASS_NAME(GLDrawInteractionPhysicsFunctor);
DECLARE_LOGGER;
- static bool contactLine,dmgLabel,epsT,epsTAxes,normal,colorStrain,epsNLabel;
+ static bool contactLine,dmgLabel,dmgPlane,epsT,epsTAxes,normal,colorStrain,epsNLabel;
};
REGISTER_SERIALIZABLE(GLDrawBrefcomContact,false);
Modified: trunk/gui/py/yadeControl.cpp
===================================================================
--- trunk/gui/py/yadeControl.cpp 2008-10-14 09:48:01 UTC (rev 1545)
+++ trunk/gui/py/yadeControl.cpp 2008-10-16 10:26:12 UTC (rev 1546)
@@ -150,6 +150,10 @@
throw std::invalid_argument("Invalid DOF specification `"+s+"', must be ∈{x,y,z,rx,ry,rz}.");
}
}
+ python::tuple pos_get(){const Vector3r& p=proxee->se3.position; return python::make_tuple(p[0],p[1],p[2]);}
+ python::tuple ori_get(){Vector3r axis; Real angle; proxee->se3.orientation.ToAxisAngle(axis,angle); return python::make_tuple(axis[0],axis[1],axis[2],angle);}
+ void pos_set(python::list l){if(python::len(l)!=3) throw invalid_argument("Wrong number of vector3 elements "+lexical_cast<string>(python::len(l))+", should be 3"); proxee->se3.position=Vector3r(python::extract<double>(l[0])(),python::extract<double>(l[1])(),python::extract<double>(l[2])());}
+ void ori_set(python::list l){if(python::len(l)!=4) throw invalid_argument("Wrong number of quaternion elements "+lexical_cast<string>(python::len(l))+", should be 4"); proxee->se3.orientation=Quaternionr(Vector3r(python::extract<double>(l[0])(),python::extract<double>(l[1])(),python::extract<double>(l[2])()),python::extract<double>(l[3])());}
BASIC_PY_PROXY_TAIL;
BASIC_PY_PROXY(pyBoundingVolume,BoundingVolume);
@@ -271,6 +275,8 @@
NONPOD_ATTRIBUTE_ACCESS(bound,pyBoundingVolume,boundingVolume);
NONPOD_ATTRIBUTE_ACCESS(phys,pyPhysicalParameters,physicalParameters);
unsigned id_get(){ensureAcc(); return proxee->getId();}
+ int mask_get(){ensureAcc(); return proxee->groupMask;}
+ void mask_set(int m){ensureAcc(); proxee->groupMask=m;}
bool isStandalone(){ensureAcc(); return proxee->isStandalone();} bool isClumpMember(){ensureAcc(); return proxee->isClumpMember();} bool isClump(){ensureAcc(); return proxee->isClump();}
BASIC_PY_PROXY_TAIL;
@@ -585,7 +591,10 @@
BASIC_PY_PROXY_WRAPPER(pyGeometricalModel,"GeometricalModel");
BASIC_PY_PROXY_WRAPPER(pyInteractingGeometry,"InteractingGeometry");
BASIC_PY_PROXY_WRAPPER(pyPhysicalParameters,"PhysicalParameters")
- .add_property("blockedDOFs",&pyPhysicalParameters::blockedDOFs_get,&pyPhysicalParameters::blockedDOFs_set);
+ .add_property("blockedDOFs",&pyPhysicalParameters::blockedDOFs_get,&pyPhysicalParameters::blockedDOFs_set)
+ .add_property("pos",&pyPhysicalParameters::pos_get,&pyPhysicalParameters::pos_set)
+ .add_property("ori",&pyPhysicalParameters::ori_get,&pyPhysicalParameters::ori_set)
+ ;
BASIC_PY_PROXY_WRAPPER(pyBoundingVolume,"BoundingVolume");
BASIC_PY_PROXY_WRAPPER(pyInteractionGeometry,"InteractionGeometry");
BASIC_PY_PROXY_WRAPPER(pyInteractionPhysics,"InteractionPhysics");
@@ -598,6 +607,7 @@
.add_property("bound",&pyBody::bound_get,&pyBody::bound_set)
.add_property("phys",&pyBody::phys_get,&pyBody::phys_set)
.add_property("id",&pyBody::id_get)
+ .add_property("mask",&pyBody::mask_get,&pyBody::mask_set)
.add_property("isStandalone",&pyBody::isStandalone)
.add_property("isClumpMember",&pyBody::isClumpMember)
.add_property("isClump",&pyBody::isClump);
Modified: trunk/gui/qt3/YadeQtMainWindow.cpp
===================================================================
--- trunk/gui/qt3/YadeQtMainWindow.cpp 2008-10-14 09:48:01 UTC (rev 1545)
+++ trunk/gui/qt3/YadeQtMainWindow.cpp 2008-10-16 10:26:12 UTC (rev 1546)
@@ -93,7 +93,7 @@
void YadeQtMainWindow::redrawAll(bool force){
// controller has its own timer -- and will update instead of us periodically
- if(renderer && (force /* || (controller && !controller->syncRunning ) */ || (!controller))){
+ if((renderer && glViews.size()>0) && (force /* || (controller && !controller->syncRunning ) */ || (!controller))){
FOREACH(const shared_ptr<GLViewer>& glv,glViews){ if(glv) glv->updateGL(); }
}
}
@@ -205,7 +205,8 @@
if(noOtherViews){
LOG_DEBUG("Deleting primary view (no other views exist).");
glViews.clear();
- renderer=shared_ptr<OpenGLRenderingEngine>();
+ // why delete renderer if we close view? That obliterates all renderer settings.
+ // renderer=shared_ptr<OpenGLRenderingEngine>();
}else{LOG_INFO("Cannot close primary view, other views still exist.");}
return;
}
Modified: trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawFacet.cpp
===================================================================
--- trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawFacet.cpp 2008-10-14 09:48:01 UTC (rev 1545)
+++ trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawFacet.cpp 2008-10-16 10:26:12 UTC (rev 1546)
@@ -29,7 +29,7 @@
}
else
{
- //glDisable(GL_CULL_FACE);
+ glDisable(GL_CULL_FACE);
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//glBegin(GL_TRIANGLES);
glEnable(GL_LIGHTING);