yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #00683
[svn] r1531 - in trunk: core/DefaultContainerImplementations gui/py gui/qt3 pkg/common/Container pkg/dem/Engine/EngineUnit pkg/dem/RenderingEngine/GLDrawSpheresContactGeometry
Author: eudoxos
Date: 2008-09-29 08:37:41 +0200 (Mon, 29 Sep 2008)
New Revision: 1531
Added:
trunk/gui/qt3/SnapshotEngine.cpp
trunk/gui/qt3/SnapshotEngine.hpp
Modified:
trunk/core/DefaultContainerImplementations/BodyRedirectionVector.cpp
trunk/gui/py/yadeControl.cpp
trunk/gui/qt3/GLViewer.cpp
trunk/gui/qt3/qt.py
trunk/pkg/common/Container/BodyAssocVector.cpp
trunk/pkg/dem/Engine/EngineUnit/InteractingFacet2InteractingSphere4SpheresContactGeometry.cpp
trunk/pkg/dem/RenderingEngine/GLDrawSpheresContactGeometry/GLDrawSpheresContactGeometry.cpp
Log:
1. Add forgotten SnapshotEngine
2. BodyRedirectionVector always really find the lowest unused ID (the same for BodyAssocVector)
3. add Omega().interactions.clear() in python
4. Move the "Less than 500 bodies, moving possible" to LOG_INFO instead of on-screen since it disturbs videos taken during simulation...
Modified: trunk/core/DefaultContainerImplementations/BodyRedirectionVector.cpp
===================================================================
--- trunk/core/DefaultContainerImplementations/BodyRedirectionVector.cpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/core/DefaultContainerImplementations/BodyRedirectionVector.cpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -73,7 +73,8 @@
// FIXME - make sure that this is correct
unsigned int BodyRedirectionVector::insert(shared_ptr<Body>& b)
{
- unsigned int position = b->getId();
+ //unsigned int position = b->getId();
+ unsigned position=0;
// std::vector< shared_ptr<Body> >::iterator tmpVii = bodies.begin();
// std::vector< shared_ptr<Body> >::iterator tmpViiEnd = bodies.end();
Modified: trunk/gui/py/yadeControl.cpp
===================================================================
--- trunk/gui/py/yadeControl.cpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/gui/py/yadeControl.cpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -289,6 +289,7 @@
void clear(){proxee->clear();}
};
+
class pyTags{
public:
pyTags(const shared_ptr<MetaBody> _mb): mb(_mb){}
@@ -345,6 +346,7 @@
long i=0; FOREACH(const shared_ptr<Interaction>& I, *proxee){ if(!I->isReal) continue; if(i++==n) return pyInteraction(I); }
throw invalid_argument(string("Interaction number out of range (")+lexical_cast<string>(n)+">="+lexical_cast<string>(i)+").");
}
+ void clear(){proxee->clear();}
};
@@ -550,7 +552,8 @@
boost::python::class_<pyInteractionContainer>("InteractionContainer",python::init<pyInteractionContainer&>())
.def("__iter__",&pyInteractionContainer::pyIter)
.def("__getitem__",&pyInteractionContainer::pyGetitem)
- .def("nth",&pyInteractionContainer::pyNth);
+ .def("nth",&pyInteractionContainer::pyNth)
+ .def("clear",&pyInteractionContainer::clear);
boost::python::class_<pyInteractionIterator>("InteractionIterator",python::init<pyInteractionIterator&>())
.def("__iter__",&pyInteractionIterator::pyIter)
.def("next",&pyInteractionIterator::pyNext);
Modified: trunk/gui/qt3/GLViewer.cpp
===================================================================
--- trunk/gui/qt3/GLViewer.cpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/gui/qt3/GLViewer.cpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -312,8 +312,8 @@
MetaBody* rb=Omega::instance().getRootBody().get();
if (!rb) return;
- if(rb->bodies->size() < 500) displayMessage("Less than 500 bodies, moving possible. Select with shift, press 'm' to move. Use / * - + for cutting plane.", 6000);
- else displayMessage("More than 500 bodies. Moving not possible. Use / * - + for cutting plane.", 6000);
+ if(rb->bodies->size()<500){LOG_INFO("Less than 500 bodies, moving possible. Select with shift, press 'm' to move.");}
+ else{LOG_INFO("More than 500 bodies. Moving not possible.");}
Vector3r min,max;
if(rb->boundingVolume){
min=rb->boundingVolume->min; max=rb->boundingVolume->max;
Added: trunk/gui/qt3/SnapshotEngine.cpp
===================================================================
--- trunk/gui/qt3/SnapshotEngine.cpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/gui/qt3/SnapshotEngine.cpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -0,0 +1,17 @@
+#include"SnapshotEngine.hpp"
+#include<sstream>
+#include<iomanip>
+CREATE_LOGGER(SnapshotEngine);
+void SnapshotEngine::action(MetaBody* rb){
+ shared_ptr<GLViewer> glv;
+ if(!YadeQtMainWindow::self || ((size_t)viewNo>=YadeQtMainWindow::self->glViews.size()) || !(glv=YadeQtMainWindow::self->glViews[viewNo])){
+ if(!ignoreErrors) throw invalid_argument("View #"+lexical_cast<string>(viewNo)+" (SnapshotEngine::viewNo) doesn't exist.");
+ return;
+ }
+ ostringstream fss; fss<<fileBase<<setw(4)<<setfill('0')<<counter++<<".png";
+ LOG_DEBUG("GL view #"<<viewNo<<" → "<<fss.str())
+ glv->setSnapshotFormat("PNG");
+ glv->saveSnapshot(QString(fss.str()),/*overwrite*/ true);
+ savedSnapshots.push_back(fss.str());
+}
+
Added: trunk/gui/qt3/SnapshotEngine.hpp
===================================================================
--- trunk/gui/qt3/SnapshotEngine.hpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/gui/qt3/SnapshotEngine.hpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -0,0 +1,38 @@
+#pragma once
+#include<yade/core/StandAloneEngine.hpp>
+#include<yade/gui-qt3/GLViewer.hpp>
+#include<yade/gui-qt3/YadeQtMainWindow.hpp>
+#include<yade/pkg-common/PeriodicEngines.hpp>
+/*! Engine for saving snapshots of GLView(s) as .png files.
+ *
+ * Derives from PeriodicEngine, which has detailed information on controlling periodicity.
+ *
+ * The files are named fileBase+counter+".png" (counter is left-padded by 0s, i.e. snap0004.png)
+ */
+class SnapshotEngine: public PeriodicEngine{
+ public:
+ //! Basename for snapshots
+ string fileBase;
+ //! Number appended to fileBase
+ int counter;
+ //! The GLView number that we save (default: 0, i.e. primary view)
+ int viewNo;
+ //! Silently return if selected view doesn't exist (default: true)
+ bool ignoreErrors;
+ //! files that have been created so far
+ vector<string> savedSnapshots;
+ SnapshotEngine():counter(0),viewNo(0),ignoreErrors(true){}
+ virtual void action(MetaBody*);
+ void registerAttributes(){
+ PeriodicEngine::registerAttributes();
+ REGISTER_ATTRIBUTE(fileBase);
+ REGISTER_ATTRIBUTE(counter);
+ REGISTER_ATTRIBUTE(viewNo);
+ REGISTER_ATTRIBUTE(ignoreErrors);
+ REGISTER_ATTRIBUTE(savedSnapshots);
+ }
+ DECLARE_LOGGER;
+ REGISTER_CLASS_NAME(SnapshotEngine);
+ REGISTER_BASE_CLASS_NAME(PeriodicEngine);
+};
+REGISTER_SERIALIZABLE(SnapshotEngine,false);
Modified: trunk/gui/qt3/qt.py
===================================================================
--- trunk/gui/qt3/qt.py 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/gui/qt3/qt.py 2008-09-29 06:37:41 UTC (rev 1531)
@@ -15,7 +15,7 @@
viewNo is 0-based GL view number. 0 is the primary view and will be created if it doesn't exist.
It is an error if viewNo>0 and the view doesn't exist.
- The simulation will run until it stops by itself. Either set Omega().stopAtIteration or have an engine
+ The simulation will run until it stops by itself. Either set Omega().stopAtIter or have an engine
that will call Omega().pause() at some point.
See makePlayerVideo for more documentation.
Modified: trunk/pkg/common/Container/BodyAssocVector.cpp
===================================================================
--- trunk/pkg/common/Container/BodyAssocVector.cpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/pkg/common/Container/BodyAssocVector.cpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -80,7 +80,8 @@
// BodyContainer::setId(b,max);
// return max;
- unsigned int position = b->getId();
+ //unsigned int position = b->getId();
+ unsigned int position=0;
Loki::AssocVector<unsigned int , shared_ptr<Body> >::const_iterator tmpBii;
tmpBii = bodies.find(position);
@@ -88,8 +89,7 @@
{
// finds the first free key, which is bigger than 0 (was: newPoistion=position, i.e. greater than id... why?)
unsigned int newPosition = 0;
- while( bodies.find(newPosition) != bodies.end() )
- ++newPosition;
+ while( bodies.find(newPosition) != bodies.end() ) ++newPosition;
//cerr << "WARNING: body id=\"" << position << "\" is already used. Using first free id=\"" << newPosition << "\", beware - if you are loading a file, this will break interactions for this body!\n";
position = newPosition;
}
Modified: trunk/pkg/dem/Engine/EngineUnit/InteractingFacet2InteractingSphere4SpheresContactGeometry.cpp
===================================================================
--- trunk/pkg/dem/Engine/EngineUnit/InteractingFacet2InteractingSphere4SpheresContactGeometry.cpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/pkg/dem/Engine/EngineUnit/InteractingFacet2InteractingSphere4SpheresContactGeometry.cpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -122,7 +122,6 @@
scm->cp2rel.Align(Vector3r::UNIT_X,se32.orientation.Conjugate()*(-normal));
scm->cp1rel.Normalize(); scm->cp2rel.Normalize();
}
- cerr<<"@@ "<<scm->epsT()<<endl;
}
return true;
Modified: trunk/pkg/dem/RenderingEngine/GLDrawSpheresContactGeometry/GLDrawSpheresContactGeometry.cpp
===================================================================
--- trunk/pkg/dem/RenderingEngine/GLDrawSpheresContactGeometry/GLDrawSpheresContactGeometry.cpp 2008-09-28 12:37:30 UTC (rev 1530)
+++ trunk/pkg/dem/RenderingEngine/GLDrawSpheresContactGeometry/GLDrawSpheresContactGeometry.cpp 2008-09-29 06:37:41 UTC (rev 1531)
@@ -80,13 +80,8 @@
Vector3r contPt=se31.position+(sc->d1/sc->d0)*(se32.position-se31.position); // must be recalculated to not be unscaled if scaling displacements ...
GLUtils::GLDrawLine(pos1,pos2,Vector3r(.5,.5,.5));
// sphere center to point on the sphere
- //GLUtils::GLDrawText("[1]",sc->pos1,Vector3r(1,1,1)); GLUtils::GLDrawText("[2]",sc->pos2,Vector3r(1,1,1));
- GLUtils::GLDrawLine(pos1,pos1+(sc->ori1*sc->cp1rel*Vector3r::UNIT_X*sc->d1),Vector3r(0,.5,1));
- GLUtils::GLDrawLine(pos2,pos2+(sc->ori2*sc->cp2rel*Vector3r::UNIT_X*sc->d2),Vector3r(0,1,.5));
- //cerr<<"=== cp1rel="<<sc->cp1rel[0]<<";"<<sc->cp1rel[1]<<";"<<sc->cp1rel[2]<<";"<<sc->cp1rel[3]<<endl;
- //cerr<<"=== ori1="<<sc->ori1[0]<<";"<<sc->ori1[1]<<";"<<sc->ori1[2]<<";"<<sc->ori1[3]<<endl;
- //cerr<<"+++ cp1rel="<<sc->cp1rel<<", ori1="<<sc->ori1<<", cp1rel*ori1="<<sc->cp1rel*sc->ori1<<endl;
- //<<", *UNIT_X="<<sc->cp1rel*sc->ori1*Vector3r::UNIT_X<<", +pos1="<<sc->pos1+(sc->cp1rel*sc->ori1*Vector3r::UNIT_X)<<endl;
+ //GLUtils::GLDrawLine(pos1,pos1+(sc->ori1*sc->cp1rel*Vector3r::UNIT_X*sc->d1),Vector3r(0,.5,1));
+ //GLUtils::GLDrawLine(pos2,pos2+(sc->ori2*sc->cp2rel*Vector3r::UNIT_X*sc->d2),Vector3r(0,1,.5));
// contact point to projected points
Vector3r ptTg1=sc->contPtInTgPlane1(), ptTg2=sc->contPtInTgPlane2();
GLUtils::GLDrawLine(contPt,contPt+ptTg1,Vector3r(0,.5,1));
@@ -94,7 +89,7 @@
// projected shear
GLUtils::GLDrawLine(contPt+ptTg1,contPt+ptTg2,Vector3r(1,1,1));
//
- GLUtils::GLDrawNum(sc->epsN(),contPt,Vector3r(1,1,1));
+ //GLUtils::GLDrawNum(sc->epsN(),contPt,Vector3r(1,1,1));
}