better organization io_base

This commit is contained in:
alemuntoni 2021-06-03 18:53:53 +02:00
parent 28234c05c9
commit 7d05349409
6 changed files with 100 additions and 90 deletions

View File

@ -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

View File

@ -22,9 +22,9 @@
****************************************************************************/
#include "baseio.h"
#include "load_project.h"
#include <QTextStream>
#include <QDir>
#include <wrap/io_trimesh/import_ply.h>
#include <wrap/io_trimesh/import_stl.h>
@ -44,12 +44,6 @@
#include <wrap/io_trimesh/export_gts.h>
#include <wrap/io_trimesh/export.h>
#include <wrap/io_trimesh/alnParser.h>
#include <common/utilities/load_save.h>
#include <common/ml_document/mesh_document.h>
#include <common/meshlabdocumentbundler.h>
using namespace std;
using namespace vcg;
@ -668,70 +662,4 @@ void BaseMeshIOPlugin::initSaveParameter(const QString &format, const MeshModel
}
}
std::list<MeshModel*> BaseMeshIOPlugin::loadALN(
const QString& filename,
MeshDocument& md,
CallBackPos* cb)
{
std::list<MeshModel*> meshList;
std::vector<RangeMap> 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<MeshModel*> 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<MeshModel*> BaseMeshIOPlugin::loadOUT(
const QString& filename,
const QString& imageListFile,
MeshDocument& md,
CallBackPos*)
{
std::list<MeshModel*> 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<MeshModel*> BaseMeshIOPlugin::loadNVM(
const QString& filename,
MeshDocument& md,
CallBackPos*)
{
std::list<MeshModel*> 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)

View File

@ -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<MeshModel*> loadALN(
const QString& filename,
MeshDocument& md,
vcg::CallBackPos* cb);
std::list<MeshModel*> loadOUT(
const QString& filename,
const QString& imageListFile,
MeshDocument& md,
vcg::CallBackPos* cb);
std::list<MeshModel*> loadNVM(
const QString& filename,
MeshDocument& md,
vcg::CallBackPos* cb);
};
#endif

View File

@ -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 \

View File

@ -0,0 +1,73 @@
#include "load_project.h"
#include <QDir>
#include <wrap/io_trimesh/alnParser.h>
#include <common/ml_document/mesh_document.h>
#include <common/utilities/load_save.h>
#include <common/meshlabdocumentbundler.h>
std::list<MeshModel*> loadALN(
const QString& filename,
MeshDocument& md,
vcg::CallBackPos* cb)
{
std::list<MeshModel*> meshList;
std::vector<RangeMap> 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<MeshModel*> 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<MeshModel*> loadOUT(
const QString& filename,
const QString& imageListFile,
MeshDocument& md,
vcg::CallBackPos*)
{
std::list<MeshModel*> 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<MeshModel*> loadNVM(
const QString& filename,
MeshDocument& md,
vcg::CallBackPos*)
{
std::list<MeshModel*> meshList;
QFileInfo fi(filename);
//todo: move here this function...
if(!MeshDocumentFromNvm(md, filename, fi.baseName())){
throw MLException("Unable to open NVMs file");
}
return meshList;
}

View File

@ -0,0 +1,22 @@
#ifndef LOAD_PROJECT_H
#define LOAD_PROJECT_H
#include <common/ml_document/mesh_model.h>
std::list<MeshModel*> loadALN(
const QString& filename,
MeshDocument& md,
vcg::CallBackPos* cb);
std::list<MeshModel*> loadOUT(
const QString& filename,
const QString& imageListFile,
MeshDocument& md,
vcg::CallBackPos* cb);
std::list<MeshModel*> loadNVM(
const QString& filename,
MeshDocument& md,
vcg::CallBackPos* cb);
#endif // LOAD_PROJECT_H