diff --git a/RemesherPlugin.cc b/RemesherPlugin.cc index b8ba5ca3acb4ad8d7b87cf19407a26c815546732..5244c9438a1f485d660c84b35cad4c887e152e95 100644 --- a/RemesherPlugin.cc +++ b/RemesherPlugin.cc @@ -117,8 +117,14 @@ void RemesherPlugin::threadFinished(QString _jobId) { for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DataType(DATA_TRIANGLE_MESH | DATA_POLY_MESH)) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { - emit updatedObject(o_it->id(), UPDATE_GEOMETRY | UPDATE_TOPOLOGY ); - emit createBackup(o_it->id(), "Remeshing", UPDATE_GEOMETRY | UPDATE_TOPOLOGY); + + if ( operation_ == REMESH_ADAPTIVE ) { + emit updatedObject(o_it->id(), UPDATE_TOPOLOGY ); + emit createBackup(o_it->id(), "Adaptive remeshing", UPDATE_TOPOLOGY); + } else if ( operation_ == REMESH_UNIFORM ) { + emit updatedObject(o_it->id(), UPDATE_TOPOLOGY ); + emit createBackup(o_it->id(), "Uniform remeshing", UPDATE_TOPOLOGY); + } } // Detach job from progress emitter @@ -257,20 +263,22 @@ void RemesherPlugin::adaptiveRemeshing() { unsigned int iters = tool_->adaptive_iters->text().toInt(); bool projection = tool_->adaptive_projection->isChecked(); - adaptiveRemeshing(o_it->id(), error, min_edge, max_edge, iters, projection); + slotAdaptiveRemeshing(o_it->id(), error, min_edge, max_edge, iters, projection); } } // ---------------------------------------------------------------------------------------- -void RemesherPlugin::adaptiveRemeshing(int _objectID, - double _error, - double _min_edge_length, - double _max_edge_length, - unsigned int _iters, - bool _use_projection) { +void RemesherPlugin::slotAdaptiveRemeshing(int _objectID, + double _error, + double _min_edge_length, + double _max_edge_length, + unsigned int _iters, + bool _use_projection) { + operation_ = REMESH_ADAPTIVE; + BaseObjectData* object = 0; if (PluginFunctions::getObject(_objectID, object)) { @@ -287,9 +295,9 @@ void RemesherPlugin::adaptiveRemeshing(int _objectID, mesh->update_normals(); - QString projectionString = "FALSE"; + QString projectionString = "\"FALSE\""; if (_use_projection) - projectionString = "TRUE"; + projectionString = "\"TRUE\""; emit scriptInfo("adaptiveRemeshing(" + QString::number(_objectID) + ", " + QString::number(_error) + ", " @@ -353,18 +361,20 @@ void RemesherPlugin::uniformRemeshing(){ // on edge flips which are only defined // for triangle configurations. - uniformRemeshing(o_it->id(), edge_length, iters, area_iters, projection); + slotUniformRemeshing(o_it->id(), edge_length, iters, area_iters, projection); } } // ---------------------------------------------------------------------------------------- -void RemesherPlugin::uniformRemeshing(int _objectID, - double _edge_length, - unsigned int _iters, - unsigned int _area_iters, - bool _use_projection) { +void RemesherPlugin::slotUniformRemeshing(int _objectID, + double _edge_length, + unsigned int _iters, + unsigned int _area_iters, + bool _use_projection) { + operation_ = REMESH_UNIFORM; + BaseObjectData* object = 0; if (PluginFunctions::getObject(_objectID, object)) { @@ -380,16 +390,16 @@ void RemesherPlugin::uniformRemeshing(int _objectID, mesh->update_normals(); - QString projectionString = "FALSE"; + QString projectionString = "\"FALSE\""; if (_use_projection) - projectionString = "TRUE"; + projectionString = "\"TRUE\""; - emit scriptInfo("adaptiveRemeshing(" + QString::number(_objectID) + ", " - + QString::number(_edge_length) + ", " - + QString::number(_iters) + ", " - + QString::number(_area_iters) + ", " - + QString::number(_iters) + ", " - + projectionString + ")"); + emit scriptInfo("uniformRemeshing(" + QString::number(_objectID) + ", " + + QString::number(_edge_length) + ", " + + QString::number(_iters) + ", " + + QString::number(_area_iters) + ", " + + QString::number(_iters) + ", " + + projectionString + ")"); return; } @@ -399,5 +409,34 @@ void RemesherPlugin::uniformRemeshing(int _objectID, // ---------------------------------------------------------------------------------------- +void RemesherPlugin::adaptiveRemeshing(int _objectID, + double _error, + double _min_edge_length, + double _max_edge_length, + unsigned int _iters, + bool _use_projection) { + + slotAdaptiveRemeshing(_objectID,_error,_min_edge_length,_max_edge_length,_iters,_use_projection); + emit updatedObject(_objectID, UPDATE_TOPOLOGY ); + emit createBackup(_objectID, "Adaptive remeshing", UPDATE_TOPOLOGY); + +} + +// ---------------------------------------------------------------------------------------- + +void RemesherPlugin::uniformRemeshing(int _objectID, + double _edge_length, + unsigned int _iters, + unsigned int _area_iters, + bool _use_projection) { + + slotUniformRemeshing(_objectID,_edge_length,_iters,_area_iters,_use_projection); + emit updatedObject(_objectID, UPDATE_TOPOLOGY ); + emit createBackup(_objectID, "Uniform remeshing", UPDATE_TOPOLOGY); + +} + +// ---------------------------------------------------------------------------------------- + Q_EXPORT_PLUGIN2( remesherplugin, RemesherPlugin ); diff --git a/RemesherPlugin.hh b/RemesherPlugin.hh index 0e4ccd448b187f09bffe1e321149fe0baca20042..0f4d0639c125276288ef597ecb55bc6a5701e074 100644 --- a/RemesherPlugin.hh +++ b/RemesherPlugin.hh @@ -127,6 +127,10 @@ private : QIcon* toolIcon_; + enum RemeshingOperation { REMESH_UNIFORM, REMESH_ADAPTIVE }; + + RemeshingOperation operation_; + private slots: //---- Adaptive Remeshing ------------ @@ -150,6 +154,19 @@ private slots: /// Compute mean edge length and set values void computeInitValues(); + void slotAdaptiveRemeshing(int _objectId, + double _error, + double _min_edge_length, + double _max_edge_length, + unsigned int _iters, + bool _use_projection = true); + + void slotUniformRemeshing(int _objectId, + double _edge_length, + unsigned int _iters, + unsigned int _area_iters, + bool _use_projection = true); + //scripting functions public slots: @@ -160,7 +177,7 @@ public slots: double _max_edge_length, unsigned int _iters, bool _use_projection = true); - + void uniformRemeshing(int _objectId, double _edge_length, unsigned int _iters,