From 76e4dce36e97d0e5703232968622ce2ba00bc536 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Thu, 10 Nov 2016 12:31:02 +0100 Subject: [PATCH] moved io gts file type into baseio and removed a now useless plugin --- src/meshlab_full.pro | 1 - src/meshlabplugins/io_base/baseio.cpp | 30 +++++- src/meshlabplugins/io_gts/io_gts.cpp | 146 -------------------------- src/meshlabplugins/io_gts/io_gts.h | 48 --------- src/meshlabplugins/io_gts/io_gts.pro | 7 -- 5 files changed, 29 insertions(+), 203 deletions(-) delete mode 100644 src/meshlabplugins/io_gts/io_gts.cpp delete mode 100644 src/meshlabplugins/io_gts/io_gts.h delete mode 100644 src/meshlabplugins/io_gts/io_gts.pro diff --git a/src/meshlab_full.pro b/src/meshlab_full.pro index fc2eaab18..50ed9016d 100644 --- a/src/meshlab_full.pro +++ b/src/meshlab_full.pro @@ -13,7 +13,6 @@ SUBDIRS = common \ meshlabplugins/io_u3d\ meshlabplugins/io_tri\ meshlabplugins/io_x3d \ - meshlabplugins/io_gts \ meshlabplugins/io_expe \ meshlabplugins/io_pdb \ plugins_experimental/io_TXT \ diff --git a/src/meshlabplugins/io_base/baseio.cpp b/src/meshlabplugins/io_base/baseio.cpp index 0307404a2..308065f44 100644 --- a/src/meshlabplugins/io_base/baseio.cpp +++ b/src/meshlabplugins/io_base/baseio.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -36,6 +37,7 @@ #include #include #include +#include #include using namespace std; @@ -219,6 +221,23 @@ bool BaseMeshIOPlugin::open(const QString &formatName, const QString &fileName, return false; } } + else if (formatName.toUpper() == tr("GTS")) + { + int loadMask; + if (!tri::io::ImporterGTS::LoadMask(filename.c_str(),loadMask)) + return false; + m.Enable(loadMask); + + tri::io::ImporterGTS::Options opt; + opt.flipFaces = true; + + int result = tri::io::ImporterGTS::Open(m.cm, filename.c_str(), mask, opt, cb); + if (result != 0) + { + errorMessage = errorMsgFormat.arg(fileName, vcg::tri::io::ImporterGTS::ErrorMsg(result)); + return false; + } + } else { assert(0); // Unknown File type @@ -331,7 +350,16 @@ bool BaseMeshIOPlugin::save(const QString &formatName,const QString &fileName, M } return true; } - + if( formatName.toUpper() == tr("GTS") ) + { + int result = vcg::tri::io::ExporterGTS::Save(m.cm,filename.c_str(),mask); + if(result!=0) + { + errorMessage = errorMsgFormat.arg(fileName, vcg::tri::io::ExporterGTS::ErrorMsg(result)); + return false; + } + return true; + } assert(0); // unknown format return false; } diff --git a/src/meshlabplugins/io_gts/io_gts.cpp b/src/meshlabplugins/io_gts/io_gts.cpp deleted file mode 100644 index 995b7c8e6..000000000 --- a/src/meshlabplugins/io_gts/io_gts.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -* MeshLab o o * -* An extendible mesh processor o o * -* _ O _ * -* Copyright(C) 2005, 2006 \/)\/ * -* Visual Computing Lab /\/| * -* ISTI - Italian National Research Council | * -* \ * -* All rights reserved. * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * -* for more details. * -* * -****************************************************************************/ - -#include - -#include "io_gts.h" - -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace vcg; - - -// initialize importing parameters -// void GtsIOPlugin::initPreOpenParameter(const QString &formatName, const QString &filename, RichParameterSet &parlst) -// { -// parlst.addBool("pointsonly",false,"Keep only points","Just import points, without triangulation"); -// parlst.addBool("flipfaces",false,"Flip all faces","Flip the orientation of all the triangles"); -// } - - -bool GtsIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet & /*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 normalsUpdated = false; - - if (formatName.toUpper() == tr("GTS")) - { - int loadMask; - if (!vcg::tri::io::ImporterGTS::LoadMask(filename.c_str(),loadMask)) - return false; - m.Enable(loadMask); - - vcg::tri::io::ImporterGTS::Options opt; - opt.flipFaces = true; - - int result = vcg::tri::io::ImporterGTS::Open(m.cm, filename.c_str(), mask, opt, cb); - if (result != 0) - { - QMessageBox::warning(parent, tr("GTS Opening Error"), - errorMsgFormat.arg(fileName, vcg::tri::io::ImporterGTS::ErrorMsg(result))); - return false; - } - - CMeshO::FaceIterator fi = m.cm.face.begin(); - for (; fi != m.cm.face.end(); ++fi) - fi->N() = TriangleNormal(*fi).Normalize(); - } - - vcg::tri::UpdateBounding::Box(m.cm); // updates bounding box - if (!normalsUpdated) - vcg::tri::UpdateNormal::PerVertex(m.cm); // updates normals - - if (cb != NULL) - (*cb)(99, "Done"); - - return true; -} - -bool GtsIOPlugin::save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask, const RichParameterSet &, vcg::CallBackPos * /*cb*/, QWidget *parent) -{ - 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::Save(m.cm,filename.c_str(),mask); - if(result!=0) - { - QMessageBox::warning(parent, tr("Saving Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ExporterGTS::ErrorMsg(result))); - return false; - } - return true; - } - assert(0); // unknown format - return false; -} - -/* - returns the list of the file's type which can be imported -*/ -QList GtsIOPlugin::importFormats() const -{ - QList formatList; - formatList << Format("GNU Triangulated Surface" ,tr("GTS")); - return formatList; -} - -/* - returns the list of the file's type which can be exported -*/ -QList GtsIOPlugin::exportFormats() const -{ - QList formatList; - formatList << Format("GNU Triangulated Surface" ,tr("GTS")); - return formatList; -} - -/* - returns the mask on the basis of the file's type. - otherwise it returns 0 if the file format is unknown -*/ -void GtsIOPlugin::GetExportMaskCapability(QString &format, int &capability, int &defaultBits) const -{ - if(format.toUpper() == tr("GTS")){capability=defaultBits= vcg::tri::io::ExporterGTS::GetExportMaskCapability();} - return; -} - -MESHLAB_PLUGIN_NAME_EXPORTER(GtsIOPlugin) diff --git a/src/meshlabplugins/io_gts/io_gts.h b/src/meshlabplugins/io_gts/io_gts.h deleted file mode 100644 index bebc546af..000000000 --- a/src/meshlabplugins/io_gts/io_gts.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -* MeshLab o o * -* A versatile mesh processing toolbox o o * -* _ O _ * -* Copyright(C) 2005 \/)\/ * -* Visual Computing Lab /\/| * -* ISTI - Italian National Research Council | * -* \ * -* All rights reserved. * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * -* for more details. * -* * -****************************************************************************/ - -#ifndef IO_GTS_PLUGIN_H -#define IO_GTS_PLUGIN_H - -#include - -#include - -class GtsIOPlugin : public QObject, public MeshIOInterface -{ - Q_OBJECT - MESHLAB_PLUGIN_IID_EXPORTER(MESH_IO_INTERFACE_IID) - Q_INTERFACES(MeshIOInterface) - - -public: - QList importFormats() const; - QList exportFormats() const; - - virtual void GetExportMaskCapability(QString &format, int &capability, int &defaultBits) const; -// void initPreOpenParameter(const QString &/*format*/, const QString &/*fileName*/, RichParameterSet & /*par*/); - bool open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet &, vcg::CallBackPos *cb=0, QWidget *parent=0); - bool save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask, const RichParameterSet &, vcg::CallBackPos *cb, QWidget *parent); -}; - -#endif diff --git a/src/meshlabplugins/io_gts/io_gts.pro b/src/meshlabplugins/io_gts/io_gts.pro deleted file mode 100644 index bdca72b04..000000000 --- a/src/meshlabplugins/io_gts/io_gts.pro +++ /dev/null @@ -1,7 +0,0 @@ -include (../../shared.pri) - -HEADERS += io_gts.h - -SOURCES += io_gts.cpp - -TARGET = io_gts