diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 3768e666153e5ecc841b2c6829793278dc9d0a86..7f2ccf5eb68b585d9d71df02dbd979f4fa905f5e 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -553,12 +553,29 @@ void GetOptions(int argc, char *argv[]) i++; if (i + 1 < argc && argv[i][0] != '-') { gmsh_yysymbols[argv[i]].value = std::vector<double>(1, atof(argv[i + 1])); - Msg::GetCommandLineNumbers()[argv[i]] = atof(argv[i + 1]); + Msg::GetCommandLineNumbers()[argv[i]] = std::vector<double>(1, atof(argv[i + 1])); i += 2; } else Msg::Error("Missing name and/or value for number definition"); } + else if (!strcmp(argv[i]+1, "setlist") || + !strcmp(argv[i]+1, "setlistofnumbers")) { + i++; + if (i + 1 < argc && argv[i][0] != '-') { + std::string n(argv[i]); + std::vector<double> v(1, atof(argv[i + 1])); + i += 2; + while(i < argc && argv[i][0] != '-'){ + v.push_back(atof(argv[i])); + i++; + } + gmsh_yysymbols[n].value = v; + Msg::GetCommandLineNumbers()[n] = v; + } + else + Msg::Error("Missing name and/or value for definition of list of numbers"); + } #endif else if(!strcmp(argv[i] + 1, "option")) { i++; diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 2c8c2fef3ad21a2119d71623c74a6055a9794ff5..9cd7190adc0747d451d75b720ab358c38dd95c53 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -64,7 +64,7 @@ std::string Msg::_firstError; GmshMessage *Msg::_callback = 0; std::string Msg::_commandLine; std::string Msg::_launchDate; -std::map<std::string, double> Msg::_commandLineNumbers; +std::map<std::string, std::vector<double> > Msg::_commandLineNumbers; std::map<std::string, std::string> Msg::_commandLineStrings; #if !defined(HAVE_ONELAB2) GmshClient *Msg::_client = 0; diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index 802b8afaca733f8434509de43b333978b518436c..b80018b8db569935f19ea54a3c1588c59399ce89 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -48,7 +48,7 @@ class Msg { // command-line and startup time static std::string _commandLine, _launchDate; // command-line-specified numbers and strings - static std::map<std::string, double> _commandLineNumbers; + static std::map<std::string, std::vector<double> > _commandLineNumbers; static std::map<std::string, std::string> _commandLineStrings; #if !defined(HAVE_ONELAB2) // communication with Gmsh when run remotely @@ -83,7 +83,7 @@ class Msg { static int GetVerbosity(){ return _verbosity; } static std::string GetLaunchDate(){ return _launchDate; } static std::string GetCommandLineArgs(){ return _commandLine; } - static std::map<std::string, double> &GetCommandLineNumbers() + static std::map<std::string, std::vector<double> > &GetCommandLineNumbers() { return _commandLineNumbers; } diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index a1fc73ac99d5691c3c286fe10c227eebf9c26a70..8e7b16e5e38a098bbc57132eb2f3146524531675 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -674,9 +674,9 @@ void OpenProject(const std::string &fileName, bool setWindowTitle) #if defined(HAVE_PARSER) gmsh_yysymbols.clear(); gmsh_yystringsymbols.clear(); - std::map<std::string, double> cln(Msg::GetCommandLineNumbers()); - for(std::map<std::string, double>::iterator it = cln.begin(); it != cln.end(); it++) - gmsh_yysymbols[it->first].value = std::vector<double>(1, it->second); + std::map<std::string, std::vector<double> > cln(Msg::GetCommandLineNumbers()); + for(std::map<std::string, std::vector<double> >::iterator it = cln.begin(); it != cln.end(); it++) + gmsh_yysymbols[it->first].value = it->second; std::map<std::string, std::string> cls(Msg::GetCommandLineStrings()); for(std::map<std::string, std::string>::iterator it = cls.begin(); it != cls.end(); it++) gmsh_yystringsymbols[it->first] = it->second; diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp index 4ece1c08b12343ffac514f0f55f009ec2979326a..eb91af2208c20dfed02ab5ce97126526782ba9a4 100644 --- a/Common/onelabUtils.cpp +++ b/Common/onelabUtils.cpp @@ -128,9 +128,17 @@ namespace onelabUtils { // good idea?) std::ostringstream sstream; sstream.precision(16); - std::map<std::string, double> cln(Msg::GetCommandLineNumbers()); - for(std::map<std::string, double>::iterator it = cln.begin(); it != cln.end(); it++) - sstream << " -setnumber " << it->first << " " << it->second; + std::map<std::string, std::vector<double> > cln(Msg::GetCommandLineNumbers()); + for(std::map<std::string, std::vector<double> >::iterator it = cln.begin(); it != cln.end(); it++){ + if(it->second.size() == 1){ + sstream << " -setnumber " << it->first << " " << it->second[0]; + } + else{ + sstream << " -setlistofnumbers " << it->first; + for(unsigned int i = 0; i < it->second.size(); i++) + sstream << " " << it->second[i]; + } + } std::map<std::string, std::string> cls(Msg::GetCommandLineStrings()); for(std::map<std::string, std::string>::iterator it = cls.begin(); it != cls.end(); it++) sstream << " -setstring " << it->first << " " << it->second;