MeshLab中Filters菜单下插件的编写

在MeshLab中对其功能的扩展是通过插件来实现的,通过实现不同的接口,可以将插件放在不同的菜单下或工具栏上,在这里只介绍Filter菜单下的插件实现,其他的类似。

 

    1. 首先在meshlab/src目录下创建myplugins文件夹,然后用QCreator打开meshlab_mini.pro。创建一个新的子工程叫helloplugin,选择空Qt项目即可,并保存在myplugins文件下,如图1所示。


图1 创建的helloplugin空项目

2.MeshLab提供了一个公用的shared.pri,里面包含了通用的插件编译配置,只需在helloplugin.pro包含该文件即完成了插件编译的基本配置。在helloplugin.pro中包含该文件:include (../../shared.pri)然后在该工程下创建一个HelloPlugin类,继承自QObject,如图2所示。


图2 创建HelloPlugin类

3.MeshLab提供了MeshFilterInterface接口,用于实现Filter菜单下的插件,因此需要实现该接口。

//helloplugin.h
#ifndef HELLOPLUGIN_H
#define HELLOPLUGIN_H

#include <QObject>
#include <common/interfaces.h>
class HelloPlugin : public QObject, public MeshFilterInterface
{
    Q_OBJECT
    Q_INTERFACES(MeshFilterInterface) //指名MeshFilterInterface为接口
public:
    explicit HelloPlugin(QObject *parent = 0);
    //……

};

#endif // HELLOPLUGIN_H


//helloplugin.cpp
#include "helloplugin.h"

HelloPlugin::HelloPlugin(QObject *parent) :
    QObject(parent)
{
}

Q_EXPORT_PLUGIN(HelloPlugin) //导出插件

4.接下来逐步完成Filter菜单下的插件,是通过实现MeshFilterInterface接口中的功能来完成。下面介绍下几个核心函数和成员变量:

/**
  \brief The MeshFilterInterface class provide the interface of the filter plugins.

*/
class MeshFilterInterface : public MeshCommonInterface
{
public:
  /** The FilterClass enum represents the set of keywords that must be used to categorize a filter.
   Each filter can belong to one or more filtering class, or-ed togheter.
  */
	enum FilterClass 
	{ 
        Generic          =0x00000, /*!< Should be avoided if possible. */  //
        Selection        =0x00001, /*!<  select or de-select something, basic operation on selections (like deleting)*/
        Cleaning         =0x00002, /*!<  Filters that can be used to clean meshes (duplicated vertices etc)*/
        Remeshing        =0x00004, /*!<  Simplification, Refinement, Reconstruction and mesh optimization*/
        FaceColoring     =0x00008,
        VertexColoring   =0x00010,
        MeshCreation     =0x00020,
        Smoothing        =0x00040, /*!<  Stuff that does not change the topology, but just the vertex positions*/
        Quality          =0x00080,
        Layer            =0x00100, /*!<  Layers, attributes */
        RasterLayer      =0x20000, /*!<  Raster Layers, attributes */
        Normal           =0x00200, /*!<  N
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值