From 3fea196cdb42ab3fcf7f83b9cd7249e98ffdec7d Mon Sep 17 00:00:00 2001 From: Marco Callieri Date: Fri, 30 Mar 2018 15:56:39 +0200 Subject: [PATCH] filter layer postconditions --- .../filter_layer/filter_layer.cpp | 84 ++++++++++++------- .../filter_layer/filter_layer.h | 19 ++++- 2 files changed, 71 insertions(+), 32 deletions(-) diff --git a/src/meshlabplugins/filter_layer/filter_layer.cpp b/src/meshlabplugins/filter_layer/filter_layer.cpp index 101276ca9..1600f7b2d 100644 --- a/src/meshlabplugins/filter_layer/filter_layer.cpp +++ b/src/meshlabplugins/filter_layer/filter_layer.cpp @@ -120,8 +120,8 @@ void FilterLayerPlugin::initParameterSet(QAction *action, MeshDocument &md, Rich parlst.addParam(new RichBool ("DeleteOriginal", true, "Delete original selection", - "Deletes the original selected faces, thus splitting the mesh among layers. \n\n" - "if false, the selected faces are duplicated in the new layer")); + "Deletes the original selected faces/vertices, thus splitting the mesh among layers. \n\n" + "if false, the selected faces/vertices are duplicated in the new layer")); } break; case FP_FLATTEN : @@ -228,7 +228,7 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam MeshModel* destModel = md.addNewMesh("","SelectedVerticesSubset",true); destModel->updateDataMask(currentModel); - numVertSel = tri::UpdateSelection::VertexCount(currentModel->cm); + numVertSel = (int)tri::UpdateSelection::VertexCount(currentModel->cm); tri::Append::Mesh(destModel->cm, currentModel->cm, true); @@ -236,7 +236,7 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam { CMeshO::VertexIterator vi; - int delfaces = tri::UpdateSelection::FaceFromVertexLoose(currentModel->cm); + int delfaces = (int)tri::UpdateSelection::FaceFromVertexLoose(currentModel->cm); for (CMeshO::FaceIterator fi = currentModel->cm.face.begin(); fi != currentModel->cm.face.end(); ++fi) if(!(*fi).IsD() && (*fi).IsS() ) tri::Allocator::DeleteFace(currentModel->cm, *fi); @@ -270,8 +270,8 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam // select all points involved tri::UpdateSelection::VertexFromFaceLoose(currentModel->cm); - numFacesSel = tri::UpdateSelection::FaceCount(currentModel->cm); - numVertSel = tri::UpdateSelection::VertexCount(currentModel->cm); + numFacesSel = (int)tri::UpdateSelection::FaceCount(currentModel->cm); + numVertSel = (int)tri::UpdateSelection::VertexCount(currentModel->cm); tri::Append::Mesh(destModel->cm, currentModel->cm, true); @@ -704,8 +704,8 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam { fx = fx / 100; shots[id].Intrinsics.FocalMm = fx; - shots[id].Intrinsics.PixelSizeMm[0] = 0.01; - shots[id].Intrinsics.PixelSizeMm[1] = 0.01; + shots[id].Intrinsics.PixelSizeMm[0] = 0.01f; + shots[id].Intrinsics.PixelSizeMm[1] = 0.01f; } else { @@ -812,30 +812,26 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam FilterLayerPlugin::FilterClass FilterLayerPlugin::getClass(QAction *a) { - switch(ID(a)) - { - case FP_RENAME_MESH : - case FP_SPLITSELECTEDFACES : - case FP_SPLITSELECTEDVERTICES: - case FP_DUPLICATE : - case FP_FLATTEN : - case FP_SELECTCURRENT : - case FP_MESH_VISIBILITY : - case FP_SPLITCONNECTED : - case FP_DELETE_MESH : - case FP_DELETE_NON_VISIBLE_MESH : - return MeshFilterInterface::Layer; - case FP_RENAME_RASTER : - case FP_DELETE_RASTER : - case FP_DELETE_NON_SELECTED_RASTER : - case FP_EXPORT_CAMERAS: - return MeshFilterInterface::RasterLayer; - case FP_IMPORT_CAMERAS: - return FilterClass(MeshFilterInterface::Camera + MeshFilterInterface::RasterLayer); - - default : assert(0); - return MeshFilterInterface::Generic; + switch(ID(a)) + { + case FP_RENAME_MESH : + case FP_SPLITSELECTEDFACES : + case FP_SPLITSELECTEDVERTICES: + case FP_DUPLICATE : + case FP_FLATTEN : + case FP_SELECTCURRENT : + case FP_MESH_VISIBILITY : + case FP_SPLITCONNECTED : + case FP_DELETE_MESH : + case FP_DELETE_NON_VISIBLE_MESH : return MeshFilterInterface::Layer; + case FP_RENAME_RASTER : + case FP_DELETE_RASTER : + case FP_DELETE_NON_SELECTED_RASTER : + case FP_EXPORT_CAMERAS: return MeshFilterInterface::RasterLayer; + case FP_IMPORT_CAMERAS: return FilterClass(MeshFilterInterface::Camera + MeshFilterInterface::RasterLayer); + default : assert(0); } + return MeshFilterInterface::Generic; } MeshFilterInterface::FILTER_ARITY FilterLayerPlugin::filterArity( QAction* filter) const @@ -864,4 +860,30 @@ MeshFilterInterface::FILTER_ARITY FilterLayerPlugin::filterArity( QAction* filte return MeshFilterInterface::NONE; } +int FilterLayerPlugin::postCondition(QAction* filter) const +{ + switch (ID(filter)) + { + case FP_RENAME_MESH: + case FP_DUPLICATE: + case FP_SELECTCURRENT: + case FP_DELETE_MESH: + case FP_DELETE_NON_VISIBLE_MESH: + case FP_FLATTEN: + case FP_RENAME_RASTER: + case FP_DELETE_RASTER: + case FP_DELETE_NON_SELECTED_RASTER: + case FP_EXPORT_CAMERAS: + case FP_IMPORT_CAMERAS: + case FP_SPLITCONNECTED: + case FP_MESH_VISIBILITY: return MeshModel::MM_NONE; + + case FP_SPLITSELECTEDFACES: + case FP_SPLITSELECTEDVERTICES: return MeshModel::MM_GEOMETRY_CHANGE; + + default: assert(0); + } + return MeshFilterInterface::Generic; +} + MESHLAB_PLUGIN_NAME_EXPORTER(FilterLayerPlugin) diff --git a/src/meshlabplugins/filter_layer/filter_layer.h b/src/meshlabplugins/filter_layer/filter_layer.h index 33601be75..5edf55178 100644 --- a/src/meshlabplugins/filter_layer/filter_layer.h +++ b/src/meshlabplugins/filter_layer/filter_layer.h @@ -35,7 +35,23 @@ class FilterLayerPlugin : public QObject, public MeshFilterInterface Q_INTERFACES(MeshFilterInterface) public: - enum { FP_FLATTEN, FP_MESH_VISIBILITY, FP_SPLITSELECTEDFACES, FP_SPLITSELECTEDVERTICES, FP_SPLITCONNECTED, FP_DUPLICATE, FP_RENAME_MESH, FP_RENAME_RASTER, FP_DELETE_MESH, FP_DELETE_NON_VISIBLE_MESH,FP_DELETE_RASTER, FP_DELETE_NON_SELECTED_RASTER,FP_SELECTCURRENT, FP_EXPORT_CAMERAS, FP_IMPORT_CAMERAS}; + enum { + FP_FLATTEN, + FP_MESH_VISIBILITY, + FP_SPLITSELECTEDFACES, + FP_SPLITSELECTEDVERTICES, + FP_SPLITCONNECTED, + FP_DUPLICATE, + FP_RENAME_MESH, + FP_RENAME_RASTER, + FP_DELETE_MESH, + FP_DELETE_NON_VISIBLE_MESH, + FP_DELETE_RASTER, + FP_DELETE_NON_SELECTED_RASTER, + FP_SELECTCURRENT, + FP_EXPORT_CAMERAS, + FP_IMPORT_CAMERAS + }; FilterLayerPlugin(); @@ -44,6 +60,7 @@ public: virtual FilterClass getClass(QAction *); virtual void initParameterSet(QAction *,MeshDocument &/*m*/, RichParameterSet & /*parent*/); virtual bool applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & /*parent*/, vcg::CallBackPos * cb) ; + int postCondition(QAction *filter) const; FILTER_ARITY filterArity(QAction*) const; };