mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-13 08:09:39 +00:00
new open for loading multiple layers
This commit is contained in:
parent
96937a827c
commit
44530b23ca
@ -100,6 +100,7 @@ set(SOURCES
|
||||
plugins/interfaces/meshlab_plugin_logger.cpp
|
||||
plugins/interfaces/decorate_plugin.cpp
|
||||
plugins/interfaces/filter_plugin.cpp
|
||||
plugins/interfaces/io_plugin.cpp
|
||||
plugins/meshlab_plugin_type.cpp
|
||||
plugins/plugin_manager.cpp
|
||||
ml_document/helpers/mesh_document_state_data.cpp
|
||||
|
||||
@ -91,6 +91,7 @@ SOURCES += \
|
||||
plugins/interfaces/meshlab_plugin_logger.cpp \
|
||||
plugins/interfaces/decorate_plugin.cpp \
|
||||
plugins/interfaces/filter_plugin.cpp \
|
||||
plugins/interfaces/io_plugin.cpp \
|
||||
plugins/meshlab_plugin_type.cpp \
|
||||
plugins/plugin_manager.cpp \
|
||||
ml_document/helpers/mesh_document_state_data.cpp \
|
||||
|
||||
48
src/common/plugins/interfaces/io_plugin.cpp
Normal file
48
src/common/plugins/interfaces/io_plugin.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "io_plugin.h"
|
||||
#include "../../ml_document/mesh_document.h"
|
||||
|
||||
void IOPlugin::open(
|
||||
const QString& format,
|
||||
const QString& fileName,
|
||||
MeshDocument& md,
|
||||
std::list<MeshModel*>& meshModelList,
|
||||
std::list<int>& maskList,
|
||||
const RichParameterList& par,
|
||||
vcg::CallBackPos* cb)
|
||||
{
|
||||
QFileInfo info(fileName);
|
||||
MeshModel *mm = md.addNewMesh(fileName, info.fileName());
|
||||
meshModelList.push_back(mm);
|
||||
int mask;
|
||||
try {
|
||||
open(format, fileName, *mm, mask, par, cb);
|
||||
maskList.push_back(mask);
|
||||
}
|
||||
catch(const MLException& exc){
|
||||
md.delMesh(mm);
|
||||
throw exc;
|
||||
}
|
||||
}
|
||||
|
||||
void IOPlugin::reportWarning(const QString& warningMessage) const
|
||||
{
|
||||
MeshLabPluginLogger::log(GLLogStream::WARNING, warningMessage.toStdString());
|
||||
warnString += "\n" + warningMessage;
|
||||
}
|
||||
|
||||
void IOPlugin::wrongOpenFormat(const QString& format)
|
||||
{
|
||||
throw MLException("Internal error: unknown open format " + format + " to " + pluginName() + " plugin.");
|
||||
}
|
||||
|
||||
void IOPlugin::wrongSaveFormat(const QString& format)
|
||||
{
|
||||
throw MLException("Internal error: unknown save format " + format + " to " + pluginName() + " plugin.");
|
||||
}
|
||||
|
||||
QString IOPlugin::warningMessageString() const
|
||||
{
|
||||
QString tmp = warnString;
|
||||
warnString.clear();
|
||||
return tmp;
|
||||
}
|
||||
@ -37,8 +37,8 @@
|
||||
class IOPlugin : virtual public MeshLabPlugin, virtual public MeshLabPluginLogger
|
||||
{
|
||||
public:
|
||||
IOPlugin() : MeshLabPluginLogger() { }
|
||||
virtual ~IOPlugin() {}
|
||||
IOPlugin() : MeshLabPluginLogger() { }
|
||||
virtual ~IOPlugin() { }
|
||||
|
||||
/**
|
||||
* @brief The importFormats function returns a list of all the
|
||||
@ -58,7 +58,15 @@ public:
|
||||
*/
|
||||
virtual std::list<FileFormat> exportFormats() const = 0;
|
||||
|
||||
virtual std::list<FileFormat> importRasterFormats() const {return std::list<FileFormat>();}
|
||||
/**
|
||||
* @brief If yout plugin supports loading also raster formats, re-implement
|
||||
* this function, returning the list of raster formats supported by
|
||||
* your openRaster function.
|
||||
*/
|
||||
virtual std::list<FileFormat> importRasterFormats() const
|
||||
{
|
||||
return std::list<FileFormat>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The initPreOpenParameter function is called to initialize the list
|
||||
@ -66,9 +74,9 @@ public:
|
||||
* called by the framework BEFORE the actual mesh loading to determine how
|
||||
* to parse the input file. The instanced parameters are then passed to the
|
||||
* open at the loading time.
|
||||
* Typical example of use to decide what subportion of a mesh you have to load.
|
||||
* If you do not need any additional processing simply do not override this
|
||||
* and ignore the parameterList in the open member function
|
||||
* Typical example of use to decide what subportion of a mesh you have to
|
||||
* load. If you do not need any additional processing simply do not override
|
||||
* this and ignore the parameterList in the open member function
|
||||
*/
|
||||
virtual void initPreOpenParameter(
|
||||
const QString& /*format*/,
|
||||
@ -133,12 +141,18 @@ public:
|
||||
int& defaultBits) const = 0;
|
||||
|
||||
/**
|
||||
* @brief The open function is called by the framework everytime a mesh is loaded.
|
||||
* @brief The open function is called by the framework everytime a mesh is
|
||||
* loaded. Re-implement this function if the format file you want to open
|
||||
* can contain just one mesh. If your file can contain more than one mesh,
|
||||
* re-implement the "open" function that takes as input the MeshDocument
|
||||
* instead of the MeshModel (see below).
|
||||
* @param format: the extension of the format e.g. "PLY"
|
||||
* @param fileName: the name of the file to be opened (including its path)
|
||||
* @param m: the mesh that is filled with the file content
|
||||
* @param mask: a bit mask that will be filled reporting what kind of data we have found in the file (per vertex color, texture coords etc)
|
||||
* @param par: the parameters that have been set up in the initPreOpenParameter()
|
||||
* @param mask: a bit mask that will be filled reporting what kind of data
|
||||
* we have found in the file (per vertex color, texture coords etc)
|
||||
* @param par: the parameters that have been set up in the
|
||||
* initPreOpenParameter()
|
||||
* @param cb: standard callback for reporting progress in the loading
|
||||
*/
|
||||
virtual void open(
|
||||
@ -150,11 +164,39 @@ public:
|
||||
vcg::CallBackPos *cb = nullptr) = 0;
|
||||
|
||||
/**
|
||||
* @brief The save function is called by the framework everytime a mesh is saved.
|
||||
* @brief The open function is called by the framework everytime a mesh is
|
||||
* loaded. Re-implement this function if your plugin supports loading format
|
||||
* file that could load more than one mesh layer. For other formats, call
|
||||
* the implementation of this interface class, that will take care of
|
||||
* calling the open function for a single layer.
|
||||
* @param format: the extension of the format e.g. "PLY"
|
||||
* @param fileName: the name of the file on which save the mesh m (including its path)
|
||||
* @param fileName: the name of the file to be opened (including its path)
|
||||
* @param m: the mesh that is filled with the file content
|
||||
* @param mask: a bit mask that will be filled reporting what kind of data
|
||||
* we have found in the file (per vertex color, texture coords etc)
|
||||
* @param par: the parameters that have been set up in the
|
||||
* initPreOpenParameter()
|
||||
* @param cb: standard callback for reporting progress in the loading
|
||||
*/
|
||||
virtual void open(
|
||||
const QString &format,
|
||||
const QString &fileName,
|
||||
MeshDocument &md,
|
||||
std::list<MeshModel*>& meshModelList,
|
||||
std::list<int>& maskList,
|
||||
const RichParameterList & par,
|
||||
vcg::CallBackPos *cb = nullptr);
|
||||
|
||||
/**
|
||||
* @brief The save function is called by the framework everytime a mesh is
|
||||
* saved.
|
||||
* @param format: the extension of the format e.g. "PLY"
|
||||
* @param fileName: the name of the file on which save the mesh m
|
||||
* (including its path)
|
||||
* @param m: the mesh to be saved in the file
|
||||
* @param mask: a bit mask indicating what kind of the data present in the mesh should be saved (e.g. you could not want to save normals in ply files)
|
||||
* @param mask: a bit mask indicating what kind of the data present in the
|
||||
* mesh should be saved (e.g. you could not want to save normals in
|
||||
* ply files)
|
||||
* @param par: the parameters that have been set up in the initSaveParameter()
|
||||
* @param cb: standard callback for reporting progress in the saving
|
||||
*/
|
||||
@ -166,6 +208,14 @@ public:
|
||||
const RichParameterList & par,
|
||||
vcg::CallBackPos *cb) = 0;
|
||||
|
||||
/**
|
||||
* @brief If your plugin supports raster formats, re-implement this
|
||||
* function.
|
||||
* @param format: the extension of the format e.g. "JPG"
|
||||
* @param filename: the name of the file to be opened (including its path)
|
||||
* @param rm: the raster model on which save the loaded raster
|
||||
* @param cb: standard callback for reporting progress while opening
|
||||
*/
|
||||
virtual void openRaster(
|
||||
const QString& /*format*/,
|
||||
const QString& /*fileName*/,
|
||||
@ -174,49 +224,35 @@ public:
|
||||
{};
|
||||
|
||||
/**
|
||||
* @brief The reportWarning function should be used everytime that a non-critical
|
||||
* error while loading or saving a file happens. This function appends the
|
||||
* warning message passed as parameter to a string that will be shown
|
||||
* by the framework at the end of the execution of the load/save function
|
||||
* @brief The reportWarning function should be used everytime that a
|
||||
* non-critical error while loading or saving a file happens. This function
|
||||
* appends the warning message passed as parameter to a string that will be
|
||||
* shown by the framework at the end of the execution of the load/save
|
||||
* function
|
||||
* @param warningMessage
|
||||
*/
|
||||
void reportWarning(const QString& warningMessage) const
|
||||
{
|
||||
MeshLabPluginLogger::log(GLLogStream::WARNING, warningMessage.toStdString());
|
||||
warnString += "\n" + warningMessage;
|
||||
}
|
||||
void reportWarning(const QString& warningMessage) const;
|
||||
|
||||
/**
|
||||
* @brief call this function in any of the import functions
|
||||
* (initPreOpenParameters, load...) whenever you receive as parameter a
|
||||
* format that is not supported by your plugin
|
||||
*/
|
||||
void wrongOpenFormat(const QString& format)
|
||||
{
|
||||
throw MLException("Internal error: unknown open format " + format + " to " + pluginName() + " plugin.");
|
||||
};
|
||||
void wrongOpenFormat(const QString& format);
|
||||
|
||||
/**
|
||||
* @brief call this function in any of the export functions
|
||||
* (exportMaskCapability, save...) whenever you receive as parameter a
|
||||
* format that is not supported by your plugin
|
||||
*/
|
||||
void wrongSaveFormat(const QString& format)
|
||||
{
|
||||
throw MLException("Internal error: unknown save format " + format + " to " + pluginName() + " plugin.");
|
||||
};
|
||||
void wrongSaveFormat(const QString& format);
|
||||
|
||||
/**
|
||||
* @brief The warningMessageString is invoked by the framework after the execution
|
||||
* of load/save function. It returns the warning string containing all the
|
||||
* warinings produced by the function, and it clears the string.
|
||||
* @brief The warningMessageString is invoked by the framework after the
|
||||
* execution of load/save function. It returns the warning string containing
|
||||
* all the warinings produced by the function, and it clears the string.
|
||||
*/
|
||||
QString warningMessageString() const
|
||||
{
|
||||
QString tmp = warnString;
|
||||
warnString.clear();
|
||||
return tmp;
|
||||
};
|
||||
QString warningMessageString() const;
|
||||
|
||||
private:
|
||||
mutable QString warnString;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user