44 #include "IsotropicRemesherPlugin.hh" 45 #include "IsotropicRemesherT.hh" 47 IsotropicRemesherPlugin::IsotropicRemesherPlugin() :
57 if ( OpenFlipper::Options::gui() ) {
63 connect(tool_->remeshButton, SIGNAL(clicked()),
this, SLOT(slotRemeshButtonClicked()) );
65 connect(tool_->minEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMinLength()) );
66 connect(tool_->maxEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMaxLength()) );
67 connect(tool_->meanEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMeanLength()) );
69 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"remesher.png");
70 emit addToolbox( tr(
"Isotropic Remesher") , tool_, toolIcon_ );
74 void IsotropicRemesherPlugin::slotRemeshButtonClicked() {
75 edgeLength_ = tool_->targetEdgeLength->value();
79 connect(thread_,SIGNAL( finished(QString)),
this,SIGNAL(finishJob(QString)));
80 connect(thread_,SIGNAL(
function() ),
this,SLOT(slotRemesh()),Qt::DirectConnection);
81 connect(
this,SIGNAL( finishJob(QString)),
this, SLOT(threadFinished(QString)), Qt::QueuedConnection);
84 emit startJob( name() +
"IsotropicRemesh",
"Isotropic remeshing" , 0 , 100 ,
true);
87 thread_->startProcessing();
91 void IsotropicRemesherPlugin::slotRemesh(){
102 connect (&prgEmt, SIGNAL(changeDescription(QString,QString)),
this, SIGNAL(setJobDescription(QString,QString)) );
103 connect (&prgEmt, SIGNAL(signalJobState(QString,
int)),
this, SIGNAL(setJobState(QString,
int)) );
106 remesher.
remesh(*mesh, edgeLength_);
111 emit log(
"Remeshing currently only implemented for triangle Meshes");
116 void IsotropicRemesherPlugin::threadFinished(QString ) {
118 std::cerr <<
"threadFinished() called" << std::endl;
125 emit createBackup(o_it->id(),
"Isotropic Remeshing");
132 void IsotropicRemesherPlugin::slotSetMinLength()
134 double current = 0.0;
138 emit functionExists(
"infomeshobject" ,
"minEdgeLength(int)", ok ) ;
147 current = RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() );
151 current = qMin (current, RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() ));
156 tool_->targetEdgeLength->setValue (current);
159 void IsotropicRemesherPlugin::slotSetMaxLength()
161 double current = 0.0;
165 emit functionExists(
"infomeshobject" ,
"maxEdgeLength(int)", ok ) ;
174 current = RPC::callFunctionValue<double>(
"infomeshobject" ,
"maxEdgeLength",o_it->id() );
178 current = qMax (current, RPC::callFunctionValue<double>(
"infomeshobject" ,
"maxEdgeLength",o_it->id() ));
183 tool_->targetEdgeLength->setValue (current);
186 void IsotropicRemesherPlugin::slotSetMeanLength()
188 double current = 0.0;
192 emit functionExists(
"infomeshobject" ,
"edgeCount(int)", ok ) ;
200 current += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id()) *
201 RPC::callFunctionValue<double>(
"infomeshobject" ,
"meanEdgeLength",o_it->id() );
202 div += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id() );
206 tool_->targetEdgeLength->setValue (current / div);
214 QString(
"object_id,targetEdgeLength").split(
","),
215 QString(
"id of an object, target edge length").split(
","));
219 void IsotropicRemesherPlugin::isotropicRemesh(
int _objectID,
double _targetEdgeLength ){
232 remesher.
remesh(*mesh, _targetEdgeLength);
238 emit
scriptInfo(
"isotropicRemesh(" + QString::number(_objectID) +
", " + QString::number(_targetEdgeLength) +
")");
245 emit log(
"Remeshing currently only implemented for triangle Meshes");
249 emit log(
"Unable to get object");
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
virtual void scriptInfo(QString _functionWithParameters)
Emit this signal if a scriptable function is executed.
bool dataType(DataType _type) const
const QStringList TARGET_OBJECTS("target")
Iterable object range.
virtual void updatedObject(int _objectId)
An object has been changed or added by this plugin.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void remesh(MeshT &_mesh, const double _targetEdgeLength)
do the remeshing
void initializePlugin()
init the Toolbox
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
virtual void updateView()
Update current view in Main Application.
Thread handling class for OpenFlipper.
#define DATA_TRIANGLE_MESH
void pluginsInitialized()
Initialize the plugin.
void update_normals()
Compute normals for all primitives.
virtual void setSlotDescription(QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions)
Set a description for a public slot.