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);
93 thread_->startProcessing();
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_);
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);
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);
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 virtual void setSlotDescription(QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions)
Set a description for a public slot.
virtual void updatedObject(int _objectId)
An object has been changed or added by this plugin.
void update_normals()
Compute normals for all primitives.
bool getObject(int _identifier, BSplineCurveObject *&_object)
bool dataType(DataType _type) const
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void initializePlugin()
init the Toolbox
Thread handling class for OpenFlipper.
virtual void scriptInfo(QString _functionWithParameters)
Emit this signal if a scriptable function is executed.
void pluginsInitialized()
Initialize the plugin.
virtual void updateView()
Update current view in Main Application.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void remesh(MeshT &_mesh, const double _targetEdgeLength)
do the remeshing
#define DATA_TRIANGLE_MESH
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.