Commit 8806f79d authored by Jan Möbius's avatar Jan Möbius
Browse files

David Progress bar for Isotropic remesher plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8806 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5026aa89
...@@ -13,7 +13,7 @@ void IsotropicRemesherPlugin::initializePlugin() { ...@@ -13,7 +13,7 @@ void IsotropicRemesherPlugin::initializePlugin() {
QSize size(300, 300); QSize size(300, 300);
tool_->resize(size); tool_->resize(size);
connect(tool_->remeshButton, SIGNAL(clicked()), this, SLOT(slotRemesh()) ); connect(tool_->remeshButton, SIGNAL(clicked()), this, SLOT(slotRemeshButtonClicked()) );
connect(tool_->minEdgeLength, SIGNAL(clicked()), this, SLOT(slotSetMinLength()) ); connect(tool_->minEdgeLength, SIGNAL(clicked()), this, SLOT(slotSetMinLength()) );
connect(tool_->maxEdgeLength, SIGNAL(clicked()), this, SLOT(slotSetMaxLength()) ); connect(tool_->maxEdgeLength, SIGNAL(clicked()), this, SLOT(slotSetMaxLength()) );
...@@ -22,6 +22,23 @@ void IsotropicRemesherPlugin::initializePlugin() { ...@@ -22,6 +22,23 @@ void IsotropicRemesherPlugin::initializePlugin() {
emit addToolbox( tr("Isotropic Remesher") , tool_ ); emit addToolbox( tr("Isotropic Remesher") , tool_ );
} }
void IsotropicRemesherPlugin::slotRemeshButtonClicked() {
edgeLength_ = tool_->targetEdgeLength->value();
OpenFlipperThread* thread = new OpenFlipperThread(name() + "IsotropicRemesh"); // Create your thread containing a unique id \n
connect(thread,SIGNAL( state(QString, int)), this,SIGNAL(setJobState(QString, int))); // connect your threads state info to the global one \n
connect(thread,SIGNAL( finished(QString)), this,SIGNAL(finishJob(QString))); // connect your threads finish info to the global one ( you can do the same for a local one ) \n
connect(thread,SIGNAL( function() ), this,SLOT(slotRemesh()),Qt::DirectConnection); // You can directly give a slot of your app that gets called \n
connect(this,SIGNAL( finishJob(QString)), this, SLOT(threadFinished(QString)), Qt::QueuedConnection);
emit startJob( name() + "IsotropicRemesh", "Isotropic remeshing" , 0 , 100 , true); // As long as meshes cannot be locked, this thread has to be blocking. Otherwise, during operation the mesh could be deleted. We don't want that!
thread->start(); // start thread
thread->startProcessing(); // start processing
}
void IsotropicRemesherPlugin::slotRemesh(){ void IsotropicRemesherPlugin::slotRemesh(){
...@@ -31,27 +48,33 @@ void IsotropicRemesherPlugin::slotRemesh(){ ...@@ -31,27 +48,33 @@ void IsotropicRemesherPlugin::slotRemesh(){
//check dataType //check dataType
if ( o_it->dataType(DATA_TRIANGLE_MESH) ) { if ( o_it->dataType(DATA_TRIANGLE_MESH) ) {
double edgeLength = tool_->targetEdgeLength->value();
TriMesh* mesh = PluginFunctions::triMesh(o_it); TriMesh* mesh = PluginFunctions::triMesh(o_it);
IsotropicRemesher< TriMesh > remesher; ProgressEmitter prgEmt(name() + "IsotropicRemesh");
connect (&prgEmt, SIGNAL(changeDescription(QString,QString)), this, SIGNAL(setJobDescription(QString,QString)) );
connect (&prgEmt, SIGNAL(signalJobState(QString,int)), this, SIGNAL(setJobState(QString,int)) );
IsotropicRemesher< TriMesh > remesher(&prgEmt);
remesher.remesh(*mesh, edgeLength); remesher.remesh(*mesh, edgeLength_);
mesh->update_normals(); mesh->update_normals();
emit updatedObject( o_it->id() );
emit updateView();
}else{ }else{
emit log("Remeshing currently only implemented for triangle Meshes"); emit log("Remeshing currently only implemented for triangle Meshes");
} }
} }
} }
void IsotropicRemesherPlugin::threadFinished(QString _jobId) {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DataType(DATA_TRIANGLE_MESH | DATA_POLY_MESH)) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
emit updatedObject( o_it->id() );
emit updateView();
}
}
void IsotropicRemesherPlugin::slotSetMinLength() void IsotropicRemesherPlugin::slotSetMinLength()
{ {
double current = 0.0; double current = 0.0;
......
...@@ -8,20 +8,23 @@ ...@@ -8,20 +8,23 @@
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh> #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh> #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh> #include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/BasePlugin/ProcessInterface.hh>
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh> #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh> #include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include "IsotropicRemesherToolbox.hh" #include "IsotropicRemesherToolbox.hh"
#include "ProgressEmitter.hh"
class IsotropicRemesherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, RPCInterface class IsotropicRemesherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, RPCInterface, ProcessInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(BaseInterface) Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface) Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(LoggingInterface) Q_INTERFACES(LoggingInterface)
Q_INTERFACES(RPCInterface) Q_INTERFACES(RPCInterface)
Q_INTERFACES(ProcessInterface)
signals: signals:
...@@ -43,6 +46,13 @@ signals: ...@@ -43,6 +46,13 @@ signals:
// ToolboxInterface // ToolboxInterface
void addToolbox( QString _name , QWidget* _widget ); void addToolbox( QString _name , QWidget* _widget );
// ProcessInterface
void startJob( QString _jobId, QString _description, int _min, int _max, bool _blocking = false);
void setJobState(QString _jobId, int _value);
void setJobName(QString _jobId, QString _name);
void finishJob(QString _jobId);
void setJobDescription(QString _jobId, QString _description);
private slots: private slots:
...@@ -60,13 +70,17 @@ public : ...@@ -60,13 +70,17 @@ public :
//GUI //GUI
private : private :
IsotropicRemesherToolBox* tool_; IsotropicRemesherToolBox* tool_;
double edgeLength_;
private slots: private slots:
void slotRemesh(); void slotRemesh();
void slotRemeshButtonClicked();
void slotSetMinLength(); void slotSetMinLength();
void slotSetMaxLength(); void slotSetMaxLength();
void slotSetMeanLength(); void slotSetMeanLength();
void threadFinished(QString _jobId);
//scripting functions //scripting functions
public slots: public slots:
......
...@@ -19,17 +19,32 @@ void IsotropicRemesher< MeshT >::remesh( MeshT& _mesh, const double _targetEdgeL ...@@ -19,17 +19,32 @@ void IsotropicRemesher< MeshT >::remesh( MeshT& _mesh, const double _targetEdgeL
OpenMeshTriangleBSPT< MeshT >* triangleBSP = getTriangleBSP(meshCopy); OpenMeshTriangleBSPT< MeshT >* triangleBSP = getTriangleBSP(meshCopy);
for (int i=0; i < 10; i++){ for (int i=0; i < 10; i++){
if (prgEmt_)
prgEmt_->sendProgressSignal(10*i + 0);
// std::cerr << "Iteration = " << i << std::endl; // std::cerr << "Iteration = " << i << std::endl;
splitLongEdges(_mesh, high); splitLongEdges(_mesh, high);
if (prgEmt_)
prgEmt_->sendProgressSignal(10*i + 2);
// std::cerr << "collapse" << std::endl; // std::cerr << "collapse" << std::endl;
collapseShortEdges(_mesh, low, high); collapseShortEdges(_mesh, low, high);
if (prgEmt_)
prgEmt_->sendProgressSignal(10*i + 4);
// std::cerr << "equal" << std::endl; // std::cerr << "equal" << std::endl;
equalizeValences(_mesh); equalizeValences(_mesh);
if (prgEmt_)
prgEmt_->sendProgressSignal(10*i + 6);
// std::cerr << "relax" << std::endl; // std::cerr << "relax" << std::endl;
tangentialRelaxation(_mesh); tangentialRelaxation(_mesh);
if (prgEmt_)
prgEmt_->sendProgressSignal(10*i + 8);
// std::cerr << "project" << std::endl; // std::cerr << "project" << std::endl;
projectToSurface(_mesh, meshCopy, triangleBSP); projectToSurface(_mesh, meshCopy, triangleBSP);
if (prgEmt_)
prgEmt_->sendProgressSignal(10*i + 10);
} }
delete triangleBSP; delete triangleBSP;
......
#ifndef ISOTROPICREMESHER_HH #ifndef ISOTROPICREMESHER_HH
#define ISOTROPICREMESHER_HH #define ISOTROPICREMESHER_HH
#include "ProgressEmitter.hh"
template< class MeshT > template< class MeshT >
...@@ -7,7 +8,7 @@ class IsotropicRemesher{ ...@@ -7,7 +8,7 @@ class IsotropicRemesher{
public: public:
IsotropicRemesher() {}; IsotropicRemesher(ProgressEmitter* _prgEmt = NULL) : prgEmt_(_prgEmt) {};
~IsotropicRemesher() {}; ~IsotropicRemesher() {};
void remesh( MeshT& _mesh, const double _targetEdgeLength ); void remesh( MeshT& _mesh, const double _targetEdgeLength );
...@@ -43,6 +44,9 @@ private: ...@@ -43,6 +44,9 @@ private:
inline inline
bool isFeature( MeshT& _mesh, const typename MeshT::VertexHandle& _vh); bool isFeature( MeshT& _mesh, const typename MeshT::VertexHandle& _vh);
private:
ProgressEmitter* prgEmt_;
}; };
//============================================================================= //=============================================================================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment