Meshlab中IO插件编写_使用自已添加的external支持库
2012-11-03 19:54
330 查看
一、使用在external中自定义添加的第三方库,如何添加请参考:
/article/9183458.html
对于第三方库的使用,无非就是向当前的工程中添加包含目录,和库目录。在meshlab_mini.pro总工程下创建工程io_json.pro,并保存在src/my_plugins/io_json目录下,并对io_json.pro设置如下:
二、 Meshlab中IO插件的编写
编写IO插件,也是非常简单的,Meshlab提供了MeshIOInterface接口,只要实现该接口的open,save方法便可以了。下面就将三维模型的json格式的读写插件进行介绍,以及jsoncpp的使用。
MeshIOInterface提供的几个方法介绍如下,也就是需要重写的方法:
下面给出JsonIOPlugin.cpp的代码,该IO插件,只支持JSON文件类型的读写,export_json.h和import_json.h见完整的工程,下载链接已给出。在这里只重写了几个必不可少的函数:
如此就完成了Meshlab的IO插件的编写,很简单呀。
完整的IOPlugin工程代码在:http://download.csdn.net/detail/fightingbull/4728854
辉辉
(FightingBull Studio)
欢迎转载,但请注明出处:http://blog.csdn.net/fightingbull
/article/9183458.html
对于第三方库的使用,无非就是向当前的工程中添加包含目录,和库目录。在meshlab_mini.pro总工程下创建工程io_json.pro,并保存在src/my_plugins/io_json目录下,并对io_json.pro设置如下:
include(../../shared.pri) TARGET=io_json #thirdpartylibs INCLUDEPATH+=../../external/jsoncpp-0.6.0-rc2/include macx:LIBS +=-L../../external/lib/macx-ljson macx32:LIBS +=-L../../external/lib/macx32-ljson macx64:LIBS +=-L../../external/lib/macx64-ljson win32-msvc.net:LIBS +=../../external/lib/win32-msvc.net/json.lib win32-msvc2005:LIBS +=../../external/lib/win32-msvc2005/json.lib win32-msvc2008:LIBS +=../../external/lib/win32-msvc2008/json.lib win32-g++:LIBS +=-L../../external/lib/win32-gcc-ljson linux-g++:LIBS +=-L../../external/lib/linux-g++-ljson linux-g++-32:LIBS +=-L../../external/lib/linux-g++-32-ljson linux-g++-64:LIBS +=-L../../external/lib/linux-g++-64-ljson
二、 Meshlab中IO插件的编写
编写IO插件,也是非常简单的,Meshlab提供了MeshIOInterface接口,只要实现该接口的open,save方法便可以了。下面就将三维模型的json格式的读写插件进行介绍,以及jsoncpp的使用。
MeshIOInterface提供的几个方法介绍如下,也就是需要重写的方法:
virtualQList<Format>importFormats()const=0; //该方法用来定义可以导入的类型,如*.json virtualQList<Format>exportFormats()const=0; //该方法定义可以导出的类型,如*.json virtualvoidinitPreOpenParameter(constQString&/*format*/,constQString&/*fileName*/,RichParameterSet&/*par*/){} //该方法用来定义在打开文件(open)之前所需要的信息,比如,是否导入normal virtualvoidinitOpenParameter(constQString&/*format*/,MeshModel&/*m*/,RichParameterSet&/*par*/){} // 该方法定义文件调入内存(open)后,所需要的处理,比如,是否对normal进行平滑处理 //Thisisthecorrespondingfunctionthatiscalledafterthemeshisloadedwiththeinitializedparameters virtualvoidapplyOpenParameter(constQString&/*format*/,MeshModel&/*m*/,constRichParameterSet&/*par*/){} //该方法执行initOpenParameter所定义的处理 virtualvoidinitSaveParameter(constQString&/*format*/,MeshModel&/*m*/,RichParameterSet&/*par*/) {}// 该方法在save之前调用,用来定义保存设置 virtualvoidGetExportMaskCapability(QString&format,int&capability,int&defaultBits)const=0; //该方法用来确定某文件类型,所能保存的模型的信息,比如json文件类型,是否具有保存normal的能力 ///callbackusedtoactuallyloadameshfromafile virtualboolopen( constQString&format, ///theextensionoftheformate.g."PLY" constQString&fileName, ///Thenameofthefiletobeopened MeshModel&m, ///Themeshthatisfilledwiththefilecontent int&mask, ///abitmaskthatwillbefilledreportingwhatkindofdatawehavefoundinthefile(pervertexcolor,texturecoordsetc) constRichParameterSet&par,///TheparametersthathavebeensetupintheinitPreOpenParameter() vcg::CallBackPos*cb=0, ///standardcallbackforreportingprogressintheloading QWidget*parent=0)=0; ///youshouldnotusethis... virtualboolsave( constQString&format,//theextensionoftheformate.g."PLY" constQString&fileName, MeshModel&m, constintmask, //abitmaskindicatingwhatkindofthedatapresentinthemeshshouldbesaved(e.g.youcouldnotwanttosavenormalsinplyfiles) constRichParameterSet&par, vcg::CallBackPos*cb=0, QWidget*parent=0)=0;
下面给出JsonIOPlugin.cpp的代码,该IO插件,只支持JSON文件类型的读写,export_json.h和import_json.h见完整的工程,下载链接已给出。在这里只重写了几个必不可少的函数:
#include"jsonioplugin.h" #include"export_json.h" #include"import_json.h" JsonIOPlugin::JsonIOPlugin(QObject*parent) : QObject(parent),MeshIOInterface() { } QList<MeshIOInterface::Format>JsonIOPlugin::exportFormats()const{ QList<Format> formatList; formatList <<Format("JavaScriptJSON",tr("JSON")); return formatList; } QList<MeshIOInterface::Format>JsonIOPlugin::importFormats()const{ QList<Format> formatList; formatList << Format("JavaScriptJSON",tr("JSON")); return formatList; } boolJsonIOPlugin::open(const QString &format, const QString &fileName,MeshModel &m, int &mask, const RichParameterSet &par,vcg::CallBackPos *cb, QWidget *parent){ QString errorMsgFormat = "Errorencountered while importing file %1:\n%2"; ImporterJSON<CMeshO>::open(m.cm,fileName.toStdString().c_str()); return true; } boolJsonIOPlugin::save(const QString &format, const QString &fileName,MeshModel &m, const int mask, const RichParameterSet &par,vcg::CallBackPos *cb, QWidget *parent){ QString errorMsgFormat = "Errorencountered while exporting file %1:\n%2"; std::string fName =QFile::encodeName(fileName).constData(); //QMessageBox::warning(parent,tr("SavingError"),errorMsgFormat.arg(fileName,tr("failed."))); if(format.toUpper() ==tr("JSON")){ bool success =ExporterJSON<CMeshO>::Save(m.cm,fName.c_str(),mask,cb); if(!success){ QMessageBox::warning(parent,tr("SavingError"),errorMsgFormat.arg(fileName,tr("failed."))); return false; } return true; } } voidJsonIOPlugin::GetExportMaskCapability(QString &format, int &capability,int &defaultBits) const{ capability = 0; if(format.toUpper() ==tr("JSON")){ capability = defaultBits =ExporterJSON<CMeshO>::GetExportMaskCapability(); } } Q_EXPORT_PLUGIN(JsonIOPlugin)
如此就完成了Meshlab的IO插件的编写,很简单呀。
完整的IOPlugin工程代码在:http://download.csdn.net/detail/fightingbull/4728854
辉辉
(FightingBull Studio)
欢迎转载,但请注明出处:http://blog.csdn.net/fightingbull
相关文章推荐
- 给JFinal添加Shiro插件功能,支持Shiro所有注解-使用篇
- Meshlab中添加external支持库
- MyEclipse项目,使用自带Git插件,添加Git支持(SSH方式)
- 手动使用C/C++编写Lua扩展插件
- MyEclipse6.0中使用aptana插件,添加jquery提示功能
- 关于使用plugman添加自定义插件过程中遇到的坑
- 如果maven中使用markdown生成xml需要添加插件
- Qt编写自定义控件及插件的使用
- 在Node.js和Express框架上添加socket.io支持
- 在使用Fragstats4.1软件,添加ESRI Grid图层时出现错误:Error: Grid IO dll is not loaded。
- FireFox插件和扩展开发(二)——编写和使用XPCOM组件
- LaTex使用技巧2:添加中文支持
- 如何编写一个使用Store更新复选框的CheckboxGroup的插件
- 基于jquery的上传插件Uploadify 3.1.1在MVC3中的使用:上传大文件的IO Error问题
- 使用QEMU模拟搭建ARM开发平台(三)——添加SCSI和MTD以及NAND flash支持
- 使用mybatis-generator添加自定义分页插件时提示无法实例化插件类
- Vim安装、配置和插件的添加使用(可以以目录的形式打开)
- javax.imageio.IIOException: Can't create cache file!(使用uploadfile插件上传文件)
- 使用NPAPI编写浏览器插件的调用本机上的程序
- 4.添加对efcore的支持 ,并使用mysql数据库。