From 8ea295d8a5a5e998810973d4301f7bde86ed1a8b Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Sun, 10 Feb 2008 15:22:57 +0000 Subject: [PATCH] slightly revised the way of parameter passing --- src/meshlabserver/mainserver.cpp | 86 +++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/src/meshlabserver/mainserver.cpp b/src/meshlabserver/mainserver.cpp index f52a4aeb4..1e8ac3607 100644 --- a/src/meshlabserver/mainserver.cpp +++ b/src/meshlabserver/mainserver.cpp @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.8 2008/02/10 15:22:57 cignoni +slightly revised the way of parameter passing + Revision 1.7 2008/01/22 14:18:27 sherholz Added support for .mlx filter scripts @@ -64,8 +67,14 @@ Added copyright info QMap filterMap; // a map to retrieve an action from a name. Used for playing filter scripts. std::vector meshIOPlugins; +// Here we need a better way to find the plugins directory. +// To be implemented: +// use the QSettings togheter with MeshLab. +// When meshlab starts if he find the plugins write the absolute path of that directory in a persistent qsetting place. +// Here we use that QSetting. If it is not set we remember to run meshlab first once. +// in this way it works safely on mac too and allows the user to put the small meshlabserver binary wherever they desire (/usr/local/bin). -void loadPlugins() +void loadPlugins(FILE *fp=0) { QDir pluginsDir = QDir(qApp->applicationDirPath()); #if defined(Q_OS_WIN) @@ -85,21 +94,19 @@ void loadPlugins() QObject *plugin = loader.instance(); if (plugin) { - //MeshColorizeInterface *iColor = qobject_cast(plugin); - MeshFilterInterface *iFilter = qobject_cast(plugin); if (iFilter){ - QAction *filterAction; foreach(filterAction, iFilter->actions()) - filterMap[filterAction->text()]=filterAction; + { + filterMap[filterAction->text()]=filterAction; + //if(fp) + printf( "*'''%s''': %s\n",qPrintable(filterAction->text()), qPrintable(iFilter->filterInfo(filterAction))); + } printf("Loaded %i filtering actions form %s\n",filterMap.size(),qPrintable(fileName)); } MeshIOInterface *iIO = qobject_cast(plugin); if (iIO) meshIOPlugins.push_back(iIO); - - -// pluginfileNames += fileName; } } printf("Total %i filtering actions\n",filterMap.size()); @@ -143,7 +150,6 @@ bool Open(MeshModel &mm, QString fileName) return true; } /* - sintassi meshlab -i mesh -o mesh -f filtro @@ -215,8 +221,24 @@ bool Script(MeshModel& mm, QString scriptfile){ } - - +} + +void Usage() +{ + printf( + "\nUsage:\n" + " meshlabserver arg1 arg2 ... \n" + "where args can be: \n" + " -i filename mesh that has to be loaded\n" + " -o filename mesh where to write the result\n" + " -s filename script to be applied\n" + "\nNotes:\n\n" + "There must be exactly one input mesh and at most one output mesh.\n" + "Script is optional and must be in the format saved by MeshLab.\n" + "The format of the output mesh is guessed by the used extension.\n" + ); + exit(-1); + } int main(int argc, char *argv[]) @@ -224,20 +246,36 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); loadPlugins(); MeshModel mm; - if(argc==3) + QString meshNameIn,meshNameOut,scriptName; + if(argc<3) Usage(); + int i=1; + while(i