FileFormat file outside IOMeshPlugin

This commit is contained in:
alemuntoni 2020-11-25 12:30:01 +01:00
parent 95ef6115c2
commit 8ae6c8de18
30 changed files with 354 additions and 358 deletions

View File

@ -37,8 +37,8 @@ public:
IOMeshPluginInterface() : PluginInterface() { }
virtual ~IOMeshPluginInterface() {}
virtual QList<Format> importFormats() const = 0;
virtual QList<Format> exportFormats() const = 0;
virtual QList<FileFormat> importFormats() const = 0;
virtual QList<FileFormat> exportFormats() const = 0;
// This function is called to initialize the list of additional parameters that a OPENING filter could require
// it is called by the framework BEFORE the actual mesh loading to perform to determine how parse the input file

View File

@ -281,7 +281,7 @@ void PluginManager::knownIOFormats()
for (QVector<IOMeshPluginInterface*>::iterator itIOPlugin = meshIOPlug.begin(); itIOPlugin != meshIOPlug.end(); ++itIOPlugin)
{
IOMeshPluginInterface* pMeshIOPlugin = *itIOPlugin;
QList<IOMeshPluginInterface::Format> format;
QList<FileFormat> format;
QMap<QString, IOMeshPluginInterface*>* map = NULL;
if (inpOut == int(IMPORT))
{
@ -295,9 +295,9 @@ void PluginManager::knownIOFormats()
formatFilters = &outFilters;
format = pMeshIOPlugin->exportFormats();
}
for (QList<IOMeshPluginInterface::Format>::iterator itf = format.begin(); itf != format.end(); ++itf)
for (QList<FileFormat>::iterator itf = format.begin(); itf != format.end(); ++itf)
{
IOMeshPluginInterface::Format currentFormat = *itf;
FileFormat currentFormat = *itf;
QString currentFilterEntry = currentFormat.description + " (";

View File

@ -26,10 +26,10 @@
#include <QStringList>
class Format
class FileFormat
{
public:
Format(QString description, QString ex) : description(description), extensions(ex){}
FileFormat(QString description, QString ex) : description(description), extensions(ex){}
QString description;
QStringList extensions;
};

View File

@ -119,13 +119,13 @@ void PluginDialog::populateTreeWidget(const QString &path,const QStringList &fil
if (iMeshIO){
nPlugins++;
QStringList Templist;
for(const IOMeshPluginInterface::Format& f: iMeshIO->importFormats()){
for(const FileFormat& f: iMeshIO->importFormats()){
QString formats;
for(const QString& s : f.extensions)
formats+="Importer_"+s+" ";
Templist.push_back(formats);
}
for(const IOMeshPluginInterface::Format& f: iMeshIO->exportFormats()){
for(const FileFormat& f: iMeshIO->exportFormats()){
QString formats;
for(const QString& s: f.extensions)
formats+="Exporter_"+s+" ";
@ -201,13 +201,13 @@ void PluginDialog::displayInfo(QTreeWidgetItem* item,int /* ncolumn*/)
if (plugin) {
IOMeshPluginInterface *iMeshIO = qobject_cast<IOMeshPluginInterface *>(plugin);
if (iMeshIO){
for(const IOMeshPluginInterface::Format& f: iMeshIO->importFormats()){
for(const FileFormat& f: iMeshIO->importFormats()){
QString formats;
for(const QString& s: f.extensions)
formats+="Importer_"+s+" ";
if (actionName==formats) labelInfo->setText(f.description);
}
for(const IOMeshPluginInterface::Format& f: iMeshIO->exportFormats()){
for(const FileFormat& f: iMeshIO->exportFormats()){
QString formats;
for(const QString& s: f.extensions)
formats+="Exporter_"+s+" ";

View File

@ -157,16 +157,16 @@ FilterPluginInterface::FilterClass FilterSSynth::getClass(const QAction */*filte
return FilterPluginInterface::MeshCreation;
}
QList<IOMeshPluginInterface::Format> FilterSSynth::importFormats() const
QList<FileFormat> FilterSSynth::importFormats() const
{
QList<IOMeshPluginInterface::Format> formats;
formats<< IOMeshPluginInterface::Format("Eisen Script File", tr("ES"));
QList<FileFormat> formats;
formats<< FileFormat("Eisen Script File", tr("ES"));
return formats;
}
QList<IOMeshPluginInterface::Format> FilterSSynth::exportFormats() const
QList<FileFormat> FilterSSynth::exportFormats() const
{
QList<IOMeshPluginInterface::Format> formats;
QList<FileFormat> formats;
return formats ;
}

View File

@ -50,8 +50,8 @@ public:
void setAttributes(CMeshO::VertexIterator &vi, CMeshO &m);
static void openX3D(const QString &fileName, MeshModel &m, int& mask, vcg::CallBackPos *cb, QWidget *parent=0);
virtual int postCondition(const QAction* filter) const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
virtual void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;
void initPreOpenParameter(const QString &formatName, const QString &filename, RichParameterList &parlst);

View File

@ -53,168 +53,168 @@ using namespace vcg;
bool ExtraMeshIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList &, CallBackPos *cb, QWidget *parent)
{
// initializing mask
mask = 0;
mask = 0;
// initializing progress bar status
if (cb != NULL) (*cb)(0, "Loading...");
QString errorMsgFormat = "Error encountered while loading file:\n\"%1\"\n\nError details: %2";
//QString error_2MsgFormat = "Error encountered while loading file:\n\"%1\"\n\n File with more than a mesh.\n Load only the first!";
//QString error_2MsgFormat = "Error encountered while loading file:\n\"%1\"\n\n File with more than a mesh.\n Load only the first!";
string filename = QFile::encodeName(fileName).constData ();
//string filename = fileName.toUtf8().data();
//string filename = fileName.toUtf8().data();
if (formatName.toUpper() == tr("3DS"))
{
vcg::tri::io::_3dsInfo info;
info.cb = cb;
Lib3dsFile *file = NULL;
file = lib3ds_file_load(filename.c_str());
if (!file)
{
int result = vcg::tri::io::Importer3DS<CMeshO>::E_CANTOPEN;
QMessageBox::warning(parent, tr("3DS Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::Importer3DS<CMeshO>::ErrorMsg(result)));
return false;
}
// No nodes? Fabricate nodes to display all the meshes.
if( !file->nodes && file->meshes)
{
Lib3dsMesh *mesh;
Lib3dsNode *node;
for (mesh = file->meshes; mesh != NULL; mesh = mesh->next)
{
node = lib3ds_node_new_object();
strcpy(node->name, mesh->name);
node->parent_id = LIB3DS_NO_PARENT;
lib3ds_file_insert_node(file, node);
}
}
if( !file->nodes)
return false;
lib3ds_file_eval(file, 0);
bool singleLayer = true;
if ( file->nodes->next)
{
if ( QMessageBox::question(parent, tr("3DS Import Option"),
tr("File with more than a mesh.\n\nDo you want to import each mesh as a separate layer?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes )
singleLayer = false;
}
if (!singleLayer)
{
Lib3dsNode *p;
mask = 0;
int i=1;
for (p=file->nodes; p!=0; p=p->next, ++i)
{
bool normalsUpdated = false;
MeshModel &mm = *m.parent->addNewMesh(qUtf8Printable(fileName), QString(p->name), false);
if (cb != NULL) (*cb)(i, (QString("Loading Mesh ")+QString(p->name)).toStdString().c_str());
vcg::tri::io::Importer3DS<CMeshO>::LoadMask(file, p, info);
mm.Enable(info.mask);
int result = vcg::tri::io::Importer3DS<CMeshO>::Load(mm.cm, file, p, info);
if (result != vcg::tri::io::Importer3DS<CMeshO>::E_NOERROR)
{
QMessageBox::warning(parent, tr("3DS Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::Importer3DS<CMeshO>::ErrorMsg(result)));
continue;
}
if(info.mask & vcg::tri::io::Mask::IOM_WEDGNORMAL)
normalsUpdated = true;
mask |= info.mask;
// verify if texture files are present
QString missingTextureFilesMsg = "The following texture files were not found:\n";
bool someTextureNotFound = false;
for ( unsigned textureIdx = 0; textureIdx < mm.cm.textures.size(); ++textureIdx)
{
FILE* pFile = fopen (mm.cm.textures[textureIdx].c_str(), "r");
if (pFile == NULL)
{
missingTextureFilesMsg.append("\n");
missingTextureFilesMsg.append(mm.cm.textures[textureIdx].c_str());
someTextureNotFound = true;
}
fclose (pFile);
}
if (someTextureNotFound)
QMessageBox::warning(parent, tr("Missing texture files"), missingTextureFilesMsg);
vcg::tri::UpdateBounding<CMeshO>::Box(mm.cm); // updates bounding box
if (!normalsUpdated)
vcg::tri::UpdateNormal<CMeshO>::PerVertex(mm.cm); // updates normals
}
}
else
{
bool normalsUpdated = false;
vcg::tri::io::Importer3DS<CMeshO>::LoadMask(file, 0, info);
m.Enable(info.mask);
int result = vcg::tri::io::Importer3DS<CMeshO>::Load(m.cm, file, 0, info);
if (result != vcg::tri::io::Importer3DS<CMeshO>::E_NOERROR)
file = lib3ds_file_load(filename.c_str());
if (!file)
{
QMessageBox::warning(parent, tr("3DS Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::Importer3DS<CMeshO>::ErrorMsg(result)));
lib3ds_file_free(file);
int result = vcg::tri::io::Importer3DS<CMeshO>::E_CANTOPEN;
errorMessage = errorMsgFormat.arg(fileName, vcg::tri::io::Importer3DS<CMeshO>::ErrorMsg(result));
return false;
}
if(info.mask & vcg::tri::io::Mask::IOM_WEDGNORMAL)
normalsUpdated = true;
mask = info.mask;
// verify if texture files are present
QString missingTextureFilesMsg = "The following texture files were not found:\n";
bool someTextureNotFound = false;
for ( unsigned textureIdx = 0; textureIdx < m.cm.textures.size(); ++textureIdx)
{
FILE* pFile = fopen (m.cm.textures[textureIdx].c_str(), "r");
if (pFile == NULL)
// No nodes? Fabricate nodes to display all the meshes.
if( !file->nodes && file->meshes)
{
missingTextureFilesMsg.append("\n");
missingTextureFilesMsg.append(m.cm.textures[textureIdx].c_str());
someTextureNotFound = true;
Lib3dsMesh *mesh;
Lib3dsNode *node;
for (mesh = file->meshes; mesh != NULL; mesh = mesh->next)
{
node = lib3ds_node_new_object();
strcpy(node->name, mesh->name);
node->parent_id = LIB3DS_NO_PARENT;
lib3ds_file_insert_node(file, node);
}
}
fclose (pFile);
if( !file->nodes)
return false;
lib3ds_file_eval(file, 0);
bool singleLayer = true;
if ( file->nodes->next)
{
if ( QMessageBox::question(parent, tr("3DS Import Option"),
tr("File with more than a mesh.\n\nDo you want to import each mesh as a separate layer?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes )
singleLayer = false;
}
if (!singleLayer)
{
Lib3dsNode *p;
mask = 0;
int i=1;
for (p=file->nodes; p!=0; p=p->next, ++i)
{
bool normalsUpdated = false;
MeshModel &mm = *m.parent->addNewMesh(qUtf8Printable(fileName), QString(p->name), false);
if (cb != NULL) (*cb)(i, (QString("Loading Mesh ")+QString(p->name)).toStdString().c_str());
vcg::tri::io::Importer3DS<CMeshO>::LoadMask(file, p, info);
mm.Enable(info.mask);
int result = vcg::tri::io::Importer3DS<CMeshO>::Load(mm.cm, file, p, info);
if (result != vcg::tri::io::Importer3DS<CMeshO>::E_NOERROR)
{
QMessageBox::warning(parent, tr("3DS Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::Importer3DS<CMeshO>::ErrorMsg(result)));
continue;
}
if(info.mask & vcg::tri::io::Mask::IOM_WEDGNORMAL)
normalsUpdated = true;
mask |= info.mask;
// verify if texture files are present
QString missingTextureFilesMsg = "The following texture files were not found:\n";
bool someTextureNotFound = false;
for ( unsigned textureIdx = 0; textureIdx < mm.cm.textures.size(); ++textureIdx)
{
FILE* pFile = fopen (mm.cm.textures[textureIdx].c_str(), "r");
if (pFile == NULL)
{
missingTextureFilesMsg.append("\n");
missingTextureFilesMsg.append(mm.cm.textures[textureIdx].c_str());
someTextureNotFound = true;
}
fclose (pFile);
}
if (someTextureNotFound)
QMessageBox::warning(parent, tr("Missing texture files"), missingTextureFilesMsg);
vcg::tri::UpdateBounding<CMeshO>::Box(mm.cm); // updates bounding box
if (!normalsUpdated)
vcg::tri::UpdateNormal<CMeshO>::PerVertex(mm.cm); // updates normals
}
}
else
{
bool normalsUpdated = false;
vcg::tri::io::Importer3DS<CMeshO>::LoadMask(file, 0, info);
m.Enable(info.mask);
int result = vcg::tri::io::Importer3DS<CMeshO>::Load(m.cm, file, 0, info);
if (result != vcg::tri::io::Importer3DS<CMeshO>::E_NOERROR)
{
QMessageBox::warning(parent, tr("3DS Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::Importer3DS<CMeshO>::ErrorMsg(result)));
lib3ds_file_free(file);
return false;
}
if(info.mask & vcg::tri::io::Mask::IOM_WEDGNORMAL)
normalsUpdated = true;
mask = info.mask;
// verify if texture files are present
QString missingTextureFilesMsg = "The following texture files were not found:\n";
bool someTextureNotFound = false;
for ( unsigned textureIdx = 0; textureIdx < m.cm.textures.size(); ++textureIdx)
{
FILE* pFile = fopen (m.cm.textures[textureIdx].c_str(), "r");
if (pFile == NULL)
{
missingTextureFilesMsg.append("\n");
missingTextureFilesMsg.append(m.cm.textures[textureIdx].c_str());
someTextureNotFound = true;
}
fclose (pFile);
}
if (someTextureNotFound)
QMessageBox::warning(parent, tr("Missing texture files"), missingTextureFilesMsg);
vcg::tri::UpdateBounding<CMeshO>::Box(m.cm); // updates bounding box
if (!normalsUpdated)
vcg::tri::UpdateNormal<CMeshO>::PerVertex(m.cm); // updates normals
}
if (cb != NULL) (*cb)(99, "Done");
// freeing memory
lib3ds_file_free(file);
return true;
}
if (someTextureNotFound)
QMessageBox::warning(parent, tr("Missing texture files"), missingTextureFilesMsg);
vcg::tri::UpdateBounding<CMeshO>::Box(m.cm); // updates bounding box
if (!normalsUpdated)
vcg::tri::UpdateNormal<CMeshO>::PerVertex(m.cm); // updates normals
}
if (cb != NULL) (*cb)(99, "Done");
// freeing memory
lib3ds_file_free(file);
return true;
}
return false;
return false;
}
bool ExtraMeshIOPlugin::save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask, const RichParameterList &, vcg::CallBackPos *cb, QWidget *parent)
{
QString errorMsgFormat = "Error encountered while exporting file %1:\n%2";
string filename = QFile::encodeName(fileName).constData ();
//string filename = fileName.toUtf8().data();
//string filename = fileName.toUtf8().data();
string ex = formatName.toUtf8().data();
if(formatName.toUpper() == tr("3DS"))
@ -228,27 +228,27 @@ bool ExtraMeshIOPlugin::save(const QString &formatName, const QString &fileName,
return true;
}
else
assert(0); // unknown format
return false;
assert(0); // unknown format
return false;
}
/*
returns the list of the file's type which can be imported
*/
QList<IOMeshPluginInterface::Format> ExtraMeshIOPlugin::importFormats() const
QList<FileFormat> ExtraMeshIOPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("3D-Studio File Format" ,tr("3DS"));
QList<FileFormat> formatList;
formatList << FileFormat("3D-Studio File Format" ,tr("3DS"));
return formatList;
}
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> ExtraMeshIOPlugin::exportFormats() const
QList<FileFormat> ExtraMeshIOPlugin::exportFormats() const
{
QList<Format> formatList;
formatList << Format("3D-Studio File Format" ,tr("3DS"));
QList<FileFormat> formatList;
formatList << FileFormat("3D-Studio File Format" ,tr("3DS"));
return formatList;
}

View File

@ -39,8 +39,8 @@ class ExtraMeshIOPlugin : public QObject, public IOMeshPluginInterface
public:
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
QString pluginName() const;
void GetExportMaskCapability(const QString& format, int &capability, int &defaultBits) const;

View File

@ -432,17 +432,17 @@ QString BaseMeshIOPlugin::pluginName() const
/*
returns the list of the file's type which can be imported
*/
QList<IOMeshPluginInterface::Format> BaseMeshIOPlugin::importFormats() const
QList<FileFormat> BaseMeshIOPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("Stanford Polygon File Format", tr("PLY"));
formatList << Format("STL File Format", tr("STL"));
formatList << Format("Alias Wavefront Object", tr("OBJ"));
formatList << Format("Quad Object", tr("QOBJ"));
formatList << Format("Object File Format", tr("OFF"));
formatList << Format("PTX File Format", tr("PTX"));
formatList << Format("VCG Dump File Format", tr("VMI"));
formatList << Format("FBX Autodesk Interchange Format", tr("FBX"));
QList<FileFormat> formatList;
formatList << FileFormat("Stanford Polygon File Format", tr("PLY"));
formatList << FileFormat("STL File Format", tr("STL"));
formatList << FileFormat("Alias Wavefront Object", tr("OBJ"));
formatList << FileFormat("Quad Object", tr("QOBJ"));
formatList << FileFormat("Object File Format", tr("OFF"));
formatList << FileFormat("PTX File Format", tr("PTX"));
formatList << FileFormat("VCG Dump File Format", tr("VMI"));
formatList << FileFormat("FBX Autodesk Interchange Format", tr("FBX"));
return formatList;
}
@ -450,15 +450,15 @@ QList<IOMeshPluginInterface::Format> BaseMeshIOPlugin::importFormats() const
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> BaseMeshIOPlugin::exportFormats() const
QList<FileFormat> BaseMeshIOPlugin::exportFormats() const
{
QList<Format> formatList;
formatList << Format("Stanford Polygon File Format", tr("PLY"));
formatList << Format("STL File Format", tr("STL"));
formatList << Format("Alias Wavefront Object", tr("OBJ"));
formatList << Format("Object File Format", tr("OFF"));
formatList << Format("VRML File Format", tr("WRL"));
formatList << Format("DXF File Format", tr("DXF"));
QList<FileFormat> formatList;
formatList << FileFormat("Stanford Polygon File Format", tr("PLY"));
formatList << FileFormat("STL File Format", tr("STL"));
formatList << FileFormat("Alias Wavefront Object", tr("OBJ"));
formatList << FileFormat("Object File Format", tr("OFF"));
formatList << FileFormat("VRML File Format", tr("WRL"));
formatList << FileFormat("DXF File Format", tr("DXF"));
return formatList;
}

View File

@ -38,8 +38,8 @@ public:
BaseMeshIOPlugin() : IOMeshPluginInterface() {}
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
void GetExportMaskCapability(const QString& format, int &capability, int &defaultBits) const;

View File

@ -160,10 +160,10 @@ QString BreMeshIOPlugin::pluginName() const
return "IOBRE";
}
QList<IOMeshPluginInterface::Format> BreMeshIOPlugin::importFormats() const
QList<FileFormat> BreMeshIOPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("Breuckmann File Format" , tr("BRE"));
QList<FileFormat> formatList;
formatList << FileFormat("Breuckmann File Format" , tr("BRE"));
return formatList;
}
@ -171,9 +171,9 @@ QList<IOMeshPluginInterface::Format> BreMeshIOPlugin::importFormats() const
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> BreMeshIOPlugin::exportFormats() const
QList<FileFormat> BreMeshIOPlugin::exportFormats() const
{
QList<Format> formatList;
QList<FileFormat> formatList;
//formatList << Format("Breuckmann File Format" , tr("BRE"));
return formatList;
}

View File

@ -161,8 +161,8 @@ public:
BreMeshIOPlugin() : IOMeshPluginInterface() {}
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;

View File

@ -219,20 +219,20 @@ QString ColladaIOPlugin::pluginName() const
return "IOCollada";
}
QList<IOMeshPluginInterface::Format> ColladaIOPlugin::importFormats() const
QList<FileFormat> ColladaIOPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("Collada File Format" ,tr("DAE"));
QList<FileFormat> formatList;
formatList << FileFormat("Collada File Format" ,tr("DAE"));
return formatList;
}
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> ColladaIOPlugin::exportFormats() const
QList<FileFormat> ColladaIOPlugin::exportFormats() const
{
QList<Format> formatList;
formatList << Format("Collada File Format" ,tr("DAE"));
QList<FileFormat> formatList;
formatList << FileFormat("Collada File Format" ,tr("DAE"));
return formatList;
}

View File

@ -58,8 +58,8 @@ class ColladaIOPlugin : public QObject, public IOMeshPluginInterface
std::vector<MeshModel*> _mp;
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;
void initPreOpenParameter(const QString &/*format*/, const QString &/*fileName*/, RichParameterList & /*par*/);

View File

@ -71,20 +71,20 @@ QString IOMPlugin::pluginName() const
return "IOCTM";
}
QList<IOMeshPluginInterface::Format> IOMPlugin::importFormats() const
QList<FileFormat> IOMPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("OpenCTM compressed format" ,tr("CTM"));
QList<FileFormat> formatList;
formatList << FileFormat("OpenCTM compressed format" ,tr("CTM"));
return formatList;
}
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> IOMPlugin::exportFormats() const
QList<FileFormat> IOMPlugin::exportFormats() const
{
QList<Format> formatList;
formatList << Format("OpenCTM compressed format" ,tr("CTM"));
QList<FileFormat> formatList;
formatList << FileFormat("OpenCTM compressed format" ,tr("CTM"));
return formatList;
}

View File

@ -44,8 +44,8 @@ class IOMPlugin : public QObject, public IOMeshPluginInterface
public:
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
virtual void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;
void initSaveParameter(const QString &/*format*/, MeshModel &/*m*/, RichParameterList & /*par*/);

View File

@ -40,73 +40,70 @@ using namespace vcg;
bool ExpeIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList & /*parlst*/, CallBackPos *cb, QWidget *parent)
bool ExpeIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList & /*parlst*/, CallBackPos *cb, QWidget*/*parent*/)
{
// initializing mask
mask = 0;
// initializing progress bar status
if (cb != NULL) (*cb)(0, "Loading...");
QString errorMsgFormat = "Error encountered while loading file:\n\"%1\"\n\nError details: %2";
QString error_2MsgFormat = "Error encountered while loading file:\n\"%1\"\n\n File with more than a mesh.\n Load only the first!";
string filename = QFile::encodeName(fileName).constData ();
bool useXYZ=false;
bool useXYZ=false;
if ( (formatName.toLower() == tr("pts")) || (formatName.toLower() == tr("apts")) )
{
int loadMask;
if (!vcg::tri::io::ImporterExpePTS<CMeshO>::LoadMask(filename.c_str(),loadMask))
{
useXYZ=true;
if (!vcg::tri::io::ImporterXYZ<CMeshO>::LoadMask(filename.c_str(),loadMask))
return false;
}
m.Enable(loadMask);
int result;
if(useXYZ) {
result = vcg::tri::io::ImporterXYZ<CMeshO>::Open(m.cm, filename.c_str(), mask, cb);
if (result != 0)
{
QMessageBox::warning(parent, tr("PTX Point Set Opening Error"),
errorMsgFormat.arg(fileName, vcg::tri::io::ImporterXYZ<CMeshO>::ErrorMsg(result)));
return false;
}
}
else
{
result = vcg::tri::io::ImporterExpePTS<CMeshO>::Open(m.cm, filename.c_str(), mask, cb);
if (result != 0)
{
QMessageBox::warning(parent, tr("Expe Point Set Opening Error"),
errorMsgFormat.arg(fileName, vcg::tri::io::ImporterExpePTS<CMeshO>::ErrorMsg(result)));
return false;
}
}
}
else if (formatName.toLower() == tr("xyz"))
{
int loadMask;
if (!vcg::tri::io::ImporterXYZ<CMeshO>::LoadMask(filename.c_str(),loadMask))
return false;
m.Enable(loadMask);
int result = vcg::tri::io::ImporterXYZ<CMeshO>::Open(m.cm, filename.c_str(), mask, cb);
if (result != 0)
{
QMessageBox::warning(parent, tr("XYZ Opening Error"),
errorMsgFormat.arg(fileName, vcg::tri::io::ImporterXYZ<CMeshO>::ErrorMsg(result)));
return false;
}
}
{
int loadMask;
if (!vcg::tri::io::ImporterExpePTS<CMeshO>::LoadMask(filename.c_str(),loadMask))
{
useXYZ=true;
if (!vcg::tri::io::ImporterXYZ<CMeshO>::LoadMask(filename.c_str(),loadMask))
return false;
}
m.Enable(loadMask);
int result;
if(useXYZ) {
result = vcg::tri::io::ImporterXYZ<CMeshO>::Open(m.cm, filename.c_str(), mask, cb);
if (result != 0)
{
errorMessage = errorMsgFormat.arg(fileName, vcg::tri::io::ImporterXYZ<CMeshO>::ErrorMsg(result));
return false;
}
}
else
{
result = vcg::tri::io::ImporterExpePTS<CMeshO>::Open(m.cm, filename.c_str(), mask, cb);
if (result != 0)
{
errorMessage = errorMsgFormat.arg(fileName, vcg::tri::io::ImporterExpePTS<CMeshO>::ErrorMsg(result));
return false;
}
}
}
else if (formatName.toLower() == tr("xyz"))
{
int loadMask;
if (!vcg::tri::io::ImporterXYZ<CMeshO>::LoadMask(filename.c_str(),loadMask))
return false;
m.Enable(loadMask);
int result = vcg::tri::io::ImporterXYZ<CMeshO>::Open(m.cm, filename.c_str(), mask, cb);
if (result != 0)
{
errorMessage = errorMsgFormat.arg(fileName, vcg::tri::io::ImporterXYZ<CMeshO>::ErrorMsg(result));
return false;
}
}
vcg::tri::UpdateBounding<CMeshO>::Box(m.cm); // updates bounding box
if (cb != NULL)
(*cb)(99, "Done");
return true;
}
@ -115,29 +112,29 @@ bool ExpeIOPlugin::save(const QString &formatName, const QString &fileName, Mesh
QString errorMsgFormat = "Error encountered while exporting file %1:\n%2";
string filename = QFile::encodeName(fileName).constData ();
string ex = formatName.toUtf8().data();
// if( formatName.toUpper() == tr("GTS") )
// {
// int result = vcg::tri::io::ExporterGTS<CMeshO>::Save(m.cm,filename.c_str(),mask);
// if(result!=0)
// {
// QMessageBox::warning(parent, tr("Saving Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ExporterGTS<CMeshO>::ErrorMsg(result)));
// return false;
// }
// return true;
// }
if(formatName.toLower() == tr("xyz"))
{
int result = vcg::tri::io::ExporterXYZ<CMeshO>::Save(m.cm,filename.c_str(),mask);
if(result!=0)
{
QMessageBox::warning(parent, tr("Saving Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ExporterXYZ<CMeshO>::ErrorMsg(result)));
return false;
}
return true;
}
// if( formatName.toUpper() == tr("GTS") )
// {
// int result = vcg::tri::io::ExporterGTS<CMeshO>::Save(m.cm,filename.c_str(),mask);
// if(result!=0)
// {
// QMessageBox::warning(parent, tr("Saving Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ExporterGTS<CMeshO>::ErrorMsg(result)));
// return false;
// }
// return true;
// }
if(formatName.toLower() == tr("xyz"))
{
int result = vcg::tri::io::ExporterXYZ<CMeshO>::Save(m.cm,filename.c_str(),mask);
if(result!=0)
{
QMessageBox::warning(parent, tr("Saving Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ExporterXYZ<CMeshO>::ErrorMsg(result)));
return false;
}
return true;
}
assert(0); // unknown format
return false;
}
@ -150,24 +147,24 @@ QString ExpeIOPlugin::pluginName() const
return "IOExpe";
}
QList<IOMeshPluginInterface::Format> ExpeIOPlugin::importFormats() const
QList<FileFormat> ExpeIOPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("Expe's point set (binary)" ,tr("pts"));
formatList << Format("Expe's point set (ascii)" ,tr("apts"));
formatList << Format("XYZ Point Cloud (with or without normal)" ,tr("xyz"));
QList<FileFormat> formatList;
formatList << FileFormat("Expe's point set (binary)" ,tr("pts"));
formatList << FileFormat("Expe's point set (ascii)" ,tr("apts"));
formatList << FileFormat("XYZ Point Cloud (with or without normal)" ,tr("xyz"));
return formatList;
}
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> ExpeIOPlugin::exportFormats() const
QList<FileFormat> ExpeIOPlugin::exportFormats() const
{
QList<Format> formatList;
// formatList << Format("Expe's point set (binary)" ,tr("pts"));
// formatList << Format("Expe's point set (ascii)" ,tr("apts"));
formatList << Format("XYZ Point Cloud (with or without normal)" ,tr("xyz"));
QList<FileFormat> formatList;
// formatList << Format("Expe's point set (binary)" ,tr("pts"));
// formatList << Format("Expe's point set (ascii)" ,tr("apts"));
formatList << FileFormat("XYZ Point Cloud (with or without normal)" ,tr("xyz"));
return formatList;
}
@ -177,9 +174,9 @@ QList<IOMeshPluginInterface::Format> ExpeIOPlugin::exportFormats() const
*/
void ExpeIOPlugin::GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const
{
// if(format.toLower() == tr("apts")){capability=defaultBits= vcg::tri::io::ExporterExpeAPTS<CMeshO>::GetExportMaskCapability();}
// if(format.toLower() == tr("pts")){capability=defaultBits= vcg::tri::io::ExporterExpePTS<CMeshO>::GetExportMaskCapability();}
if(format.toLower() == tr("xyz")){capability=defaultBits= vcg::tri::io::ExporterXYZ<CMeshO>::GetExportMaskCapability();}
// if(format.toLower() == tr("apts")){capability=defaultBits= vcg::tri::io::ExporterExpeAPTS<CMeshO>::GetExportMaskCapability();}
// if(format.toLower() == tr("pts")){capability=defaultBits= vcg::tri::io::ExporterExpePTS<CMeshO>::GetExportMaskCapability();}
if(format.toLower() == tr("xyz")){capability=defaultBits= vcg::tri::io::ExporterXYZ<CMeshO>::GetExportMaskCapability();}
return;
}

View File

@ -39,8 +39,8 @@ class ExpeIOPlugin : public QObject, public IOMeshPluginInterface
public:
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
virtual void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;
// void initPreOpenParameter(const QString &/*format*/, const QString &/*fileName*/, RichParameterSet & /*par*/);

View File

@ -45,7 +45,7 @@ QString JSONIOPlugin::pluginName() const
return "IOJson";
}
bool JSONIOPlugin::open(const QString & formatName, const QString & fileName, MeshModel & m, int & mask, const RichParameterList & parlst, vcg::CallBackPos * cb, QWidget * parent)
bool JSONIOPlugin::open(const QString & formatName, const QString & fileName, MeshModel & m, int & mask, const RichParameterList & parlst, vcg::CallBackPos * cb, QWidget * /*parent*/)
{
(void)formatName;
(void)fileName;
@ -53,7 +53,6 @@ bool JSONIOPlugin::open(const QString & formatName, const QString & fileName, Me
(void)mask;
(void)parlst;
(void)cb;
(void)parent;
return false;
}
@ -426,9 +425,9 @@ bool JSONIOPlugin::save(const QString & formatName,const QString & fileName, Mes
/*
returns the list of the file's type which can be imported
*/
QList<IOMeshPluginInterface::Format> JSONIOPlugin::importFormats(void) const
QList<FileFormat> JSONIOPlugin::importFormats(void) const
{
QList<Format> formatList;
QList<FileFormat> formatList;
//formatList << Format("JavaScript JSON", tr("JSON"));
return formatList;
}
@ -436,10 +435,10 @@ QList<IOMeshPluginInterface::Format> JSONIOPlugin::importFormats(void) const
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> JSONIOPlugin::exportFormats(void) const
QList<FileFormat> JSONIOPlugin::exportFormats(void) const
{
QList<Format> formatList;
formatList << Format("JavaScript JSON", tr("JSON"));
QList<FileFormat> formatList;
formatList << FileFormat("JavaScript JSON", tr("JSON"));
return formatList;
}

View File

@ -39,8 +39,8 @@ public:
QString pluginName() const;
QList<Format> importFormats(void) const;
QList<Format> exportFormats(void) const;
QList<FileFormat> importFormats(void) const;
QList<FileFormat> exportFormats(void) const;
void GetExportMaskCapability(const QString & format, int & capability, int & defaultBits) const;

View File

@ -148,10 +148,10 @@ QString PDBIOPlugin::pluginName() const
return "IOPDB";
}
QList<IOMeshPluginInterface::Format> PDBIOPlugin::importFormats() const
QList<FileFormat> PDBIOPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("Protein Data Bank" , tr("PDB"));
QList<FileFormat> formatList;
formatList << FileFormat("Protein Data Bank" , tr("PDB"));
return formatList;
}
@ -159,9 +159,9 @@ QList<IOMeshPluginInterface::Format> PDBIOPlugin::importFormats() const
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> PDBIOPlugin::exportFormats() const
QList<FileFormat> PDBIOPlugin::exportFormats() const
{
QList<Format> formatList;
QList<FileFormat> formatList;
// formatList << Format("Stanford Polygon File Format" , tr("PLY"));
return formatList;

View File

@ -37,8 +37,8 @@ class PDBIOPlugin : public QObject, public IOMeshPluginInterface
public:
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;

View File

@ -87,21 +87,21 @@ QString TriIOPlugin::pluginName() const
return "IOTRI";
}
QList<IOMeshPluginInterface::Format> TriIOPlugin::importFormats() const
QList<FileFormat> TriIOPlugin::importFormats() const
{
QList<Format> formatList;
QList<FileFormat> formatList;
formatList
<< Format("TRI (photogrammetric reconstructions)", tr("TRI"))
<< Format("ASC (ascii triplets of points)", tr("ASC"));
<< FileFormat("TRI (photogrammetric reconstructions)", tr("TRI"))
<< FileFormat("ASC (ascii triplets of points)", tr("ASC"));
return formatList;
}
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> TriIOPlugin::exportFormats() const
QList<FileFormat> TriIOPlugin::exportFormats() const
{
QList<Format> formatList;
QList<FileFormat> formatList;
return formatList;
}

View File

@ -43,8 +43,8 @@ class TriIOPlugin : public QObject, public IOMeshPluginInterface
public:
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
virtual void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;
virtual void initPreOpenParameter(const QString &/*format*/, const QString &/*fileName*/, RichParameterList & /*par*/);

View File

@ -103,10 +103,10 @@ QString TxtIOPlugin::pluginName() const
return "IOTXT";
}
QList<IOMeshPluginInterface::Format> TxtIOPlugin::importFormats() const
QList<FileFormat> TxtIOPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("TXT (Generic ASCII point list)", tr("TXT"));
QList<FileFormat> formatList;
formatList << FileFormat("TXT (Generic ASCII point list)", tr("TXT"));
return formatList;
}
@ -114,9 +114,9 @@ QList<IOMeshPluginInterface::Format> TxtIOPlugin::importFormats() const
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> TxtIOPlugin::exportFormats() const
QList<FileFormat> TxtIOPlugin::exportFormats() const
{
QList<Format> formatList;
QList<FileFormat> formatList;
return formatList;
}
@ -126,7 +126,7 @@ QList<IOMeshPluginInterface::Format> TxtIOPlugin::exportFormats() const
*/
void TxtIOPlugin::GetExportMaskCapability(const QString & /*format*/, int &capability, int &defaultBits) const
{
capability=defaultBits=0;
capability=defaultBits=0;
return;
}

View File

@ -37,8 +37,8 @@ class TxtIOPlugin : public QObject, public IOMeshPluginInterface
public:
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
virtual void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;
virtual void initPreOpenParameter(const QString &/*format*/, const QString &/*fileName*/, RichParameterList & /*par*/);

View File

@ -146,20 +146,20 @@ QString U3DIOPlugin::pluginName() const
return "IOU3D";
}
QList<IOMeshPluginInterface::Format> U3DIOPlugin::importFormats() const
QList<FileFormat> U3DIOPlugin::importFormats() const
{
QList<Format> formatList;
QList<FileFormat> formatList;
return formatList;
}
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> U3DIOPlugin::exportFormats() const
QList<FileFormat> U3DIOPlugin::exportFormats() const
{
QList<Format> formatList;
formatList << Format("U3D File Format" ,tr("U3D"));
formatList << Format("IDTF File Format" ,tr("IDTF"));
QList<FileFormat> formatList;
formatList << FileFormat("U3D File Format" ,tr("U3D"));
formatList << FileFormat("IDTF File Format" ,tr("IDTF"));
return formatList;
}

View File

@ -41,8 +41,8 @@ class U3DIOPlugin : public QObject, public IOMeshPluginInterface
public:
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
U3DIOPlugin();

View File

@ -35,7 +35,7 @@
using namespace std;
using namespace vcg;
bool IoX3DPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList &, CallBackPos *cb, QWidget *parent)
bool IoX3DPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList &, CallBackPos *cb, QWidget */*parent*/)
{
// initializing mask
mask = 0;
@ -56,7 +56,7 @@ bool IoX3DPlugin::open(const QString &formatName, const QString &fileName, MeshM
result = vcg::tri::io::ImporterX3D<CMeshO>::LoadMaskVrml(filename.c_str(), info);
if ( result != vcg::tri::io::ImporterX3D<CMeshO>::E_NOERROR)
{
QMessageBox::critical(parent, tr("X3D Opening Error"), errorMsgFormat.arg(fileName, info->filenameStack[info->filenameStack.size()-1], vcg::tri::io::ImporterX3D<CMeshO>::ErrorMsg(result)));
errorMessage = errorMsgFormat.arg(fileName, info->filenameStack[info->filenameStack.size()-1], vcg::tri::io::ImporterX3D<CMeshO>::ErrorMsg(result));
delete info;
return false;
}
@ -78,14 +78,14 @@ bool IoX3DPlugin::open(const QString &formatName, const QString &fileName, MeshM
QString fileError = info->filenameStack[info->filenameStack.size()-1];
QString lineError;
lineError.setNum(info->lineNumberError);
QMessageBox::critical(parent, tr("X3D Opening Error"), errorMsgFormat.arg(fileName, fileError, lineError, vcg::tri::io::ImporterX3D<CMeshO>::ErrorMsg(result)));
errorMessage = errorMsgFormat.arg(fileName, fileError, lineError, vcg::tri::io::ImporterX3D<CMeshO>::ErrorMsg(result));
delete info;
return false;
}
if (m.cm.vert.size() == 0)
{
errorMsgFormat = "Error encountered while loading file:\n\"%1\"\n\nError details: File without a geometry";
QMessageBox::critical(parent, tr("X3D Opening Error"), errorMsgFormat.arg(fileName));
errorMessage = errorMsgFormat.arg(fileName);
delete info;
return false;
}
@ -113,7 +113,7 @@ bool IoX3DPlugin::open(const QString &formatName, const QString &fileName, MeshM
if (someTextureNotFound)
QMessageBox::warning(parent, tr("Missing texture files"), missingTextureFilesMsg);
errorMessage = missingTextureFilesMsg;
vcg::tri::UpdateBounding<CMeshO>::Box(m.cm); // updates bounding box
if (!normalsUpdated)
@ -155,22 +155,22 @@ QString IoX3DPlugin::pluginName() const
return "IOX3D";
}
QList<IOMeshPluginInterface::Format> IoX3DPlugin::importFormats() const
QList<FileFormat> IoX3DPlugin::importFormats() const
{
QList<Format> formatList;
formatList << Format("X3D File Format - XML encoding", tr("X3D"));
formatList << Format("X3D File Format - VRML encoding", tr("X3DV"));
formatList << Format("VRML 2.0 File Format", tr("WRL"));
QList<FileFormat> formatList;
formatList << FileFormat("X3D File Format - XML encoding", tr("X3D"));
formatList << FileFormat("X3D File Format - VRML encoding", tr("X3DV"));
formatList << FileFormat("VRML 2.0 File Format", tr("WRL"));
return formatList;
}
/*
returns the list of the file's type which can be exported
*/
QList<IOMeshPluginInterface::Format> IoX3DPlugin::exportFormats() const
QList<FileFormat> IoX3DPlugin::exportFormats() const
{
QList<Format> formatList;
formatList << Format("X3D File Format", tr("X3D"));
QList<FileFormat> formatList;
formatList << FileFormat("X3D File Format", tr("X3D"));
return formatList;
}

View File

@ -46,8 +46,8 @@ class IoX3DPlugin : public QObject, public IOMeshPluginInterface
public:
QString pluginName() const;
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
QList<FileFormat> importFormats() const;
QList<FileFormat> exportFormats() const;
virtual void GetExportMaskCapability(const QString &format, int &capability, int &defaultBits) const;