diff --git a/src/meshlabplugins/io_base/CMakeLists.txt b/src/meshlabplugins/io_base/CMakeLists.txt index fffd82a7d..c8a9a86af 100644 --- a/src/meshlabplugins/io_base/CMakeLists.txt +++ b/src/meshlabplugins/io_base/CMakeLists.txt @@ -4,12 +4,14 @@ set(SOURCES baseio.cpp + load_project.cpp ${VCGDIR}/wrap/openfbx/src/miniz.c ${VCGDIR}/wrap/openfbx/src/ofbx.cpp ${VCGDIR}/wrap/ply/plylib.cpp) set(HEADERS baseio.h + load_project.h ${VCGDIR}/wrap/io_trimesh/export_obj.h ${VCGDIR}/wrap/io_trimesh/export_off.h ${VCGDIR}/wrap/io_trimesh/export_ply.h diff --git a/src/meshlabplugins/io_base/baseio.cpp b/src/meshlabplugins/io_base/baseio.cpp index 26657a0da..2748c9eba 100644 --- a/src/meshlabplugins/io_base/baseio.cpp +++ b/src/meshlabplugins/io_base/baseio.cpp @@ -22,9 +22,9 @@ ****************************************************************************/ #include "baseio.h" +#include "load_project.h" #include -#include #include #include @@ -44,12 +44,6 @@ #include #include -#include - -#include -#include -#include - using namespace std; using namespace vcg; @@ -668,70 +662,4 @@ void BaseMeshIOPlugin::initSaveParameter(const QString &format, const MeshModel } } -std::list BaseMeshIOPlugin::loadALN( - const QString& filename, - MeshDocument& md, - CallBackPos* cb) -{ - std::list meshList; - std::vector rmv; - int retVal = ALNParser::ParseALN(rmv, qUtf8Printable(filename)); - if(retVal != ALNParser::NoError) { - throw MLException("Unable to open ALN file"); - } - QFileInfo fi(filename); - - for(const RangeMap& rm : rmv) { - QString relativeToProj = fi.absoluteDir().absolutePath() + "/" + rm.filename.c_str(); - try { - std::list tmp = - meshlab::loadMeshWithStandardParameters(relativeToProj, md, cb); - md.mm()->cm.Tr.Import(rm.transformation); - meshList.insert(meshList.end(), tmp.begin(), tmp.end()); - } - catch (const MLException& e){ - for (MeshModel* m : meshList) - md.delMesh(m); - throw e; - } - } - return meshList; -} - -std::list BaseMeshIOPlugin::loadOUT( - const QString& filename, - const QString& imageListFile, - MeshDocument& md, - CallBackPos*) -{ - std::list meshList; - - QString model_filename; - QFileInfo fi(filename); - - //todo: move here this function... - if(!MeshDocumentFromBundler(md, filename, imageListFile, fi.baseName())){ - throw MLException("Unable to open OUTs file"); - } - - return meshList; -} - -std::list BaseMeshIOPlugin::loadNVM( - const QString& filename, - MeshDocument& md, - CallBackPos*) -{ - std::list meshList; - - QString model_filename; - QFileInfo fi(filename); - - if(!MeshDocumentFromNvm(md, filename, model_filename)){ - throw MLException("Unable to open NVMs file"); - } - - return meshList; -} - MESHLAB_PLUGIN_NAME_EXPORTER(BaseMeshIOPlugin) diff --git a/src/meshlabplugins/io_base/baseio.h b/src/meshlabplugins/io_base/baseio.h index aaf8ceb7f..312f68c5e 100644 --- a/src/meshlabplugins/io_base/baseio.h +++ b/src/meshlabplugins/io_base/baseio.h @@ -90,23 +90,6 @@ public: void initPreOpenParameter(const QString &formatName, RichParameterList &parlst); void initSaveParameter(const QString &format, const MeshModel &/*m*/, RichParameterList & par); - -private: - std::list loadALN( - const QString& filename, - MeshDocument& md, - vcg::CallBackPos* cb); - - std::list loadOUT( - const QString& filename, - const QString& imageListFile, - MeshDocument& md, - vcg::CallBackPos* cb); - - std::list loadNVM( - const QString& filename, - MeshDocument& md, - vcg::CallBackPos* cb); }; #endif diff --git a/src/meshlabplugins/io_base/io_base.pro b/src/meshlabplugins/io_base/io_base.pro index 3649f4c2d..a99a0ef1e 100644 --- a/src/meshlabplugins/io_base/io_base.pro +++ b/src/meshlabplugins/io_base/io_base.pro @@ -2,6 +2,7 @@ include (../../shared.pri) HEADERS += \ baseio.h \ + load_project.h \ $$VCGDIR/wrap/io_trimesh/import_ply.h \ $$VCGDIR/wrap/io_trimesh/import_obj.h \ $$VCGDIR/wrap/io_trimesh/import_off.h \ @@ -16,6 +17,7 @@ HEADERS += \ SOURCES += \ baseio.cpp \ + load_project.cpp \ $$VCGDIR/wrap/ply/plylib.cpp \ $$VCGDIR/wrap/openfbx/src/ofbx.cpp \ $$VCGDIR/wrap/openfbx/src/miniz.c \ diff --git a/src/meshlabplugins/io_base/load_project.cpp b/src/meshlabplugins/io_base/load_project.cpp new file mode 100644 index 000000000..683aade59 --- /dev/null +++ b/src/meshlabplugins/io_base/load_project.cpp @@ -0,0 +1,73 @@ +#include "load_project.h" + +#include + +#include +#include +#include +#include + +std::list loadALN( + const QString& filename, + MeshDocument& md, + vcg::CallBackPos* cb) +{ + std::list meshList; + std::vector rmv; + int retVal = ALNParser::ParseALN(rmv, qUtf8Printable(filename)); + if(retVal != ALNParser::NoError) { + throw MLException("Unable to open ALN file"); + } + QFileInfo fi(filename); + + for(const RangeMap& rm : rmv) { + QString relativeToProj = fi.absoluteDir().absolutePath() + "/" + rm.filename.c_str(); + try { + std::list tmp = + meshlab::loadMeshWithStandardParameters(relativeToProj, md, cb); + md.mm()->cm.Tr.Import(rm.transformation); + meshList.insert(meshList.end(), tmp.begin(), tmp.end()); + } + catch (const MLException& e){ + for (MeshModel* m : meshList) + md.delMesh(m); + throw e; + } + } + return meshList; +} + +std::list loadOUT( + const QString& filename, + const QString& imageListFile, + MeshDocument& md, + vcg::CallBackPos*) +{ + std::list meshList; + + QFileInfo fi(filename); + + //todo: move here this function... + if(!MeshDocumentFromBundler(md, filename, imageListFile, fi.baseName())){ + throw MLException("Unable to open OUTs file"); + } + + return meshList; +} + +std::list loadNVM( + const QString& filename, + MeshDocument& md, + vcg::CallBackPos*) +{ + std::list meshList; + + QFileInfo fi(filename); + + //todo: move here this function... + if(!MeshDocumentFromNvm(md, filename, fi.baseName())){ + throw MLException("Unable to open NVMs file"); + } + + return meshList; +} diff --git a/src/meshlabplugins/io_base/load_project.h b/src/meshlabplugins/io_base/load_project.h new file mode 100644 index 000000000..a812aa6a5 --- /dev/null +++ b/src/meshlabplugins/io_base/load_project.h @@ -0,0 +1,22 @@ +#ifndef LOAD_PROJECT_H +#define LOAD_PROJECT_H + +#include + +std::list loadALN( + const QString& filename, + MeshDocument& md, + vcg::CallBackPos* cb); + +std::list loadOUT( + const QString& filename, + const QString& imageListFile, + MeshDocument& md, + vcg::CallBackPos* cb); + +std::list loadNVM( + const QString& filename, + MeshDocument& md, + vcg::CallBackPos* cb); + +#endif // LOAD_PROJECT_H