Added Filter classes (cleaning, meshing etc)

This commit is contained in:
Paolo Cignoni cignoni 2006-04-12 15:12:18 +00:00
parent e196beb2de
commit d4df8eaa5a
7 changed files with 163 additions and 102 deletions

View File

@ -27,6 +27,16 @@
==============================================================================
------------------------------------------------------------------------------
- Meshlab v0.7
------------------------------------------------------------------------------
** NEW FEATURES/PATCHES **
Bug in shaders
Filter classes (now filters are assigned to different submenus)
Intial mode faceted
------------------------------------------------------------------------------
- Meshlab v0.6
------------------------------------------------------------------------------

View File

@ -23,6 +23,9 @@
/****************************************************************************
History
$Log$
Revision 1.40 2006/04/12 15:12:18 cignoni
Added Filter classes (cleaning, meshing etc)
Revision 1.39 2006/02/21 17:25:57 ggangemi
RenderMode is now passed to MeshRenderInterface::Init()
@ -207,9 +210,12 @@ public:
class MeshFilterInterface
{
public:
enum FilterClass { Generic, Selection, Cleaning, Subdivision} ;
virtual ~MeshFilterInterface() {}
virtual QList<QAction *> actions() const = 0;
virtual const ActionInfo &Info(QAction *)=0;
virtual const FilterClass getClass(QAction *) {return FilterClass::Generic;};
virtual const PluginInfo &Info()=0;
virtual void setLog(GLLogStream* )=0;
virtual bool applyFilter(QAction * /*filter*/, MeshModel &/*m*/, QWidget * /*parent*/, vcg::CallBackPos * /*cb*/) = 0;

View File

