50 #include "IsotropicRemesherPlugin.hh"
51 #include "IsotropicRemesherT.hh"
53 IsotropicRemesherPlugin::IsotropicRemesherPlugin() :
63 if ( OpenFlipper::Options::gui() ) {
69 connect(tool_->remeshButton, SIGNAL(clicked()),
this, SLOT(slotRemeshButtonClicked()) );
71 connect(tool_->minEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMinLength()) );
72 connect(tool_->maxEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMaxLength()) );
73 connect(tool_->meanEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMeanLength()) );
75 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"remesher.png");
76 emit addToolbox( tr(
"Isotropic Remesher") , tool_, toolIcon_ );
80 void IsotropicRemesherPlugin::slotRemeshButtonClicked() {
81 edgeLength_ = tool_->targetEdgeLength->value();
85 connect(thread_,SIGNAL( finished(QString)),
this,SIGNAL(finishJob(QString)));
86 connect(thread_,SIGNAL(
function() ),
this,SLOT(slotRemesh()),Qt::DirectConnection);
87 connect(
this,SIGNAL( finishJob(QString)),
this, SLOT(threadFinished(QString)), Qt::QueuedConnection);
90 emit startJob(
name() +
"IsotropicRemesh",
"Isotropic remeshing" , 0 , 100 ,
true);
97 void IsotropicRemesherPlugin::slotRemesh(){
108 connect (&prgEmt, SIGNAL(changeDescription(QString,QString)),
this, SIGNAL(setJobDescription(QString,QString)) );
109 connect (&prgEmt, SIGNAL(signalJobState(QString,
int)),
this, SIGNAL(setJobState(QString,
int)) );
112 remesher.remesh(*mesh, edgeLength_);
114 mesh->update_normals();
117 emit log(
"Remeshing currently only implemented for triangle Meshes");
122 void IsotropicRemesherPlugin::threadFinished(QString ) {
124 std::cerr <<
"threadFinished() called" << std::endl;
131 emit createBackup(o_it->id(),
"Isotropic Remeshing");
138 void IsotropicRemesherPlugin::slotSetMinLength()
140 double current = 0.0;
144 emit functionExists(
"infomeshobject" ,
"minEdgeLength(int)", ok ) ;
153 current = RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() );
157 current = qMin (current, RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() ));
162 tool_->targetEdgeLength->setValue (current);
165 void IsotropicRemesherPlugin::slotSetMaxLength()
167 double current = 0.0;
171 emit functionExists(
"infomeshobject" ,
"maxEdgeLength(int)", ok ) ;
180 current = RPC::callFunctionValue<double>(
"infomeshobject" ,
"maxEdgeLength",o_it->id() );
184 current = qMax (current, RPC::callFunctionValue<double>(
"infomeshobject" ,
"maxEdgeLength",o_it->id() ));
189 tool_->targetEdgeLength->setValue (current);
192 void IsotropicRemesherPlugin::slotSetMeanLength()
194 double current = 0.0;
198 emit functionExists(
"infomeshobject" ,
"edgeCount(int)", ok ) ;
206 current += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id()) *
207 RPC::callFunctionValue<double>(
"infomeshobject" ,
"meanEdgeLength",o_it->id() );
208 div += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id() );
212 tool_->targetEdgeLength->setValue (current / div);
219 emit setSlotDescription(
"isotropicRemesh(int,double)",
"Isotropic Remeshing",
220 QString(
"object_id,targetEdgeLength").split(
","),
221 QString(
"id of an object, target edge length").split(
","));
225 void IsotropicRemesherPlugin::isotropicRemesh(
int _objectID,
double _targetEdgeLength ){
238 remesher.
remesh(*mesh, _targetEdgeLength);
240 mesh->update_normals();
244 emit scriptInfo(
"isotropicRemesh(" + QString::number(_objectID) +
", " + QString::number(_targetEdgeLength) +
")");
251 emit log(
"Remeshing currently only implemented for triangle Meshes");
255 emit log(
"Unable to get object");
259 #if QT_VERSION < 0x050000
QString name()
Return a name for the plugin.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool getObject(int _identifier, BSplineCurveObject *&_object)
void initializePlugin()
init the Toolbox
const QStringList TARGET_OBJECTS("target")
Iterable object range.
bool dataType(DataType _type) const
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void remesh(MeshT &_mesh, const double _targetEdgeLength)
do the remeshing
Thread handling class for OpenFlipper.
void startProcessing()
start processing
void pluginsInitialized()
Initialize the plugin.
#define DATA_TRIANGLE_MESH