44#include "IsotropicRemesherPlugin.hh"
45#include "IsotropicRemesherT.hh"
47IsotropicRemesherPlugin::IsotropicRemesherPlugin() :
55IsotropicRemesherPlugin::~IsotropicRemesherPlugin() {
61 if ( OpenFlipper::Options::gui() ) {
67 connect(tool_->remeshButton, SIGNAL(clicked()),
this, SLOT(slotRemeshButtonClicked()) );
69 connect(tool_->minEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMinLength()) );
70 connect(tool_->maxEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMaxLength()) );
71 connect(tool_->meanEdgeLength, SIGNAL(clicked()),
this, SLOT(slotSetMeanLength()) );
73 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"remesher.png");
74 emit addToolbox( tr(
"Isotropic Remesher") , tool_, toolIcon_ );
78void IsotropicRemesherPlugin::slotRemeshButtonClicked() {
79 edgeLength_ = tool_->targetEdgeLength->value();
83 connect(thread_,SIGNAL( finished(QString)),
this,SIGNAL(finishJob(QString)));
84 connect(thread_,SIGNAL( function() ),
this,SLOT(slotRemesh()),Qt::DirectConnection);
85 connect(
this,SIGNAL( finishJob(QString)),
this, SLOT(threadFinished(QString)), Qt::QueuedConnection);
88 emit startJob(
name() +
"IsotropicRemesh",
"Isotropic remeshing" , 0 , 100 ,
true);
95void IsotropicRemesherPlugin::slotRemesh(){
105 connect (&prgEmt, SIGNAL(changeDescription(QString,QString)),
this, SIGNAL(setJobDescription(QString,QString)) );
106 connect (&prgEmt, SIGNAL(signalJobState(QString,
int)),
this, SIGNAL(setJobState(QString,
int)) );
109 remesher.remesh(*mesh, edgeLength_);
114 emit log(
"Remeshing currently only implemented for triangle Meshes");
119void IsotropicRemesherPlugin::threadFinished(QString ) {
121 std::cerr <<
"threadFinished() called" << std::endl;
127 emit createBackup(o_it->id(),
"Isotropic Remeshing");
134void IsotropicRemesherPlugin::slotSetMinLength()
136 double current = 0.0;
140 emit functionExists(
"infomeshobject" ,
"minEdgeLength(int)", ok ) ;
148 current = RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() );
152 current = qMin (current, RPC::callFunctionValue<double>(
"infomeshobject" ,
"minEdgeLength",o_it->id() ));
157 tool_->targetEdgeLength->setValue (current);
160void IsotropicRemesherPlugin::slotSetMaxLength()
162 double current = 0.0;
166 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);
186void IsotropicRemesherPlugin::slotSetMeanLength()
188 double current = 0.0;
192 emit functionExists(
"infomeshobject" ,
"edgeCount(int)", ok ) ;
197 current += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id()) *
198 RPC::callFunctionValue<double>(
"infomeshobject" ,
"meanEdgeLength",o_it->id() );
199 div += RPC::callFunctionValue<int> (
"infomeshobject" ,
"edgeCount",o_it->id() );
203 tool_->targetEdgeLength->setValue (current / div);
210 emit setSlotDescription(
"isotropicRemesh(int,double)",
"Isotropic Remeshing",
211 QString(
"object_id,targetEdgeLength").split(
","),
212 QString(
"id of an object, target edge length").split(
","));
216void IsotropicRemesherPlugin::isotropicRemesh(
int _objectID,
double _targetEdgeLength ){
229 remesher.
remesh(*mesh, _targetEdgeLength);
235 emit scriptInfo(
"isotropicRemesh(" + QString::number(_objectID) +
", " + QString::number(_targetEdgeLength) +
")");
242 emit log(
"Remeshing currently only implemented for triangle Meshes");
246 emit log(
"Unable to get object");
#define DATA_TRIANGLE_MESH
bool dataType(DataType _type) const
QString name()
Return a name for the plugin.
void initializePlugin()
init the Toolbox
void pluginsInitialized()
Initialize the plugin.
void remesh(MeshT &_mesh, const double _targetEdgeLength)
do the remeshing
Thread handling class for OpenFlipper.
void startProcessing()
start processing
void update_normals()
Compute normals for all primitives.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
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.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.