mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-13 16:14:38 +00:00
154 lines
12 KiB
HTML
154 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<title>Meshlab Development</title>
|
|
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
|
|
<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", 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 QObject. This involves you specifying
|
|
the two keywords
|
|
<br>
|
|
<span style="FONT-WEIGHT: bold; FONT-STYLE: italic">Q_OBJECT</span><br>
|
|
<span style="FONT-WEIGHT: bold; FONT-STYLE: italic">Q_INTERFACES(MeshFilterInterface)</span><br>
|
|
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>
|
|
Then you implement the following four pure virtual methods:<br>
|
|
<br>
|
|
<span style="FONT-WEIGHT: bold; FONT-STYLE: italic">virtual const QString ST(FilterType filter);</span>
|
|
// Return a string that explane the filter's behaviour<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">, FilterParameter & </span><span style="FONT-STYLE: italic">/*par*/</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>
|
|
// Discriminate on the filter to apply by the action name. Its parameters are:<br>
|
|
|| * The Filter Action<br>
|
|
|| * The Mesh
|
|
<br>
|
|
|| * The Filter Parameters
|
|
<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>
|
|
<br>
|
|
<p><span style="FONT-WEIGHT: bold">Download:</span><br>
|
|
You can download here a sample code <a href="http://meshlab.sourceforge.net/samplePlugins.zip">
|
|
FilterPlugins.zip</a></p>
|
|
<h2><span style="FONT-STYLE: italic"></span>Example of filter plug-in</h2>
|
|
<p><span style="FONT-STYLE: italic"></span><span style="FONT-WEIGHT: bold; TEXT-DECORATION: underline"> 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">
|
|
<br>
|
|
<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">
|
|
<br>
|
|
<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 QString ST(FilterType filter);</span><br style="FONT-STYLE: italic">
|
|
<span style="FONT-STYLE: italic"> virtual bool applyFilter(QAction *filter, MeshModel &m, FilterParameter &par, vcg::CallBackPos * cb);</span><br style="FONT-STYLE: italic">
|
|
<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">QString ExampleMeshFilterPlugin::ST(FilterType filter) <br>
|
|
{</span><br style="FONT-STYLE: italic">
|
|
<span style="FONT-STYLE: italic"> switch(filter){</span><br style="FONT-STYLE: italic">
|
|
<br>
|
|
<span style="FONT-STYLE: italic"> case "TYPE": return QString("...");</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"> return QString("error");</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, FilterParameter &par, 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">
|
|
<br>
|
|
<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>
|