diff --git a/src/meshlabplugins/filter_select/meshselect.cpp b/src/meshlabplugins/filter_select/meshselect.cpp index 0f9d1db33..3bf993601 100644 --- a/src/meshlabplugins/filter_select/meshselect.cpp +++ b/src/meshlabplugins/filter_select/meshselect.cpp @@ -1,8 +1,8 @@ -/**************************************************************************** +/***************************************************************************** * MeshLab o o * * A versatile mesh processing toolbox o o * * _ O _ * - * Copyright(C) 2005 \/)\/ * + * Copyright(C) 2005-2021 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * @@ -21,25 +21,29 @@ * * ****************************************************************************/ +#include "meshselect.h" #include #include -#include -#include "meshselect.h" #include -#include #include +#include +#include #include using namespace vcg; // ERROR CHECKING UTILITY -#define CheckError(x,y); if ((x)) {this->errorMessage = (y); return false;} +#define CheckError(x, y) \ + ; \ + if ((x)) { \ + this->errorMessage = (y); \ + return false; \ + } /////////////////////////////////////////////////////// SelectionFilterPlugin::SelectionFilterPlugin() { - typeList = { FP_SELECT_ALL, FP_SELECT_NONE, @@ -64,52 +68,51 @@ SelectionFilterPlugin::SelectionFilterPlugin() CP_SELECT_NON_MANIFOLD_VERTEX, FP_SELECT_FACES_BY_EDGE, FP_SELECT_BY_COLOR, - FP_SELECT_OUTLIER - }; + FP_SELECT_OUTLIER}; QCoreApplication* app = QCoreApplication::instance(); - for(ActionIDType tt : types()) { + for (ActionIDType tt : types()) { QAction* act = new QAction(filterName(tt), this); actionList.push_back(act); if (app != nullptr) { - if(tt==FP_SELECT_DELETE_VERT){ - act->setShortcut(QKeySequence ("Ctrl+Del")); + if (tt == FP_SELECT_DELETE_VERT) { + act->setShortcut(QKeySequence("Ctrl+Del")); act->setIcon(QIcon(":/images/delete_vert.png")); act->setPriority(QAction::HighPriority); } - if(tt==FP_SELECT_DELETE_FACE){ - act->setShortcut(QKeySequence (Qt::Key_Delete)); + if (tt == FP_SELECT_DELETE_FACE) { + act->setShortcut(QKeySequence(Qt::Key_Delete)); act->setIcon(QIcon(":/images/delete_face.png")); act->setPriority(QAction::HighPriority); } - if(tt==FP_SELECT_DELETE_FACEVERT){ - act->setShortcut(QKeySequence ("Shift+Del")); + if (tt == FP_SELECT_DELETE_FACEVERT) { + act->setShortcut(QKeySequence("Shift+Del")); act->setIcon(QIcon(":/images/delete_facevert.png")); act->setPriority(QAction::HighPriority); } - if (tt == FP_SELECT_ALL){ + if (tt == FP_SELECT_ALL) { act->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_A); act->setIcon(QIcon(":/images/sel_all.png")); act->setPriority(QAction::LowPriority); } - if (tt == FP_SELECT_NONE){ + if (tt == FP_SELECT_NONE) { act->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_D); act->setIcon(QIcon(":/images/sel_none.png")); act->setPriority(QAction::LowPriority); } - if (tt == FP_SELECT_INVERT){ + if (tt == FP_SELECT_INVERT) { act->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_I); act->setIcon(QIcon(":/images/sel_inv.png")); act->setPriority(QAction::LowPriority); } - if (tt == FP_SELECT_DILATE){ + if (tt == FP_SELECT_DILATE) { act->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Plus); act->setIcon(QIcon(":/images/sel_plus.png")); act->setPriority(QAction::LowPriority); } - if (tt == FP_SELECT_ERODE){ + if (tt == FP_SELECT_ERODE) { act->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Minus); act->setIcon(QIcon(":/images/sel_minus.png")); act->setPriority(QAction::LowPriority); @@ -125,31 +128,31 @@ QString SelectionFilterPlugin::pluginName() const QString SelectionFilterPlugin::filterName(ActionIDType filter) const { - switch(filter) { - case FP_SELECT_ALL : return tr("Select All"); - case FP_SELECT_NONE : return tr("Select None"); - case FP_SELECT_INVERT : return tr("Invert Selection"); - case FP_SELECT_CONNECTED : return tr("Select Connected Faces"); - case FP_SELECT_DELETE_VERT : return tr("Delete Selected Vertices"); - case FP_SELECT_DELETE_ALL_FACE : return tr("Delete ALL Faces"); - case FP_SELECT_DELETE_FACE : return tr("Delete Selected Faces"); - case FP_SELECT_DELETE_FACEVERT : return tr("Delete Selected Faces and Vertices"); - case FP_SELECTBYANGLE : return tr("Select Faces by view angle"); - case FP_SELECT_UGLY : return tr("Select 'problematic' faces"); - case FP_SELECT_FACE_FROM_VERT : return tr("Select Faces from Vertices"); - case FP_SELECT_VERT_FROM_FACE : return tr("Select Vertices from Faces"); - case FP_SELECT_ERODE : return tr("Erode Selection"); - case FP_SELECT_DILATE : return tr("Dilate Selection"); - case FP_SELECT_BORDER : return tr("Select Border"); - case FP_SELECT_BY_VERT_QUALITY : return tr("Select by Vertex Quality"); - case FP_SELECT_BY_FACE_QUALITY : return tr("Select by Face Quality"); - case FP_SELECT_BY_COLOR : return tr("Select Faces by Color"); - case CP_SELFINTERSECT_SELECT : return tr("Select Self Intersecting Faces"); - case CP_SELECT_TEXBORDER : return tr("Select Vertex Texture Seams"); - case CP_SELECT_NON_MANIFOLD_FACE : return tr("Select non Manifold Edges"); - case CP_SELECT_NON_MANIFOLD_VERTEX : return tr("Select non Manifold Vertices"); - case FP_SELECT_FACES_BY_EDGE: return tr("Select Faces with edges longer than..."); - case FP_SELECT_OUTLIER: return tr("Select Outliers"); + switch (filter) { + case FP_SELECT_ALL: return tr("Select All"); + case FP_SELECT_NONE: return tr("Select None"); + case FP_SELECT_INVERT: return tr("Invert Selection"); + case FP_SELECT_CONNECTED: return tr("Select Connected Faces"); + case FP_SELECT_DELETE_VERT: return tr("Delete Selected Vertices"); + case FP_SELECT_DELETE_ALL_FACE: return tr("Delete ALL Faces"); + case FP_SELECT_DELETE_FACE: return tr("Delete Selected Faces"); + case FP_SELECT_DELETE_FACEVERT: return tr("Delete Selected Faces and Vertices"); + case FP_SELECTBYANGLE: return tr("Select Faces by view angle"); + case FP_SELECT_UGLY: return tr("Select 'problematic' faces"); + case FP_SELECT_FACE_FROM_VERT: return tr("Select Faces from Vertices"); + case FP_SELECT_VERT_FROM_FACE: return tr("Select Vertices from Faces"); + case FP_SELECT_ERODE: return tr("Erode Selection"); + case FP_SELECT_DILATE: return tr("Dilate Selection"); + case FP_SELECT_BORDER: return tr("Select Border"); + case FP_SELECT_BY_VERT_QUALITY: return tr("Select by Vertex Quality"); + case FP_SELECT_BY_FACE_QUALITY: return tr("Select by Face Quality"); + case FP_SELECT_BY_COLOR: return tr("Select Faces by Color"); + case CP_SELFINTERSECT_SELECT: return tr("Select Self Intersecting Faces"); + case CP_SELECT_TEXBORDER: return tr("Select Vertex Texture Seams"); + case CP_SELECT_NON_MANIFOLD_FACE: return tr("Select non Manifold Edges"); + case CP_SELECT_NON_MANIFOLD_VERTEX: return tr("Select non Manifold Vertices"); + case FP_SELECT_FACES_BY_EDGE: return tr("Select Faces with edges longer than..."); + case FP_SELECT_OUTLIER: return tr("Select Outliers"); } assert(0); return QString("Unknown filter"); @@ -157,162 +160,358 @@ QString SelectionFilterPlugin::filterName(ActionIDType filter) const QString SelectionFilterPlugin::filterInfo(ActionIDType filterId) const { - switch(filterId) - { - case FP_SELECT_DILATE : return tr("Dilate (expand) the current set of selected faces."); - case FP_SELECT_ERODE : return tr("Erode (reduce) the current set of selected faces."); - case FP_SELECT_INVERT : return tr("Invert the current set of selected faces/vertices."); - case FP_SELECT_CONNECTED: return tr("Expand the current face selection so that it includes all the faces in the connected components where there is at least a selected face."); - case FP_SELECT_NONE : return tr("Clear the current set of selected faces/vertices."); - case FP_SELECT_ALL : return tr("Select all the faces/vertices of the current mesh."); - case FP_SELECT_DELETE_VERT : return tr("Delete the current set of selected vertices; faces that share one of the deleted vertices are deleted too."); - case FP_SELECT_DELETE_ALL_FACE: return tr("Delete ALL faces, turning the mesh into a pointcloud. May be applied also to all visible layers."); - case FP_SELECT_DELETE_FACE : return tr("Delete the current set of selected faces, vertices that remains unreferenced are not deleted."); - case FP_SELECT_DELETE_FACEVERT : return tr("Delete the current set of selected faces and all the vertices surrounded by that faces."); - case FP_SELECTBYANGLE : return tr("Select faces according to the angle between their normal and the view direction. It is used in range map processing to select and delete steep faces parallel to viewdirection."); - case FP_SELECT_UGLY : return tr("Select faces with 'problems', like normal inverted w.r.t the surrounding areas, or extremely elongated"); - case CP_SELFINTERSECT_SELECT : return tr("Select only self intersecting faces."); - case FP_SELECT_FACE_FROM_VERT : return tr("Select faces from selected vertices."); - case FP_SELECT_VERT_FROM_FACE : return tr("Select vertices from selected faces."); - case FP_SELECT_FACES_BY_EDGE : return tr("Select all triangles having an edge with length greater or equal than a given threshold."); - case FP_SELECT_BORDER : return tr("Select vertices and faces on the boundary."); - case FP_SELECT_BY_VERT_QUALITY : return tr("Select all the faces/vertices within the specified vertex quality range."); - case FP_SELECT_BY_FACE_QUALITY : return tr("Select all the faces/vertices with within the specified face quality range."); - case FP_SELECT_BY_COLOR : return tr("Select part of the mesh based on its color."); - case CP_SELECT_TEXBORDER : return tr("Colorize only border edges."); - case CP_SELECT_NON_MANIFOLD_FACE: return tr("Select the faces and the vertices incident on non manifold edges (e.g. edges where more than two faces are incident); note that this function select the components that are related to non manifold edges. The case of non manifold vertices is specifically managed by the pertinent filter."); - case CP_SELECT_NON_MANIFOLD_VERTEX: return tr("Select the non manifold vertices that do not belong to non manifold edges. For example two cones connected by their apex. Vertices incident on non manifold edges are ignored."); - case FP_SELECT_OUTLIER: return tr("Select the vertex classified as outlier using Local Outlier Propabilty measure described in:
'LoOP: Local Outlier Probabilities' Kriegel et al.
CIKM 2009"); - } - assert(0); - return QString("Unknown filter"); + switch (filterId) { + case FP_SELECT_DILATE: return tr("Dilate (expand) the current set of selected faces."); + case FP_SELECT_ERODE: return tr("Erode (reduce) the current set of selected faces."); + case FP_SELECT_INVERT: return tr("Invert the current set of selected faces/vertices."); + case FP_SELECT_CONNECTED: + return tr( + "Expand the current face selection so that it includes all the faces in the connected " + "components where there is at least a selected face."); + case FP_SELECT_NONE: return tr("Clear the current set of selected faces/vertices."); + case FP_SELECT_ALL: return tr("Select all the faces/vertices of the current mesh."); + case FP_SELECT_DELETE_VERT: + return tr( + "Delete the current set of selected vertices; faces that share one of the deleted " + "vertices are deleted too."); + case FP_SELECT_DELETE_ALL_FACE: + return tr( + "Delete ALL faces, turning the mesh into a pointcloud. May be applied also to all " + "visible layers."); + case FP_SELECT_DELETE_FACE: + return tr( + "Delete the current set of selected faces, vertices that remains unreferenced are not " + "deleted."); + case FP_SELECT_DELETE_FACEVERT: + return tr( + "Delete the current set of selected faces and all the vertices surrounded by that " + "faces."); + case FP_SELECTBYANGLE: + return tr( + "Select faces according to the angle between their normal and the view direction. It " + "is used in range map processing to select and delete steep faces parallel to " + "viewdirection."); + case FP_SELECT_UGLY: + return tr( + "Select faces with 'problems', like normal inverted w.r.t the surrounding areas, or " + "extremely elongated"); + case CP_SELFINTERSECT_SELECT: return tr("Select only self intersecting faces."); + case FP_SELECT_FACE_FROM_VERT: return tr("Select faces from selected vertices."); + case FP_SELECT_VERT_FROM_FACE: return tr("Select vertices from selected faces."); + case FP_SELECT_FACES_BY_EDGE: + return tr( + "Select all triangles having an edge with length greater or equal than a given " + "threshold."); + case FP_SELECT_BORDER: return tr("Select vertices and faces on the boundary."); + case FP_SELECT_BY_VERT_QUALITY: + return tr("Select all the faces/vertices within the specified vertex quality range."); + case FP_SELECT_BY_FACE_QUALITY: + return tr("Select all the faces/vertices with within the specified face quality range."); + case FP_SELECT_BY_COLOR: return tr("Select part of the mesh based on its color."); + case CP_SELECT_TEXBORDER: return tr("Colorize only border edges."); + case CP_SELECT_NON_MANIFOLD_FACE: + return tr( + "Select the faces and the vertices incident on non manifold edges (e.g. edges where " + "more than two faces are incident); note that this function select the components that " + "are related to non manifold edges. The case of non manifold vertices is specifically " + "managed by the pertinent filter."); + case CP_SELECT_NON_MANIFOLD_VERTEX: + return tr( + "Select the non manifold vertices that do not belong to non manifold edges. For " + "example two cones connected by their apex. Vertices incident on non manifold edges " + "are ignored."); + case FP_SELECT_OUTLIER: + return tr( + "Select the vertex classified as outlier using Local Outlier Propabilty measure " + "described in:
'LoOP: Local Outlier Probabilities' Kriegel et al.
CIKM " + "2009"); + } + assert(0); + return QString("Unknown filter"); } -RichParameterList SelectionFilterPlugin::initParameterList(const QAction *action, const MeshModel &m) +RichParameterList +SelectionFilterPlugin::initParameterList(const QAction* action, const MeshModel& m) { RichParameterList parlst; - switch(ID(action)) - { - case FP_SELECT_FACES_BY_EDGE: - { - float maxVal = m.cm.bbox.Diag()/2.0f; - parlst.addParam(RichDynamicFloat("Threshold",maxVal*0.01,0,maxVal,"Edge Threshold", "All the faces with an edge longer than this threshold will be deleted. Useful for removing long skinny faces obtained by bad triangulation of range maps.")); + switch (ID(action)) { + case FP_SELECT_FACES_BY_EDGE: { + float maxVal = m.cm.bbox.Diag() / 2.0f; + parlst.addParam(RichDynamicFloat( + "Threshold", + maxVal * 0.01, + 0, + maxVal, + "Edge Threshold", + "All the faces with an edge longer than this threshold will be deleted. Useful " + "for removing long skinny faces obtained by bad triangulation of range maps.")); } break; - + case FP_SELECT_BORDER: - //parlst.addParam(RichInt("Iteration", true, "Inclusive Sel.", "If true only the faces with all selected vertices are selected. Otherwise any face with at least one selected vertex will be selected.")); - break; + // parlst.addParam(RichInt("Iteration", true, "Inclusive Sel.", "If true only the faces with + // all selected vertices are selected. Otherwise any face with at least one selected + // vertex will be selected.")); + break; - case FP_SELECTBYANGLE : - { - parlst.addParam(RichDynamicFloat("anglelimit", 75.0f, 0.0f, 180.0f, "angle threshold (deg)", "faces with normal at higher angle w.r.t. the view direction are selected")); - parlst.addParam(RichBool ("usecamera", false, "Use ViewPoint from Mesh Camera", "Uses the ViewPoint from the camera associated to the current mesh\n if there is no camera, an error occurs")); - parlst.addParam(RichDirection("viewpoint", Point3f(0.0f, 0.0f, 0.0f), "ViewPoint", "if UseCamera is true, this value is ignored")); + case FP_SELECTBYANGLE: { + parlst.addParam(RichDynamicFloat( + "anglelimit", + 75.0f, + 0.0f, + 180.0f, + "angle threshold (deg)", + "faces with normal at higher angle w.r.t. the view direction are selected")); + parlst.addParam(RichBool( + "usecamera", + false, + "Use ViewPoint from Mesh Camera", + "Uses the ViewPoint from the camera associated to the current mesh\n if there is no " + "camera, an error occurs")); + parlst.addParam(RichDirection( + "viewpoint", + Point3f(0.0f, 0.0f, 0.0f), + "ViewPoint", + "if UseCamera is true, this value is ignored")); } break; - case FP_SELECT_UGLY : - parlst.addParam(RichBool("useAR", true, "select by Aspect Ratio", "if true, faces with aspect ratio below the limit will be selected")); - parlst.addParam(RichDynamicFloat("ARatio", 0.02, 0.0, 1.0, tr("Aspect Ratio"), tr("Triangle face aspect ratio [1 (equilateral) - 0 (line)]: face will be selected if BELOW this threshold"))); - parlst.addParam(RichBool("useNF", false, "select by Normal Angle", "if true, adjacent faces with normals forming an angle above the limit will be selected")); - parlst.addParam(RichDynamicFloat("NFRatio", 60, 0.0, 180.0, tr("Angle flip"), tr("angle between the adjacent faces: face will be selected if ABOVE this threshold"))); - break; + case FP_SELECT_UGLY: + parlst.addParam(RichBool( + "useAR", + true, + "select by Aspect Ratio", + "if true, faces with aspect ratio below the limit will be selected")); + parlst.addParam(RichDynamicFloat( + "ARatio", + 0.02, + 0.0, + 1.0, + tr("Aspect Ratio"), + tr("Triangle face aspect ratio [1 (equilateral) - 0 (line)]: face will be selected if " + "BELOW this threshold"))); + parlst.addParam(RichBool( + "useNF", + false, + "select by Normal Angle", + "if true, adjacent faces with normals forming an angle above the limit will be " + "selected")); + parlst.addParam(RichDynamicFloat( + "NFRatio", + 60, + 0.0, + 180.0, + tr("Angle flip"), + tr("angle between the adjacent faces: face will be selected if ABOVE this threshold"))); + break; case FP_SELECT_FACE_FROM_VERT: - parlst.addParam(RichBool("Inclusive", true, "Strict Selection", "If true only the faces with all selected vertices are selected. Otherwise any face with at least one selected vertex will be selected.")); - break; + parlst.addParam(RichBool( + "Inclusive", + true, + "Strict Selection", + "If true only the faces with all selected vertices are selected. Otherwise any " + "face with at least one selected vertex will be selected.")); + break; - case FP_SELECT_VERT_FROM_FACE: - parlst.addParam(RichBool("Inclusive", true, "Strict Selection", "If true only the vertices with all the incident face selected are selected. Otherwise any vertex with at least one incident selected face will be selected.")); - break; + case FP_SELECT_VERT_FROM_FACE: + parlst.addParam(RichBool( + "Inclusive", + true, + "Strict Selection", + "If true only the vertices with all the incident face selected are selected. " + "Otherwise any vertex with at least one incident selected face will be selected.")); + break; - case FP_SELECT_BY_VERT_QUALITY: - { - std::pair minmax = tri::Stat::ComputePerVertexQualityMinMax(m.cm); - float minq=minmax.first; - float maxq=minmax.second; + case FP_SELECT_BY_VERT_QUALITY: { + std::pair minmax = tri::Stat::ComputePerVertexQualityMinMax(m.cm); + float minq = minmax.first; + float maxq = minmax.second; - parlst.addParam(RichDynamicFloat("minQ", minq*0.75+maxq*.25, minq, maxq, tr("Min Quality"), tr("Minimum acceptable quality value") )); - parlst.addParam(RichDynamicFloat("maxQ", minq*0.25+maxq*.75, minq, maxq, tr("Max Quality"), tr("Maximum acceptable quality value") )); - parlst.addParam(RichBool("Inclusive", true, "Inclusive Sel.", "If true only the faces with all the vertices within the specified range are selected. Otherwise any face with at least one vertex within the range is selected.")); + parlst.addParam(RichDynamicFloat( + "minQ", + minq * 0.75 + maxq * .25, + minq, + maxq, + tr("Min Quality"), + tr("Minimum acceptable quality value"))); + parlst.addParam(RichDynamicFloat( + "maxQ", + minq * 0.25 + maxq * .75, + minq, + maxq, + tr("Max Quality"), + tr("Maximum acceptable quality value"))); + parlst.addParam(RichBool( + "Inclusive", + true, + "Inclusive Sel.", + "If true only the faces with all the vertices within the specified range are " + "selected. Otherwise any face with at least one vertex within the range is selected.")); } break; - case FP_SELECT_BY_FACE_QUALITY: - { - std::pair minmax = tri::Stat::ComputePerFaceQualityMinMax(m.cm); - float minq=minmax.first; - float maxq=minmax.second; + case FP_SELECT_BY_FACE_QUALITY: { + std::pair minmax = tri::Stat::ComputePerFaceQualityMinMax(m.cm); + float minq = minmax.first; + float maxq = minmax.second; - parlst.addParam(RichDynamicFloat("minQ", minq*0.75+maxq*.25, minq, maxq, tr("Min Quality"), tr("Minimum acceptable quality value") )); - parlst.addParam(RichDynamicFloat("maxQ", minq*0.25+maxq*.75, minq, maxq, tr("Max Quality"), tr("Maximum acceptable quality value") )); - parlst.addParam(RichBool("Inclusive", true, "Inclusive Sel.", "If true only the vertices with all the adjacent faces within the specified range are selected. Otherwise any vertex with at least one face within the range is selected.")); + parlst.addParam(RichDynamicFloat( + "minQ", + minq * 0.75 + maxq * .25, + minq, + maxq, + tr("Min Quality"), + tr("Minimum acceptable quality value"))); + parlst.addParam(RichDynamicFloat( + "maxQ", + minq * 0.25 + maxq * .75, + minq, + maxq, + tr("Max Quality"), + tr("Maximum acceptable quality value"))); + parlst.addParam(RichBool( + "Inclusive", + true, + "Inclusive Sel.", + "If true only the vertices with all the adjacent faces within the specified " + "range are selected. Otherwise any vertex with at least one face within the range is " + "selected.")); } break; - - case FP_SELECT_BY_COLOR: - { - parlst.addParam(RichColor("Color",Color4b::Black, tr("Color To Select"), tr("Color that you want to be selected.") )); + + case FP_SELECT_BY_COLOR: { + parlst.addParam(RichColor( + "Color", + Color4b::Black, + tr("Color To Select"), + tr("Color that you want to be selected."))); QStringList colorspace; - colorspace << "HSV" << "RGB"; - parlst.addParam(RichEnum("ColorSpace", 0, colorspace, tr("Pick Color Space"), tr("The color space that the sliders will manipulate.") )); + colorspace << "HSV" + << "RGB"; + parlst.addParam(RichEnum( + "ColorSpace", + 0, + colorspace, + tr("Pick Color Space"), + tr("The color space that the sliders will manipulate."))); - parlst.addParam(RichBool("Inclusive", true, "Inclusive Sel.", "If true only the faces with all the vertices within the specified range are selected. Otherwise any face with at least one vertex within the range is selected.")); + parlst.addParam(RichBool( + "Inclusive", + true, + "Inclusive Sel.", + "If true only the faces with all the vertices within the specified range are " + "selected. Otherwise any face with at least one vertex within the range is selected.")); - parlst.addParam(RichDynamicFloat("PercentRH", 0.2f, 0.0f, 1.0f, tr("Variation from Red or Hue"), tr("A float between 0 and 1 that represents the percent variation from this color that will be selected. For example if the R was 200 and you put 0.1 then any color with R 200+-25.5 will be selected.") )); - parlst.addParam(RichDynamicFloat("PercentGS", 0.2f, 0.0f, 1.0f, tr("Variation from Green or Saturation"), tr("A float between 0 and 1 that represents the percent variation from this color that will be selected. For example if the R was 200 and you put 0.1 then any color with R 200+-25.5 will be selected.") )); - parlst.addParam(RichDynamicFloat("PercentBV", 0.2f, 0.0f, 1.0f, tr("Variation from Blue or Value"), tr("A float between 0 and 1 that represents the percent variation from this color that will be selected. For example if the R was 200 and you put 0.1 then any color with R 200+-25.5 will be selected.") )); + parlst.addParam(RichDynamicFloat( + "PercentRH", + 0.2f, + 0.0f, + 1.0f, + tr("Variation from Red or Hue"), + tr("A float between 0 and 1 that represents the percent variation from this color that " + "will be selected. For example if the R was 200 and you put 0.1 then any color " + "with R 200+-25.5 will be selected."))); + parlst.addParam(RichDynamicFloat( + "PercentGS", + 0.2f, + 0.0f, + 1.0f, + tr("Variation from Green or Saturation"), + tr("A float between 0 and 1 that represents the percent variation from this color that " + "will be selected. For example if the R was 200 and you put 0.1 then any color " + "with R 200+-25.5 will be selected."))); + parlst.addParam(RichDynamicFloat( + "PercentBV", + 0.2f, + 0.0f, + 1.0f, + tr("Variation from Blue or Value"), + tr("A float between 0 and 1 that represents the percent variation from this color that " + "will be selected. For example if the R was 200 and you put 0.1 then any color " + "with R 200+-25.5 will be selected."))); } break; - case FP_SELECT_ALL: - { - parlst.addParam(RichBool("allFaces", true, "Select all Faces", "If true the filter will select all the faces.")); - parlst.addParam(RichBool("allVerts", true, "Select all Vertices", "If true the filter will select all the vertices.")); + case FP_SELECT_ALL: { + parlst.addParam(RichBool( + "allFaces", true, "Select all Faces", "If true the filter will select all the faces.")); + parlst.addParam(RichBool( + "allVerts", + true, + "Select all Vertices", + "If true the filter will select all the vertices.")); } break; - case FP_SELECT_NONE: - { - parlst.addParam(RichBool("allFaces", true, "De-select all Faces", "If true the filter will de-select all the faces.")); - parlst.addParam(RichBool("allVerts", true, "De-select all Vertices", "If true the filter will de-select all the vertices.")); + case FP_SELECT_NONE: { + parlst.addParam(RichBool( + "allFaces", + true, + "De-select all Faces", + "If true the filter will de-select all the faces.")); + parlst.addParam(RichBool( + "allVerts", + true, + "De-select all Vertices", + "If true the filter will de-select all the vertices.")); } break; - case FP_SELECT_INVERT: - { + case FP_SELECT_INVERT: { bool defF = (m.cm.sfn > 0) ? true : false; bool defV = (m.cm.svn > 0) ? true : false; - parlst.addParam(RichBool("InvFaces", defF, "Invert Faces", "If true the filter will invert the set of selected faces.")); - parlst.addParam(RichBool("InvVerts", defV, "Invert Vertices", "If true the filter will invert the set of selected vertices.")); + parlst.addParam(RichBool( + "InvFaces", + defF, + "Invert Faces", + "If true the filter will invert the set of selected faces.")); + parlst.addParam(RichBool( + "InvVerts", + defV, + "Invert Vertices", + "If true the filter will invert the set of selected vertices.")); } break; - case FP_SELECT_OUTLIER: - { - parlst.addParam(RichDynamicFloat("PropThreshold", 0.8, 0.0, 1.0, tr("Probability"), tr("Threshold to select the vertex. The vertex is selected if the LoOP value is above the threshold."))); - parlst.addParam(RichInt("KNearest", 32, tr("Number of neighbors"), tr("Number of neighbours used to compute the LoOP"))); + case FP_SELECT_OUTLIER: { + parlst.addParam(RichDynamicFloat( + "PropThreshold", + 0.8, + 0.0, + 1.0, + tr("Probability"), + tr("Threshold to select the vertex. The vertex is selected if the LoOP value is above " + "the threshold."))); + parlst.addParam(RichInt( + "KNearest", + 32, + tr("Number of neighbors"), + tr("Number of neighbours used to compute the LoOP"))); } break; - case FP_SELECT_DELETE_ALL_FACE: - { - parlst.addParam(RichBool("allLayers", false, "Apply to all visible Layers", "If selected, the filter will be applied to all visible mesh Layers.")); + case FP_SELECT_DELETE_ALL_FACE: { + parlst.addParam(RichBool( + "allLayers", + false, + "Apply to all visible Layers", + "If selected, the filter will be applied to all visible mesh Layers.")); } break; - } - return parlst; + } + return parlst; } std::map SelectionFilterPlugin::applyFilter( - const QAction *action, - const RichParameterList & par, - MeshDocument &md, - unsigned int& /*postConditionMask*/, - vcg::CallBackPos * /*cb*/) + const QAction* action, + const RichParameterList& par, + MeshDocument& md, + unsigned int& /*postConditionMask*/, + vcg::CallBackPos* /*cb*/) { - MeshModel &m=*(md.mm()); - CMeshO::FaceIterator fi; + MeshModel& m = *(md.mm()); + CMeshO::FaceIterator fi; CMeshO::VertexIterator vi; - switch(ID(action)) - { - case FP_SELECT_DELETE_VERT: - { - if (m.cm.svn == 0) { log("Nothing done: no vertex selected"); break; } + switch (ID(action)) { + case FP_SELECT_DELETE_VERT: { + if (m.cm.svn == 0) { + log("Nothing done: no vertex selected"); + break; + } tri::UpdateSelection::FaceClear(m.cm); tri::UpdateSelection::FaceFromVertexLoose(m.cm); int vvn = m.cm.vn; @@ -329,13 +528,10 @@ std::map SelectionFilterPlugin::applyFilter( log("Deleted %i vertices, %i faces.", vvn - m.cm.vn, ffn - m.cm.fn); } break; - case FP_SELECT_DELETE_ALL_FACE: - { - if (par.getBool("allLayers")) - { - MeshModel *ml = NULL; - while ((ml = md.nextVisibleMesh(ml))) - { + case FP_SELECT_DELETE_ALL_FACE: { + if (par.getBool("allLayers")) { + MeshModel* ml = NULL; + while ((ml = md.nextVisibleMesh(ml))) { int ffn = ml->cm.fn; for (fi = ml->cm.face.begin(); fi != ml->cm.face.end(); ++fi) if (!(*fi).IsD()) @@ -346,8 +542,7 @@ std::map SelectionFilterPlugin::applyFilter( log("Layer %i: deleted all %i faces.", ml->id(), ffn - ml->cm.fn); } } - else - { + else { int ffn = m.cm.fn; for (fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) if (!(*fi).IsD()) @@ -359,9 +554,11 @@ std::map SelectionFilterPlugin::applyFilter( } } break; - case FP_SELECT_DELETE_FACE: - { - if (m.cm.sfn == 0) { log("Nothing done: no faces selected"); break; } + case FP_SELECT_DELETE_FACE: { + if (m.cm.sfn == 0) { + log("Nothing done: no faces selected"); + break; + } int ffn = m.cm.fn; for (fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) if (!(*fi).IsD() && (*fi).IsS()) @@ -372,9 +569,11 @@ std::map SelectionFilterPlugin::applyFilter( log("Deleted %i faces.", ffn - m.cm.fn); } break; - case FP_SELECT_DELETE_FACEVERT: - { - if (m.cm.sfn == 0) { log("Nothing done: no faces selected"); break; } + case FP_SELECT_DELETE_FACEVERT: { + if (m.cm.sfn == 0) { + log("Nothing done: no faces selected"); + break; + } tri::UpdateSelection::VertexClear(m.cm); tri::UpdateSelection::VertexFromFaceStrict(m.cm); int vvn = m.cm.vn; @@ -391,93 +590,88 @@ std::map SelectionFilterPlugin::applyFilter( log("Deleted %i faces, %i vertices.", ffn - m.cm.fn, vvn - m.cm.vn); } break; - case FP_SELECT_CONNECTED: - tri::UpdateSelection::FaceConnectedFF(m.cm); - break; + case FP_SELECT_CONNECTED: tri::UpdateSelection::FaceConnectedFF(m.cm); break; - case FP_SELECTBYANGLE : - { - CMeshO::FaceIterator fi; - bool usecam = par.getBool("usecamera"); - Point3m viewpoint = par.getPoint3m("viewpoint"); + case FP_SELECTBYANGLE: { + CMeshO::FaceIterator fi; + bool usecam = par.getBool("usecamera"); + Point3m viewpoint = par.getPoint3m("viewpoint"); // if usecamera but mesh does not have one - if( usecam && !m.hasDataMask(MeshModel::MM_CAMERA) ) - { - throw MLException("Mesh has not a camera that can be used to compute view direction. Please set a view direction."); + if (usecam && !m.hasDataMask(MeshModel::MM_CAMERA)) { + throw MLException( + "Mesh has not a camera that can be used to compute view direction. Please set a " + "view direction."); } - if(usecam) - { + if (usecam) { viewpoint = m.cm.shot.GetViewPoint(); } // angle threshold in radians - Scalarm limit = cos( math::ToRad(par.getDynamicFloat("anglelimit")) ); + Scalarm limit = cos(math::ToRad(par.getDynamicFloat("anglelimit"))); Point3m viewray; - for(fi=m.cm.face.begin();fi!=m.cm.face.end();++fi) - if(!(*fi).IsD()) - { + for (fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) + if (!(*fi).IsD()) { viewray = Barycenter(*fi) - viewpoint; viewray.Normalize(); - if((viewray.dot((*fi).N().Normalize())) < limit) + if ((viewray.dot((*fi).N().Normalize())) < limit) fi->SetS(); } } break; - case FP_SELECT_UGLY : - { + case FP_SELECT_UGLY: { + vcg::tri::UpdateSelection::Clear(m.cm); // elongated - if (par.getBool("useAR")) - for (fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) - if (!(*fi).IsD()) - { + if (par.getBool("useAR")) { + for (fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) { + if (!(*fi).IsD()) { float QQ = QualityRadii((*fi).V(0)->P(), (*fi).V(1)->P(), (*fi).V(2)->P()); - if (QQSetS(); } + } + } // flipped normal - if (par.getBool("useNF")) - { + if (par.getBool("useNF")) { md.mm()->updateDataMask(MeshModel::MM_FACEFACETOPO); - for (fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) - if (!(*fi).IsD()) - { + for (fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) { + if (!(*fi).IsD()) { float QQ = 0; - for (int ei = 0; ei < 3; ei++) - { + for (int ei = 0; ei < 3; ei++) { CMeshO::FacePointer adjf = (*fi).FFp(ei); - float nangle = (*adjf).N().Normalize() * (*fi).N().Normalize(); - nangle = math::ToDeg(fabsf(acos(nangle))); - if (nangle > QQ) QQ = nangle; + float nangle = (*adjf).N().Normalize() * (*fi).N().Normalize(); + nangle = math::ToDeg(fabsf(acos(nangle))); + if (nangle > QQ) + QQ = nangle; } if (QQ > par.getFloat("NFRatio")) fi->SetS(); } + } m.clearDataMask(MeshModel::MM_FACEFACETOPO); } - } break; - case FP_SELECT_ALL : + case FP_SELECT_ALL: if (par.getBool("allVerts")) tri::UpdateSelection::VertexAll(m.cm); if (par.getBool("allFaces")) tri::UpdateSelection::FaceAll(m.cm); break; - case FP_SELECT_NONE : + case FP_SELECT_NONE: if (par.getBool("allVerts")) tri::UpdateSelection::VertexClear(m.cm); if (par.getBool("allFaces")) tri::UpdateSelection::FaceClear(m.cm); break; - case FP_SELECT_INVERT : + case FP_SELECT_INVERT: if (par.getBool("InvVerts")) tri::UpdateSelection::VertexInvert(m.cm); if (par.getBool("InvFaces")) @@ -515,11 +709,10 @@ std::map SelectionFilterPlugin::applyFilter( tri::UpdateSelection::VertexFromBorderFlag(m.cm); break; - case FP_SELECT_BY_VERT_QUALITY: - { - Scalarm minQ = par.getDynamicFloat("minQ"); - Scalarm maxQ = par.getDynamicFloat("maxQ"); - bool inclusiveFlag = par.getBool("Inclusive"); + case FP_SELECT_BY_VERT_QUALITY: { + Scalarm minQ = par.getDynamicFloat("minQ"); + Scalarm maxQ = par.getDynamicFloat("maxQ"); + bool inclusiveFlag = par.getBool("Inclusive"); tri::UpdateSelection::VertexFromQualityRange(m.cm, minQ, maxQ); if (inclusiveFlag) tri::UpdateSelection::FaceFromVertexStrict(m.cm); @@ -527,11 +720,10 @@ std::map SelectionFilterPlugin::applyFilter( tri::UpdateSelection::FaceFromVertexLoose(m.cm); } break; - case FP_SELECT_BY_FACE_QUALITY: - { - Scalarm minQ = par.getDynamicFloat("minQ"); - Scalarm maxQ = par.getDynamicFloat("maxQ"); - bool inclusiveFlag = par.getBool("Inclusive"); + case FP_SELECT_BY_FACE_QUALITY: { + Scalarm minQ = par.getDynamicFloat("minQ"); + Scalarm maxQ = par.getDynamicFloat("maxQ"); + bool inclusiveFlag = par.getBool("Inclusive"); tri::UpdateSelection::FaceFromQualityRange(m.cm, minQ, maxQ); if (inclusiveFlag) tri::UpdateSelection::VertexFromFaceStrict(m.cm); @@ -539,20 +731,19 @@ std::map SelectionFilterPlugin::applyFilter( tri::UpdateSelection::VertexFromFaceLoose(m.cm); } break; - case FP_SELECT_BY_COLOR: - { - int colorSpace = par.getEnum("ColorSpace"); + case FP_SELECT_BY_COLOR: { + int colorSpace = par.getEnum("ColorSpace"); QColor targetColor = par.getColor("Color"); - float red = targetColor.redF(); + float red = targetColor.redF(); float green = targetColor.greenF(); - float blue = targetColor.blueF(); + float blue = targetColor.blueF(); - float hue = targetColor.hue()/360.0f;// Normalized into [0..1) range + float hue = targetColor.hue() / 360.0f; // Normalized into [0..1) range float saturation = targetColor.saturationF(); - float value = targetColor.valueF(); + float value = targetColor.valueF(); - //like fuzz factor in photoshop + // like fuzz factor in photoshop float valueRH = par.getDynamicFloat("PercentRH"); float valueGS = par.getDynamicFloat("PercentGS"); float valueBV = par.getDynamicFloat("PercentBV"); @@ -560,28 +751,25 @@ std::map SelectionFilterPlugin::applyFilter( tri::UpdateSelection::FaceClear(m.cm); tri::UpdateSelection::VertexClear(m.cm); - //now loop through all the faces - for(vi = m.cm.vert.begin(); vi != m.cm.vert.end(); ++vi) - { - if(!(*vi).IsD()) - { + // now loop through all the faces + for (vi = m.cm.vert.begin(); vi != m.cm.vert.end(); ++vi) { + if (!(*vi).IsD()) { Color4f colorv = Color4f::Construct((*vi).C()); - if(colorSpace == 0){ + if (colorSpace == 0) { colorv = ColorSpace::RGBtoHSV(colorv); - if( fabsf(colorv[0] - hue) <= valueRH && - fabsf(colorv[1] - saturation) <= valueGS && - fabsf(colorv[2] - value) <= valueBV ) + if (fabsf(colorv[0] - hue) <= valueRH && + fabsf(colorv[1] - saturation) <= valueGS && + fabsf(colorv[2] - value) <= valueBV) (*vi).SetS(); } - else { - if( fabsf(colorv[0] - red) <= valueRH && - fabsf(colorv[1] - green) <= valueGS && - fabsf(colorv[2] - blue) <= valueBV ) + else { + if (fabsf(colorv[0] - red) <= valueRH && fabsf(colorv[1] - green) <= valueGS && + fabsf(colorv[2] - blue) <= valueBV) (*vi).SetS(); } } } - if(par.getBool("Inclusive")) + if (par.getBool("Inclusive")) tri::UpdateSelection::FaceFromVertexStrict(m.cm); else tri::UpdateSelection::FaceFromVertexLoose(m.cm); @@ -598,62 +786,59 @@ std::map SelectionFilterPlugin::applyFilter( tri::UpdateFlags::VertexBorderFromFaceBorder(m.cm); break; - case CP_SELECT_NON_MANIFOLD_FACE: - tri::Clean::CountNonManifoldEdgeFF(m.cm,true); - break; + case CP_SELECT_NON_MANIFOLD_FACE: tri::Clean::CountNonManifoldEdgeFF(m.cm, true); break; case CP_SELECT_NON_MANIFOLD_VERTEX: - tri::Clean::CountNonManifoldVertexFF(m.cm,true); + tri::Clean::CountNonManifoldVertexFF(m.cm, true); break; - case CP_SELFINTERSECT_SELECT: - { - std::vector IntersFace; + case CP_SELFINTERSECT_SELECT: { + std::vector IntersFace; tri::Clean::SelfIntersections(m.cm, IntersFace); tri::UpdateSelection::FaceClear(m.cm); - std::vector::iterator fpi; + std::vector::iterator fpi; for (fpi = IntersFace.begin(); fpi != IntersFace.end(); ++fpi) (*fpi)->SetS(); } break; - case FP_SELECT_FACES_BY_EDGE: - { - Scalarm threshold = par.getDynamicFloat("Threshold"); - int selFaceNum = tri::UpdateSelection::FaceOutOfRangeEdge(m.cm,0,threshold ); - log( "Selected %d faces with and edge longer than %f",selFaceNum,threshold); + case FP_SELECT_FACES_BY_EDGE: { + Scalarm threshold = par.getDynamicFloat("Threshold"); + int selFaceNum = tri::UpdateSelection::FaceOutOfRangeEdge(m.cm, 0, threshold); + log("Selected %d faces with and edge longer than %f", selFaceNum, threshold); } break; - case FP_SELECT_OUTLIER: - { - Scalarm threshold = par.getDynamicFloat("PropThreshold"); - int kNearest = par.getInt("KNearest"); - VertexConstDataWrapper wrapper(m.cm); + case FP_SELECT_OUTLIER: { + Scalarm threshold = par.getDynamicFloat("PropThreshold"); + int kNearest = par.getInt("KNearest"); + VertexConstDataWrapper wrapper(m.cm); KdTree kdTree(wrapper); - int selVertexNum = tri::OutlierRemoval::SelectLoOPOutliers(m.cm, kdTree, kNearest, threshold); + int selVertexNum = + tri::OutlierRemoval::SelectLoOPOutliers(m.cm, kdTree, kNearest, threshold); log("Selected %d outlier vertices", selVertexNum); } break; - default: - wrongActionCalled(action); + default: wrongActionCalled(action); } return std::map(); } -FilterPlugin::FilterClass SelectionFilterPlugin::getClass(const QAction *action) const +FilterPlugin::FilterClass SelectionFilterPlugin::getClass(const QAction* action) const { - switch(ID(action)) - { - case CP_SELFINTERSECT_SELECT: return FilterClass(FilterPlugin::Selection + FilterPlugin::Cleaning); + switch (ID(action)) { + case CP_SELFINTERSECT_SELECT: + return FilterClass(FilterPlugin::Selection + FilterPlugin::Cleaning); - case CP_SELECT_TEXBORDER : return FilterClass(FilterPlugin::Selection + FilterPlugin::Texture); + case CP_SELECT_TEXBORDER: return FilterClass(FilterPlugin::Selection + FilterPlugin::Texture); - case FP_SELECT_BY_FACE_QUALITY : - case FP_SELECT_BY_VERT_QUALITY : return FilterClass(FilterPlugin::Selection + FilterPlugin::Quality); + case FP_SELECT_BY_FACE_QUALITY: + case FP_SELECT_BY_VERT_QUALITY: + return FilterClass(FilterPlugin::Selection + FilterPlugin::Quality); - case FP_SELECTBYANGLE : return FilterPlugin::FilterClass(FilterPlugin::RangeMap + FilterPlugin::Selection); + case FP_SELECTBYANGLE: + return FilterPlugin::FilterClass(FilterPlugin::RangeMap + FilterPlugin::Selection); - case FP_SELECT_ALL : - case FP_SELECT_NONE : + case FP_SELECT_ALL: + case FP_SELECT_NONE: case FP_SELECT_CONNECTED: case FP_SELECT_UGLY: case FP_SELECT_DELETE_VERT: @@ -668,77 +853,74 @@ FilterPlugin::FilterClass SelectionFilterPlugin::getClass(const QAction *action) case FP_SELECT_INVERT: case FP_SELECT_FACES_BY_EDGE: case FP_SELECT_OUTLIER: - case FP_SELECT_BY_COLOR: + case FP_SELECT_BY_COLOR: case CP_SELECT_NON_MANIFOLD_VERTEX: - case CP_SELECT_NON_MANIFOLD_FACE: return FilterClass(FilterPlugin::Selection); - } - return FilterPlugin::Selection; + case CP_SELECT_NON_MANIFOLD_FACE: return FilterClass(FilterPlugin::Selection); + } + return FilterPlugin::Selection; } - int SelectionFilterPlugin::getRequirements(const QAction *action) +int SelectionFilterPlugin::getRequirements(const QAction* action) { - switch(ID(action)) - { + switch (ID(action)) { case CP_SELECT_NON_MANIFOLD_FACE: - case CP_SELECT_NON_MANIFOLD_VERTEX: - case FP_SELECT_CONNECTED: return MeshModel::MM_FACEFACETOPO; - + case CP_SELECT_NON_MANIFOLD_VERTEX: + case FP_SELECT_CONNECTED: return MeshModel::MM_FACEFACETOPO; + case CP_SELECT_TEXBORDER: return MeshModel::MM_FACEFACETOPO; case CP_SELFINTERSECT_SELECT: return MeshModel::MM_FACEMARK | MeshModel::MM_FACEFACETOPO; default: return MeshModel::MM_NONE; - } + } } -int SelectionFilterPlugin::postCondition(const QAction *action) const +int SelectionFilterPlugin::postCondition(const QAction* action) const { - switch(ID(action)) - { - case FP_SELECT_ALL : - case FP_SELECT_FACE_FROM_VERT : - case FP_SELECT_VERT_FROM_FACE : - case FP_SELECT_NONE : - case FP_SELECT_INVERT : - case FP_SELECT_ERODE : - case FP_SELECT_CONNECTED : - case FP_SELECT_DILATE : - case FP_SELECT_BORDER : - case FP_SELECT_BY_VERT_QUALITY : - case FP_SELECT_BY_FACE_QUALITY : - case FP_SELECT_BY_COLOR : - case CP_SELFINTERSECT_SELECT : - case CP_SELECT_TEXBORDER : - case CP_SELECT_NON_MANIFOLD_FACE : - case CP_SELECT_NON_MANIFOLD_VERTEX : - case FP_SELECT_FACES_BY_EDGE : - case FP_SELECT_UGLY : - case FP_SELECT_OUTLIER : return MeshModel::MM_VERTFLAGSELECT | MeshModel::MM_FACEFLAGSELECT; - case FP_SELECT_DELETE_VERT : - case FP_SELECT_DELETE_ALL_FACE : - case FP_SELECT_DELETE_FACE : - case FP_SELECT_DELETE_FACEVERT : return MeshModel::MM_GEOMETRY_AND_TOPOLOGY_CHANGE; - } - return MeshModel::MM_ALL; + switch (ID(action)) { + case FP_SELECT_ALL: + case FP_SELECT_FACE_FROM_VERT: + case FP_SELECT_VERT_FROM_FACE: + case FP_SELECT_NONE: + case FP_SELECT_INVERT: + case FP_SELECT_ERODE: + case FP_SELECT_CONNECTED: + case FP_SELECT_DILATE: + case FP_SELECT_BORDER: + case FP_SELECT_BY_VERT_QUALITY: + case FP_SELECT_BY_FACE_QUALITY: + case FP_SELECT_BY_COLOR: + case CP_SELFINTERSECT_SELECT: + case CP_SELECT_TEXBORDER: + case CP_SELECT_NON_MANIFOLD_FACE: + case CP_SELECT_NON_MANIFOLD_VERTEX: + case FP_SELECT_FACES_BY_EDGE: + case FP_SELECT_UGLY: + case FP_SELECT_OUTLIER: return MeshModel::MM_VERTFLAGSELECT | MeshModel::MM_FACEFLAGSELECT; + case FP_SELECT_DELETE_VERT: + case FP_SELECT_DELETE_ALL_FACE: + case FP_SELECT_DELETE_FACE: + case FP_SELECT_DELETE_FACEVERT: return MeshModel::MM_GEOMETRY_AND_TOPOLOGY_CHANGE; + } + return MeshModel::MM_ALL; } -int SelectionFilterPlugin::getPreConditions(const QAction * action) const +int SelectionFilterPlugin::getPreConditions(const QAction* action) const { - switch(ID(action)) - { - case CP_SELECT_NON_MANIFOLD_VERTEX: - case CP_SELECT_NON_MANIFOLD_FACE: - case CP_SELFINTERSECT_SELECT: - case FP_SELECT_FACES_BY_EDGE: - case FP_SELECT_FACE_FROM_VERT: - case FP_SELECT_BORDER: - case FP_SELECT_ERODE: - case FP_SELECT_DILATE: - case FP_SELECT_CONNECTED: return MeshModel::MM_FACENUMBER; - case FP_SELECT_BY_COLOR: return MeshModel::MM_VERTCOLOR; - case FP_SELECT_BY_VERT_QUALITY: return MeshModel::MM_VERTQUALITY; - case FP_SELECT_BY_FACE_QUALITY: return MeshModel::MM_FACEQUALITY; - case CP_SELECT_TEXBORDER: return MeshModel::MM_WEDGTEXCOORD; - } - return 0; + switch (ID(action)) { + case CP_SELECT_NON_MANIFOLD_VERTEX: + case CP_SELECT_NON_MANIFOLD_FACE: + case CP_SELFINTERSECT_SELECT: + case FP_SELECT_FACES_BY_EDGE: + case FP_SELECT_FACE_FROM_VERT: + case FP_SELECT_BORDER: + case FP_SELECT_ERODE: + case FP_SELECT_DILATE: + case FP_SELECT_CONNECTED: return MeshModel::MM_FACENUMBER; + case FP_SELECT_BY_COLOR: return MeshModel::MM_VERTCOLOR; + case FP_SELECT_BY_VERT_QUALITY: return MeshModel::MM_VERTQUALITY; + case FP_SELECT_BY_FACE_QUALITY: return MeshModel::MM_FACEQUALITY; + case CP_SELECT_TEXBORDER: return MeshModel::MM_WEDGTEXCOORD; + } + return 0; } MESHLAB_PLUGIN_NAME_EXPORTER(SelectionFilterPlugin) diff --git a/src/meshlabplugins/filter_select/meshselect.h b/src/meshlabplugins/filter_select/meshselect.h index 210ca9ce1..2c9dd31d5 100644 --- a/src/meshlabplugins/filter_select/meshselect.h +++ b/src/meshlabplugins/filter_select/meshselect.h @@ -1,25 +1,25 @@ -/**************************************************************************** -* MeshLab o o * -* A versatile mesh processing toolbox o o * -* _ O _ * -* Copyright(C) 2005 \/)\/ * -* Visual Computing Lab /\/| * -* ISTI - Italian National Research Council | * -* \ * -* All rights reserved. * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * -* for more details. * -* * -****************************************************************************/ +/***************************************************************************** + * MeshLab o o * + * A versatile mesh processing toolbox o o * + * _ O _ * + * Copyright(C) 2005-2021 \/)\/ * + * Visual Computing Lab /\/| * + * ISTI - Italian National Research Council | * + * \ * + * All rights reserved. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * + * for more details. * + * * + ****************************************************************************/ #ifndef FILTER_SELECT_H #define FILTER_SELECT_H @@ -27,7 +27,6 @@ #include #include - class SelectionFilterPlugin : public QObject, public FilterPlugin { Q_OBJECT @@ -35,10 +34,6 @@ class SelectionFilterPlugin : public QObject, public FilterPlugin Q_INTERFACES(FilterPlugin) public: - /* naming convention : - - FP -> Filter Plugin - - name of the plugin separated by _ - */ enum { FP_SELECT_ALL, FP_SELECT_NONE, @@ -58,32 +53,32 @@ public: FP_SELECT_BY_FACE_QUALITY, FP_SELECT_BY_VERT_QUALITY, FP_SELECT_BY_RANGE, - FP_SELECT_BY_COLOR,CP_SELFINTERSECT_SELECT, + FP_SELECT_BY_COLOR, + CP_SELFINTERSECT_SELECT, CP_SELECT_TEXBORDER, CP_SELECT_NON_MANIFOLD_FACE, CP_SELECT_NON_MANIFOLD_VERTEX, FP_SELECT_FACES_BY_EDGE, FP_SELECT_OUTLIER - } ; + }; SelectionFilterPlugin(); - //~SelectionFilterPlugin(); QString pluginName() const; QString filterInfo(ActionIDType filter) const; QString filterName(ActionIDType filter) const; - FilterClass getClass(const QAction*) const; - RichParameterList initParameterList(const QAction* action, const MeshModel &m); - int getPreConditions(const QAction*) const; - int postCondition(const QAction* ) const; - int getRequirements(const QAction*); + FilterClass getClass(const QAction*) const; + RichParameterList initParameterList(const QAction* action, const MeshModel& m); + int getPreConditions(const QAction*) const; + int postCondition(const QAction*) const; + int getRequirements(const QAction*); std::map applyFilter( - const QAction* action, - const RichParameterList & parameters, - MeshDocument &md, - unsigned int& postConditionMask, - vcg::CallBackPos * cb); - FilterArity filterArity(const QAction *) const {return SINGLE_MESH;} + const QAction* action, + const RichParameterList& parameters, + MeshDocument& md, + unsigned int& postConditionMask, + vcg::CallBackPos* cb); + FilterArity filterArity(const QAction*) const { return SINGLE_MESH; } }; #endif