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(){
101 connect (&prgEmt, SIGNAL(changeDescription(QString,QString)),
this, SIGNAL(setJobDescription(QString,QString)) );
102 connect (&prgEmt, SIGNAL(signalJobState(QString,
int)),
this, SIGNAL(setJobState(QString,
int)) );
105 remesher.
remesh(*mesh, edgeLength_);
110 emit log(
"Remeshing currently only implemented for triangle Meshes");
115 void IsotropicRemesherPlugin::threadFinished(QString ) {
117 std::cerr <<
"threadFinished() called" << std::endl;
123 emit createBackup(o_it->id(),
"Isotropic Remeshing");
130 void IsotropicRemesherPlugin::slotSetMinLength()
132 double current = 0.0;
136 emit functionExists(
"infomeshobject" ,
"minEdgeLength(int)", ok ) ;
144 current = RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() );
148 current = qMin (current, RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() ));
153 tool_->targetEdgeLength->setValue (current);
156 void IsotropicRemesherPlugin::slotSetMaxLength()
158 double current = 0.0;
162 emit functionExists(
"infomeshobject" ,
"maxEdgeLength(int)", ok ) ;
170 current = RPC::callFunctionValue<double>(
"infomeshobject" ,
"maxEdgeLength",o_it->id() );
174 current = qMax (current, RPC::callFunctionValue<double>(
"infomeshobject" ,
"maxEdgeLength",o_it->id() ));
179 tool_->targetEdgeLength->setValue (current);
182 void IsotropicRemesherPlugin::slotSetMeanLength()
184 double current = 0.0;
188 emit functionExists(
"infomeshobject" ,
"edgeCount(int)", ok ) ;
193 current += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id()) *
194 RPC::callFunctionValue<double>(
"infomeshobject" ,
"meanEdgeLength",o_it->id() );
195 div += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id() );
199 tool_->targetEdgeLength->setValue (current / div);
207 QString(
"object_id,targetEdgeLength").split(
","),
208 QString(
"id of an object, target edge length").split(
","));
212 void IsotropicRemesherPlugin::isotropicRemesh(
int _objectID,
double _targetEdgeLength ){
225 remesher.
remesh(*mesh, _targetEdgeLength);
231 emit
scriptInfo(
"isotropicRemesh(" + QString::number(_objectID) +
", " + QString::number(_targetEdgeLength) +
")");
238 emit log(
"Remeshing currently only implemented for triangle Meshes");
242 emit log(
"Unable to get object");
void pluginsInitialized()
Initialize the plugin.
#define DATA_TRIANGLE_MESH
void remesh(MeshT &_mesh, const double _targetEdgeLength)
do the remeshing
void initializePlugin()
init the Toolbox
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
virtual void updateView()
Update current view in Main Application.
virtual void setSlotDescription(QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions)
Set a description for a public slot.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
bool dataType(DataType _type) const
virtual void scriptInfo(QString _functionWithParameters)
Emit this signal if a scriptable function is executed.
void update_normals()
Compute normals for all primitives.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
virtual void updatedObject(int _objectId)
An object has been changed or added by this plugin.
Thread handling class for OpenFlipper.