diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04aa9cfc0..5f98b7447 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -144,7 +144,7 @@ else() meshlabplugins/filter_fractal meshlabplugins/filter_func meshlabplugins/filter_img_patch_param -# meshlabplugins/filter_isoparametrization + meshlabplugins/filter_isoparametrization # meshlabplugins/filter_layer # meshlabplugins/filter_measure # meshlabplugins/filter_meshing diff --git a/src/meshlab.pro b/src/meshlab.pro index 9ef442081..09c6ef0e5 100644 --- a/src/meshlab.pro +++ b/src/meshlab.pro @@ -67,7 +67,7 @@ SUBDIRS += \ #sub projects names filter_fractal \ filter_func \ filter_img_patch_param \ - #filter_isoparametrization \ + filter_isoparametrization \ #filter_layer \ #filter_mls \ #filter_mutualglobal \ diff --git a/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp b/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp index c2e9ff0f8..41c5a4e09 100644 --- a/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp +++ b/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp @@ -179,7 +179,12 @@ void FilterIsoParametrization::PrintStats(CMeshO *mesh) log("stdDev Edge: %5.2f",stdE/avE); } -bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& md, std::map&, unsigned int& /*postConditionMask*/, const RichParameterList & par, vcg::CallBackPos *cb) +std::map FilterIsoParametrization::applyFilter( + const QAction *filter, + const RichParameterList & par, + MeshDocument& md, + unsigned int& /*postConditionMask*/, + vcg::CallBackPos *cb) { MeshModel* m = md.mm(); //get current mesh from document CMeshO *mesh=&m->cm; @@ -244,19 +249,19 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& switch(ret) { case IsoParametrizator::MultiComponent: - this->errorMessage="non possible parameterization because of multi component mesh"; return false; + throw MLException("non possible parameterization because of multi component mesh"); case IsoParametrizator::NonSizeCons: - this->errorMessage="non possible parameterization because of non size consistent mesh"; return false; + throw MLException("non possible parameterization because of non size consistent mesh"); case IsoParametrizator::NonManifoldE: - this->errorMessage="non possible parameterization because of non manifold edges"; return false; + throw MLException("non possible parameterization because of non manifold edges"); case IsoParametrizator::NonManifoldV: - this->errorMessage="non possible parameterization because of non manifold vertices";return false; + throw MLException("non possible parameterization because of non manifold vertices"); case IsoParametrizator::NonWatertigh: - this->errorMessage="non possible parameterization because of non watertight mesh"; return false; + throw MLException("non possible parameterization because of non watertight mesh"); case IsoParametrizator::FailParam: - this->errorMessage="non possible parameterization cause one of the following reasons:\n Topologycal noise \n Too Low resolution mesh \n Too Bad triangulation \n"; return false; + throw MLException("non possible parameterization cause one of the following reasons:\n Topologycal noise \n Too Low resolution mesh \n Too Bad triangulation \n"); default: - this->errorMessage="unknown error"; return false; + throw MLException("unknown error"); } } @@ -267,8 +272,7 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& bool isOK=isoPHandle().Init(abs_mesh,para_mesh); if (!isOK) { - this->errorMessage="Problems gathering parameterization \n"; - return false; + throw MLException("Problems gathering parameterization \n"); } isoPHandle().CopyParametrization(mesh); ///copy back to original mesh @@ -280,19 +284,17 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& bool Done=isoPHandle().LoadBaseDomain(qUtf8Printable(AbsLoadName),mesh,para_mesh,abs_mesh,true); if (!Done) { - this->errorMessage="Abstract domain doesn't fit well with the parametrized mesh"; delete para_mesh; delete abs_mesh; - return false; + throw MLException("Abstract domain doesn't fit well with the parametrized mesh"); } } QString AbsSaveName = par.getString("AbsSaveName"); - if(!AbsSaveName.isEmpty()) - { + if(!AbsSaveName.isEmpty()) { isoPHandle().SaveBaseDomain(qUtf8Printable(AbsSaveName)); } - return true; + break; } case ISOP_REMESHING : { @@ -302,16 +304,14 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& bool b=tri::Allocator::IsValidHandle(*mesh,isoPHandle); if (!b) { - this->errorMessage="You must compute the abstract mesh before remeshing. Use the Isoparametrization main filter."; - return false; + throw MLException("You must compute the abstract mesh before remeshing. Use the Isoparametrization main filter."); } int SamplingRate=par.getInt("SamplingRate"); if (SamplingRate<2) { - this->errorMessage="Sampling rate must be >1"; - return false; + throw MLException("Sampling rate must be >1"); } MeshModel* mm=md.addNewMesh("","Re-meshed"); @@ -320,7 +320,7 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& DiamSampl.Init(&isoPHandle()); bool done = DiamSampl.SamplePos(SamplingRate); if (!done) - return false; + throw MLException(filter->text() + " filter failed."); DiamSampl.GetMesh(*rem); int n_diamonds,inFace,inEdge,inStar,n_merged; @@ -335,7 +335,7 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& mm->updateDataMask(MeshModel::MM_VERTFACETOPO); PrintStats(rem); mm->UpdateBoxAndNormals(); - return true; + break; } case ISOP_DIAMPARAM : { @@ -344,8 +344,7 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& bool b=tri::Allocator::IsValidHandle(*mesh,isoPHandle); if (!b) { - this->errorMessage="You must compute the abstract mesh before remeshing. Use the Isoparametrization main filter."; - return false; + throw MLException("You must compute the abstract mesh before remeshing. Use the Isoparametrization main filter."); } Scalarm border_size=par.getDynamicFloat("BorderSize"); @@ -357,7 +356,7 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& DiaPara.Init(&isoPHandle()); DiaPara.SetCoordinates(*rem,border_size); tri::UpdateNormal::PerFace(*rem); - return true; + break; } // case ISOP_LOAD : // { @@ -427,8 +426,7 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& bool b=tri::Allocator::IsValidHandle(*srcMesh,isoPHandle); if (!b) { - this->errorMessage="Your source mesh must have the abstract isoparametrization. Use the Isoparametrization command."; - return false; + throw MLException("Your source mesh must have the abstract isoparametrization. Use the Isoparametrization command."); } IsoTransfer IsoTr; AbstractMesh *abs_mesh = isoPHandle().AbsMesh(); @@ -448,10 +446,12 @@ bool FilterIsoParametrization::applyFilter(const QAction *filter, MeshDocument& isoPHandle().AbsMesh()=abs_mesh; isoPHandle().SetParamMesh(trgMesh,para_mesh); - return true; + break; } + default: + wrongActionCalled(filter); } - return false; + return std::map(); } FilterPlugin::FilterClass FilterIsoParametrization::getClass(const QAction *) const diff --git a/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.h b/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.h index b51709579..ca8619d3e 100644 --- a/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.h +++ b/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.h @@ -36,29 +36,34 @@ class FilterIsoParametrization : public QObject, public FilterPlugin Q_OBJECT MESHLAB_PLUGIN_IID_EXPORTER(FILTER_PLUGIN_IID) Q_INTERFACES(FilterPlugin) - - public: - enum {ISOP_PARAM, - ISOP_REMESHING, - ISOP_DIAMPARAM, - ISOP_TRANSFER - }; - - FilterIsoParametrization(); - ~FilterIsoParametrization(); - - QString pluginName() const; - virtual FilterClass getClass(const QAction*) const; - virtual QString filterName(ActionIDType filter) const; - virtual QString filterInfo(ActionIDType filter) const; - - virtual int getRequirements(const QAction*); - - virtual void initParameterList(const QAction*, MeshDocument&, RichParameterList & /*parent*/); - virtual bool applyFilter(const QAction* filter, MeshDocument&, std::map& outputValues, unsigned int& postConditionMask, const RichParameterList & /*parent*/, vcg::CallBackPos * cb); - int postCondition(const QAction* filter) const; - void PrintStats(CMeshO *mesh); - FILTER_ARITY filterArity(const QAction*) const; - + +public: + enum {ISOP_PARAM, + ISOP_REMESHING, + ISOP_DIAMPARAM, + ISOP_TRANSFER + }; + + FilterIsoParametrization(); + ~FilterIsoParametrization(); + + QString pluginName() const; + virtual FilterClass getClass(const QAction*) const; + virtual QString filterName(ActionIDType filter) const; + virtual QString filterInfo(ActionIDType filter) const; + + virtual int getRequirements(const QAction*); + + virtual void initParameterList(const QAction*, MeshDocument&, RichParameterList & /*parent*/); + std::map applyFilter( + const QAction* action, + const RichParameterList & parameters, + MeshDocument &md, + unsigned int& postConditionMask, + vcg::CallBackPos * cb); + int postCondition(const QAction* filter) const; + void PrintStats(CMeshO *mesh); + FILTER_ARITY filterArity(const QAction*) const; + }; #endif