@ -23,6 +23,9 @@
/****************************************************************************
History
$Log$
Revision 1.62 2006/04/12 15:12:18 cignoni
Added Filter classes (cleaning, meshing etc)
Revision 1.61 2006/02/17 11:17:23 glvertex
- Moved closeAction in FileMenu
- Minor changes
@ -158,8 +161,10 @@ private:
///////// Menus ///////////////
QMenu *fileMenu;
QMenu *filterMenu;
QMenu *filterMenuSelect;
QMenu *filterMenuClean;
QMenu *editMenu;
//Render Menu and SubMenu ////
//Render Menu and SubMenu ////
QMenu *shadersMenu;
QMenu *renderMenu;
QMenu *renderModeMenu;

View File

@ -24,6 +24,9 @@
History
$Log$
Revision 1.51 2006/04/12 15:12:18 cignoni
Added Filter classes (cleaning, meshing etc)
Revision 1.50 2006/02/25 13:43:39 ggangemi
Action "None" is now exported from MeshRenderPlugin
@ -295,6 +298,8 @@ void MainWindow::createMenus()
filterMenu = menuBar()->addMenu(tr("Fi&lters"));
filterMenu->addAction(lastFilterAct);
filterMenu->addSeparator();
filterMenuSelect = filterMenu->addMenu(tr("Select"));
filterMenuClean = filterMenu->addMenu(tr("Clean"));
//////////////////// Menu Render //////////////////////////////////////////////////////////////////////////
@ -395,8 +400,23 @@ void MainWindow::loadPlugins()
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(plugin);
if (iFilter)
addToMenu(iFilter->actions(), filterMenu, SLOT(applyFilter()));
{
QAction *filterAction;
foreach(filterAction, iFilter->actions())
{
connect(filterAction,SIGNAL(triggered()),this,SLOT(applyFilter()));
switch(iFilter->getClass(filterAction))
{
case MeshFilterInterface::FilterClass::Selection :
filterMenuSelect->addAction(filterAction); break;
case MeshFilterInterface::FilterClass::Cleaning :
filterMenuClean->addAction(filterAction); break;
case MeshFilterInterface::FilterClass::Generic :
default:
filterMenu->addAction(filterAction); break;
}
}
}
MeshIOInterface *iIO = qobject_cast<MeshIOInterface *>(plugin);
if (iIO)
meshIOPlugins.push_back(iIO);
@ -413,7 +433,7 @@ void MainWindow::loadPlugins()
MeshEditInterface *iEdit = qobject_cast<MeshEditInterface *>(plugin);
if (iEdit)
addToMenu(iEdit->actions(), renderMenu, SLOT(applyEditMode()));
addToMenu(iEdit->actions(), editMenu, SLOT(applyEditMode()));
pluginFileNames += fileName;
}

View File

@ -23,6 +23,9 @@
/****************************************************************************
History
$Log$
Revision 1.33 2006/04/12 15:12:18 cignoni
Added Filter classes (cleaning, meshing etc)
Revision 1.32 2006/03/29 10:44:06 zifnab1974
for gcc 3.4.5
@ -380,7 +383,7 @@ void ExtraMeshDecoratePlugin::drawQuotedLine(const Point3d &a,const Point3d &b,
glVertex(Zero+v*i);
glEnd();
int neededZeros=ceil(max(0.0,-log10(tickDist)));
int neededZeros=ceil(max(0.0f,-log10(tickDist)));
for(i=firstTick;i<bVal;i+=tickDist)
gla->renderText(Zero[0]+i*v[0],Zero[1]+i*v[1],Zero[2]+i*v[2],tr("%1").arg(i,3+neededZeros,'f',neededZeros),gla->getFont());

View File

@ -22,6 +22,9 @@
/****************************************************************************
History
$Log$
Revision 1.59 2006/04/12 15:12:18 cignoni
Added Filter classes (cleaning, meshing etc)
Revision 1.58 2006/02/20 20:52:36 giec
replace refine and detacher dialog whit GnericELDialog
@ -84,19 +87,26 @@ added scale to unit box, move obj center. Rotate around object and origin are no
#include "../../meshlab/LogStream.h"
using namespace vcg;
ExtraMeshFilterPlugin::ExtraMeshFilterPlugin() {
actionList << new QAction(ST(FP_LOOP_SS), this);
actionList << new QAction(ST(FP_BUTTERFLY_SS), this);
actionList << new QAction(ST(FP_MIDPOINT), this);
actionList << new QAction(ST(FP_REMOVE_UNREFERENCED_VERTEX), this);
actionList << new QAction(ST(FP_REMOVE_DUPLICATED_VERTEX), this);
actionList << new QAction(ST(FP_REMOVE_NULL_FACES), this);
actionList << new QAction(ST(FP_LAPLACIAN_SMOOTH), this);
actionList << new QAction(ST(FP_REORIENT), this);
actionList << new QAction(ST(FP_DETACHER), this);
actionList << new QAction(ST(FP_DECIMATOR), this);
actionList << new QAction(ST(FP_INVERT_FACES), this);
actionList << new QAction(ST(FP_TRANSFORM), this);
ExtraMeshFilterPlugin::ExtraMeshFilterPlugin()
{
typeList << FP_LOOP_SS<<
FP_BUTTERFLY_SS<<
FP_REMOVE_UNREFERENCED_VERTEX<<
FP_REMOVE_DUPLICATED_VERTEX<<
FP_REMOVE_NULL_FACES<<
FP_LAPLACIAN_SMOOTH<<
FP_DECIMATOR<<
FP_MIDPOINT<<
FP_REORIENT <<
FP_INVERT_FACES<<
FP_TRANSFORM<<
FP_REMOVE_SMALL_FACES ;
FilterType tt;
foreach(tt , types())
actionList << new QAction(ST(tt), this);
//refineDialog = new RefineDialog();
//refineDialog->hide();
@ -110,35 +120,47 @@ ExtraMeshFilterPlugin::ExtraMeshFilterPlugin() {
transformDialog->hide();
}
const QString ExtraMeshFilterPlugin::ST(FilterType filter) {
const ExtraMeshFilterPlugin::FilterClass ExtraMeshFilterPlugin::getClass(QAction *a)
{
switch(ID(a))
{
case FP_REMOVE_UNREFERENCED_VERTEX :
case FP_REMOVE_DUPLICATED_VERTEX :
case FP_REMOVE_NULL_FACES :
case FP_REMOVE_SMALL_FACES :
return FilterClass::Cleaning;
default : return FilterClass::Generic;
}
}
const ExtraMeshFilterPlugin::FilterType ExtraMeshFilterPlugin::ID(QAction *a)
{
foreach( FilterType tt, types())
if( a->text() == ST(tt) ) return tt;
assert(0);
return FP_LOOP_SS;
}
const QString ExtraMeshFilterPlugin::ST(FilterType filter)
{
switch(filter)
{
case FP_LOOP_SS :
return QString("Loop Subdivision Surfaces");
case FP_BUTTERFLY_SS :
return QString("Butterfly Subdivision Surfaces");
case FP_REMOVE_UNREFERENCED_VERTEX :
return QString("Remove Unreferenced Vertex");
case FP_REMOVE_DUPLICATED_VERTEX :
return QString("Remove Duplicated Vertex");
case FP_REMOVE_NULL_FACES :
return QString("Remove Null Faces");
case FP_LAPLACIAN_SMOOTH :
return QString("Laplacian Smooth");
case FP_DECIMATOR :
return QString("Clustering decimation");
case FP_MIDPOINT :
return QString("Midpoint Subdivision Surfaces");
case FP_REORIENT :
return QString("Re-oriented");
case FP_INVERT_FACES:
return QString("Invert Faces");
case FP_TRANSFORM:
return QString("Apply Transform");
case FP_DETACHER:
return QString("Remove triangle above threshold");
case FP_LOOP_SS : return QString("Loop Subdivision Surfaces");
case FP_BUTTERFLY_SS : return QString("Butterfly Subdivision Surfaces");
case FP_REMOVE_UNREFERENCED_VERTEX : return QString("Remove Unreferenced Vertex");
case FP_REMOVE_DUPLICATED_VERTEX : return QString("Remove Duplicated Vertex");
case FP_REMOVE_NULL_FACES : return QString("Remove Null Faces");
case FP_REMOVE_SMALL_FACES: return QString("Remove faces wrt size");
case FP_LAPLACIAN_SMOOTH : return QString("Laplacian Smooth");
case FP_DECIMATOR : return QString("Clustering decimation");
case FP_MIDPOINT : return QString("Midpoint Subdivision Surfaces");
case FP_REORIENT : return QString("Re-oriented");
case FP_INVERT_FACES: return QString("Invert Faces");
case FP_TRANSFORM: return QString("Apply Transform");
default: assert(0);
}
return QString("error!");
@ -160,82 +182,60 @@ QList<QAction *> ExtraMeshFilterPlugin::actions() const {
return actionList;
}
const ActionInfo &ExtraMeshFilterPlugin::Info(QAction *action)
{
static ActionInfo ai;
if( action->text() == ST(FP_LOOP_SS) )
{
ai.Help = tr("Apply Loop's Subdivision Surface algorithm. It is an approximate method which subdivide each triangle in four faces. It works for every triangle and has rules for extraordinary vertices");
ai.ShortHelp = tr("Apply Loop's Subdivision Surface algorithm");
}
if( action->text() == ST(FP_BUTTERFLY_SS) )
{
ai.Help = tr("Apply Butterfly Subdivision Surface algorithm. It is an interpolated method, defined on arbitrary triangular meshes. The scheme is known to be C1 but not C2 on regular meshes");
switch(ID(action))
{
case FP_LOOP_SS :
ai.Help = tr("Apply Loop's Subdivision Surface algorithm. It is an approximate method which subdivide each triangle in four faces. It works for every triangle and has rules for extraordinary vertices");
ai.ShortHelp = tr("Apply Loop's Subdivision Surface algorithm");
break;
case FP_BUTTERFLY_SS :
ai.Help = tr("Apply Butterfly Subdivision Surface algorithm. It is an interpolated method, defined on arbitrary triangular meshes. The scheme is known to be C1 but not C2 on regular meshes");
ai.ShortHelp = tr("Apply Butterfly Subdivision Surface algorithm");
}
if( action->text() == ST(FP_REMOVE_UNREFERENCED_VERTEX) )
{
break;
case FP_REMOVE_UNREFERENCED_VERTEX :
ai.Help = tr("Check for every vertex on the mesh if it is referenced by a face and removes it");
ai.ShortHelp = tr("Remove Unreferenced Vertexes");
}
if( action->text() == ST(FP_REMOVE_DUPLICATED_VERTEX) )
{
break;
case FP_REMOVE_DUPLICATED_VERTEX :
ai.Help = tr("Check for every vertex on the mesh if there are two vertices with same coordinates and removes it");
ai.ShortHelp = tr("Remove Duplicated Vertexes");
}
if(action->text() == ST(FP_REMOVE_NULL_FACES) )
{
break;
case FP_REMOVE_NULL_FACES :
ai.Help = tr("Removes faces with area equal to zero");
ai.ShortHelp = tr("Remove Null Faces");
}
if(action->text() == ST(FP_LAPLACIAN_SMOOTH) )
{
break;
case FP_LAPLACIAN_SMOOTH :
ai.Help = tr("For each vertex it calculates the average position with nearest vertex");
ai.ShortHelp = tr("Smooth the mesh surface");
}
if(action->text() == ST(FP_DECIMATOR) )
{
break;
case FP_DECIMATOR :
ai.Help = tr("Collapse vertices by creating a three dimensional grid enveloping the mesh and discretizes them based on the cells of this grid");
ai.ShortHelp = tr("Simplify the surface eliminating triangle");
}
if(action->text() == ST(FP_MIDPOINT) )
{
break;
case FP_MIDPOINT :
ai.Help = tr("Splits every edge in two");
ai.ShortHelp = tr("Apply Midpoint's Subdivision Surface algorithm");
}
if(action->text() == ST(FP_REORIENT) )
{
break;
case FP_REORIENT :
ai.Help = tr("Re-oriented the adjacencies of the face of the mesh");
ai.ShortHelp = tr("Re-oriented the face");
}
if(action->text() == ST(FP_INVERT_FACES) )
{
break;
case FP_INVERT_FACES :
ai.Help = tr("Invert faces orentation, flip the normal of the mesh");
ai.ShortHelp = tr("Invert faces orentation");
}
if(action->text() == ST(FP_TRANSFORM) )
{
break;
case FP_TRANSFORM :
ai.Help = tr("Apply transformation, you can rotate, translate or scale the mesh");
ai.ShortHelp = tr("Apply Transform");
}
if(action->text() == ST(FP_DETACHER) )
{
break;
case FP_REMOVE_SMALL_FACES :
ai.Help = tr("Remove from the mesh all triangles whose have an edge with lenght greater or equal than a threshold");
ai.ShortHelp = tr("Remove triangle with edge greater than a threshold");
}
break;
}
return ai;
}
@ -421,7 +421,7 @@ bool ExtraMeshFilterPlugin::applyFilter(QAction *filter, MeshModel &m, QWidget *
vcg::tri::UpdateBounding<CMeshO>::Box(m.cm);
}
if (filter->text() == ST(FP_DETACHER) ) {
if (filter->text() == ST(FP_REMOVE_SMALL_FACES) ) {
float diagonale = m.cm.bbox.Diag();
Histogram<float> *histo= new Histogram<float>();
histo->SetRange( 0, diagonale, 10000);

View File

@ -20,6 +20,9 @@
****************************************************************************/
/* History
$Log$
Revision 1.28 2006/04/12 15:12:18 cignoni
Added Filter classes (cleaning, meshing etc)
Revision 1.27 2006/02/21 15:24:47 mariolatronico
case typo on #include
@ -65,17 +68,29 @@ class ExtraMeshFilterPlugin : public QObject, public MeshFilterInterface
- FP -> Filter Plugin
- name of the plugin separated by _
*/
enum FilterType { FP_LOOP_SS, FP_BUTTERFLY_SS, FP_REMOVE_UNREFERENCED_VERTEX,
FP_REMOVE_DUPLICATED_VERTEX, FP_REMOVE_NULL_FACES,
FP_LAPLACIAN_SMOOTH, FP_DECIMATOR, FP_MIDPOINT, FP_REORIENT ,FP_INVERT_FACES,
FP_TRANSFORM, FP_DETACHER } ;
const QString ST(FilterType filter);
enum FilterType { FP_LOOP_SS,
FP_BUTTERFLY_SS,
FP_REMOVE_UNREFERENCED_VERTEX,
FP_REMOVE_DUPLICATED_VERTEX,
FP_REMOVE_NULL_FACES,
FP_LAPLACIAN_SMOOTH,
FP_DECIMATOR,
FP_MIDPOINT,
FP_REORIENT ,
FP_INVERT_FACES,
FP_TRANSFORM,
FP_REMOVE_SMALL_FACES } ;
const QString ST(FilterType filter);
const FilterType ID(QAction *a);
virtual QList<FilterType> &types() { return typeList;}
ExtraMeshFilterPlugin();
~ExtraMeshFilterPlugin();
virtual const ActionInfo &Info(QAction *);
virtual const PluginInfo &Info();
virtual const FilterClass getClass(QAction *);
virtual QList<QAction *> actions() const;
bool applyFilter(QAction *filter, MeshModel &m, QWidget *parent, vcg::CallBackPos * cb) ;
@ -83,6 +98,8 @@ class ExtraMeshFilterPlugin : public QObject, public MeshFilterInterface
protected:
GLLogStream *log;
QList <QAction *> actionList;
QList <FilterType> typeList;
// RefineDialog *refineDialog;
DecimatorDialog *decimatorDialog;
TransformDialog *transformDialog;