To create a new MeshIO plug-in the first step is to considerate that you must implement the "MeshIOInterface", you can find it in "meshlab/interfaces.h".
Then you create a new class filter which
must inherit from the interface and from QObject. This involves you specifying
the two keywords
Q_OBJECT
Q_INTERFACES(MeshIOInterface)
before the method declaration to permit the moc'ing phases.
It is essential to import of the mesh definition found in "meshlab/meshmodel.h".
Then you implement the following pure virtual methods:
virtual QList
virtual QList
virtual const ActionInfo &Info(QAction *);
virtual const PluginInfo &Info();
virtual int GetExportMaskCapability(QString &format) const;//Returns
the mask on the basis of the file's type
virtual bool open(const QString &formatName,QString &fileName, MeshModel &m, int& mask, vcg::CallBackPos *cb=0, QWidget *parent=0);
//For open a mesh
virtual bool save(const QString &formatName,QString &fileName, MeshModel &m, const int &mask, vcg::CallBackPos *cb, QWidget *parent);
//For save a mesh
Download:
You can download here a sample code
MeshIOPlugins.zip
smfio.h
#ifndef EXAMPLEPLUGIN_H
#define EXAMPLEPLUGIN_H
#include <QObject>
#include <QStringList>
#include <QString>
class smfIOPlugin : public QObject, public MeshIOInterface
{
Q_OBJECT
Q_INTERFACES(MeshIOInterface)
public:
smfIOPlugin();
virtual QList
virtual QList
virtual const ActionInfo &Info(QAction *);
virtual const PluginInfo &Info();
virtual int GetExportMaskCapability(QString &format) const;
virtual bool open(const QString &formatName, QString &fileName, MeshModel &m, int& mask, vcg::CallBackPos *cb=0, QWidget *parent=0);
virtual bool save(const QString &formatName,QString &fileName, MeshModel &m, const int &mask, vcg::CallBackPos *cb, QWidget *parent);
};
#endif
smfio.cpp
#include <Qt>
#include <QtGui>
#include "smfio.h"
#include <vcg/wrap/io_trimesh/import_smf.h>
#include <vcg/wrap/io_trimesh/export_smf.h>
using namespace vcg;
bool
smfIOPlugin::open(const QString &formatName, QString &fileName, MeshModel &m, int& mask, CallBackPos *cb, QWidget *parent)
{
if (fileName.isEmpty())
return false;
...
int result =
vcg::tri::io::ImporterSMF
...
return true;
}
bool
smfIOPlugin::save(const QString &formatName, QString &fileName, MeshModel &m, int& mask, CallBackPos *cb, QWidget *parent)
{
...
int result =
vcg::tri::io::ExporterSMF
...
return true;
}
QList
{
QList
formatList << Format("Simple Model Format" ,tr("SMF"));
return formatList;
}
QList
{
QList
formatList << Format("Simple Model Format" ,tr("SMF"));
return formatList;
}
const ActionInfo &smfIOPlugin::Info(QAction *action)
{
static ActionInfo ai;
return ai;
}
const PluginInfo &smfIOPlugin::Info()
{
static PluginInfo ai;
ai.Date=tr("__DATE__");
ai.Version = tr("Current version");
ai.Author = ("Yuor name");
return ai;
}
int smfIOPlugin::GetExportMaskCapability(QString &format) const
{
return 0;
}
Q_EXPORT_PLUGIN(smfIOPlugin)