mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-13 08:09:39 +00:00
192 lines
11 KiB
HTML
192 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
|
|
|
|
|
|
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
|
|
|
|
|
|
|
|
|
|
|
|
<title>Meshlab Development</title>
|
|
<meta name="author" content="Paolo Cignoni">
|
|
|
|
|
|
|
|
<meta name="keywords" content="mesh 3d processing meshlab scanning">
|
|
|
|
|
|
|
|
<meta name="description" content="Course Web page">
|
|
|
|
|
|
|
|
<meta name="robots" content="all">
|
|
|
|
|
|
|
|
<link media="all" rel="stylesheet" href="style.css" type="text/css">
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<div id="leftcontent">
|
|
<h1>MeshLab:
|
|
Development page : Create a Filter-plugin</h1>
|
|
|
|
|
|
<br>
|
|
|
|
|
|
<h2><span style="font-weight: bold;">How to</span></h2>
|
|
|
|
<p>
|
|
To create a new filter plug-in the first step is to considerate that you
|
|
must implement the "MeshFilterInterface" interface; you can find it in<span style="font-style: italic;"> "meshlab/interfaces.h".</span></p>
|
|
|
|
|
|
<p><span style="font-style: italic;"></span>Then you create a new class
|
|
filter which must inherit from the interface and from Object. This
|
|
involves you specifying the two keywords "<span style="font-style: italic; font-weight: bold;">Q_OBJECT</span>" and "<span style="font-style: italic; font-weight: bold;">Q_INTERFACES(MeshFilterInterface)</span>" before the method declaration to permit the moc'ing phases.</p>
|
|
<p>It is essential to import of the mesh definition found in "meshlab/meshmodel.h".<br>
|
|
<br>
|
|
The new filter plug-in class must have an action container like "<span style="text-decoration: underline;">QList <QAction *></span>", where you can store all the actions you implement in your class; <span style="font-style: italic;">QList <QAction*></span> must be populated in the constructor.<br>
|
|
<br>
|
|
Then you implement the following four pure virtual methods:<br>
|
|
<br>
|
|
<span style="font-weight: bold; font-style: italic;">QList<QAction *> actions()</span> // return the list of actions to create the menu on the toolbar<br>
|
|
<span style="font-weight: bold; font-style: italic;">virtual const ActionInfo &Info(QAction *)</span>//?<br>
|
|
<span style="font-weight: bold; font-style: italic;">virtual const PluginInfo &Info()</span>//?<br>
|
|
<span style="font-weight: bold; font-style: italic;">virtual bool applyFilter(QAction * </span><span style="font-style: italic;">/*filter*/</span><span style="font-weight: bold; font-style: italic;">, MeshModel & </span><span style="font-style: italic;">/*m*/</span><span style="font-weight: bold; font-style: italic;">, QWidget * </span><span style="font-style: italic;">/*parent*/</span><span style="font-weight: bold; font-style: italic;">, vcg::CallBackPos* </span><span style="font-style: italic;">/*cb*/</span><span style="font-weight: bold; font-style: italic;">)</span><br>
|
|
// Discriminate on the filter to apply by the action name. Its parameters are:<br>
|
|
|| * The filter action<br>
|
|
|| * The Mesh <br>
|
|
|| * The QWidget parent to possibly create the dialog to set some variables<br>
|
|
|| * The call-back function to update the progress-bar<br>
|
|
<br style="font-weight: bold;">
|
|
<span style="font-weight: bold;">Important:</span><br>
|
|
Before performing a filter function call it is good practice to check
|
|
that the characteristics of the mesh (topology, normal, texture and so
|
|
on) are up to date; otherwise you should call the specific method.</p>
|
|
|
|
<h2><span style="font-style: italic;"></span>Example</h2>
|
|
|
|
<p><span style="font-style: italic;"></span><span style="text-decoration: underline; font-weight: bold;"> Example.h</span></p>
|
|
<p><span style="font-style: italic;">#ifndef EXAMPLEPLUGIN_H</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">#define EXAMPLEPLUGIN_H</span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">#include <QObject></span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">#include <QStringList></span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">#include <QList></span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">class ExampleMeshFilterPlugin : public QObject, public MeshFilterInterface</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">{</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> Q_OBJECT</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> Q_INTERFACES(MeshFilterInterface)</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> </span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">public:</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> ExampleMeshFilterPlugin();</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> virtual const ActionInfo &Info(QAction *);</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> virtual const PluginInfo &Info();</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> virtual QList<QAction *> actions() const;</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> bool applyFilter(QAction *filter, MeshModel &m, QWidget *parent, vcg::CallBackPos * cb) ;</span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">protected:</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> QList <QAction *> actionList;</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">};</span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">#endif</span><br>
|
|
</p>
|
|
<p><br>
|
|
<br>
|
|
<span style="font-weight: bold; text-decoration: underline;">Example.cpp</span><br>
|
|
<br>
|
|
<span style="font-style: italic;">#include <QtGui></span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">#include <stdlib.h></span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">#include "meshfilter.h"</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">#include <vcg/complex/trimesh/clean.h></span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">#include <vcg/complex/trimesh/smooth.h></span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">ExampleMeshFilterPlugin::ExampleMeshFilterPlugin() <br>
|
|
{</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> actionList << new QAction("ExampleFilter", this);</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">}</span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">QList<QAction *> ExampleMeshFilterPlugin::actions() const <br>
|
|
{</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> return actionList;</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">}</span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">const ActionInfo &ExampleMeshFilterPlugin::Info(QAction *action) </span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">{</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> ActionInfo ai; </span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> </span><span style="font-style: italic;"> if( action->text() == tr("ExampleFilter") )</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> {</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> ai.Help = tr("explain yuor method");</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> ai.ShortHelp = tr("For tooltip");</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> }</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> return ai;</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> }</span><br style="font-style: italic;">
|
|
<br style="font-style: italic;">
|
|
<span style="font-style: italic;">const PluginInfo &ExampleMeshFilterPlugin::Info() </span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">{</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> static PluginInfo ai; </span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> ai.Date=tr("__DATE__");</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> ai.Version = tr("Current version");</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> ai.Author = ("Yuor name");</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> return ai;</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> }</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> </span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">bool ExampleMeshFilterPlugin::applyFilter(QAction *filter, MeshModel &m, QWidget *parent, vcg::CallBackPos *cb) </span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">{</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> if(filter->text() == tr("ExampleFilter") )</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> {</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> //call my filter method</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> }</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;"> return true;</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">}</span><br style="font-style: italic;">
|
|
<span style="font-style: italic;">Q_EXPORT_PLUGIN(ExampleMeshFilterPlugin)</span><br>
|
|
<br>
|
|
</p>
|
|
<br>
|
|
<span style="font-style: italic;">
|
|
<dl>
|
|
|
|
|
|
</dl>
|
|
|
|
|
|
</span></div>
|
|
|
|
|
|
<div id="rightcontent">
|
|
<br>
|
|
|
|
<a href="https://sourceforge.net/projects/meshlab/"><span style="font-style: italic;"></span><img src="http://sourceforge.net/sflogo.php?group_id=149444&type=2" alt="SourceForge.net Logo" border="0" height="37" width="125"></a>
|
|
<p class="menu"><a href="http://meshlab.sourceforge.net">Main
|
|
Page </a></p>
|
|
|
|
|
|
<p class="menu"><a href="https://sourceforge.net/project/showfiles.php?group_id=149444">Download</a></p>
|
|
|
|
|
|
<p class="menu"><a href="http://cvs.sourceforge.net/viewcvs.py/meshlab/">CVS</a></p>
|
|
|
|
|
|
<p class="menu"><a href="https://sourceforge.net/pm/?group_id=149444">TASK</a></p>
|
|
|
|
|
|
<p class="menu"><a href="https://sourceforge.net/projects/meshlab/">SF project
|
|
page</a></p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
|
</html>
|