10 #include "makeontargetchange.h"
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wunused-parameter"
26 int main(
int argc,
char *argv[])
28 int main_rsvs3d(
int argc,
char *argv[])
34 return RSVSExecution(argc, argv);
35 #elif defined(TEST_ALL)
36 return rsvstest::maintest();
37 #elif defined(TEST_SHORT)
38 return rsvstest::shorttest();
40 return rsvstest::newtest();
43 #pragma GCC diagnostic pop
45 int RSVSExecution(
int argc,
char *argv[])
50 if (parseOut.execFlow > 0)
53 RSVSobj.paramconf = paramconf;
54 if (parseOut.execFlow == 1)
56 integrate::execute::All(RSVSobj);
58 else if (parseOut.execFlow == 2)
60 integrate::execute::Interactive(RSVSobj);
67 else if (parseOut.execFlow == -3)
71 ExecuteTests(parseOut);
73 RSVS3D_ERROR(
"Tests not compiled; use `make all` to produce an executable"
74 "with tests;\n or `make notest` for an executable without");
80 NoExecution(parseOut, paramconf);
89 #ifndef RSVS_HIDETESTS
90 if (parseOut.testCase.compare(
"all") == 0)
92 testNum = rsvstest::maintest();
94 else if (parseOut.testCase.compare(
"short") == 0)
96 testNum = rsvstest::shorttest();
98 else if (parseOut.testCase.compare(
"new") == 0)
100 testNum = rsvstest::newtest();
104 std::stringstream errStr;
105 errStr <<
"The test case '" << parseOut.testCase <<
"'is not known, valid options are:" << std::endl
106 <<
"'all', 'short', or 'new'.";
116 if (parseOut.execFlow == -2)
118 parseOut.paramFileOut =
"failexec_rsvsconfig.json";
121 param::io::writeflat(parseOut.paramFileOut +
"flat", paramconf);
122 param::io::write(parseOut.paramFileOut, paramconf);
124 if (parseOut.execFlow == -2)
126 std::cerr <<
"Error while parsing the arguments. Check generated '" << parseOut.paramFileOut <<
"' file";
146 parseOut.execFlow = 0;
147 std::vector<std::string> triggerExec, configParam, configFiles, configPredef, noexecStr, testString;
149 triggerExec = {
"use-config",
"load-config",
"param"};
151 std::string strDescription;
152 strDescription =
"\nProgram for the execution of the Restricted-Surface";
153 strDescription +=
" Volume of Solid in 3D";
154 cxxopts::Options options(argv[0], strDescription);
155 options.positional_help(
"[optional args]").show_positional_help();
157 options.add_options(
"")(
"h,help",
"Print help");
159 options.add_options(
"Parameter configuration")
160 (
"u,use-config",
"Use one of the predefined configurations stored in the code.", cxxopts::value(configPredef),
"STRING")
161 (
"l,load-config",std::string(
"Load configuration file in JSON format to set parameter "
162 "structure. Multiple files can be specified and will be processed"
163 " in order of appearance."),cxxopts::value(configFiles),
"FILES")
164 (
"p,param",
"Define a parameter manually on the command line."
165 " The format must be a flat key into the JSON configuration:"
166 " (e.g.: '/snak/maxsteps:50' will set 'param.snak.maxsteps=50')",
167 cxxopts::value(configParam),
169 (
"default-config",
"Output the default configuration to a file.",
170 cxxopts::value<std::string>()->implicit_value(
"default_config"),
"FILE");
172 options.add_options(
"Execution control")
173 (
"n,noexec", std::string(
"Do not execute RSVS process, will only parse the inputs and output "
174 "the resulting configuration file to 'arg'"),
175 cxxopts::value(noexecStr)->implicit_value(
"./noexec_config.json"),
"STRING")
176 (
"e,exec",
"Execute RSVS. With no command line argument the program does nothing.")
177 (
"i,interactive",
"Execute the RSVS in interactive mode using polyscope")
178 (
"no-gui",
"Disable all GUI calls and OpenGL functionality.")
179 #ifndef RSVS_HIDETESTS
180 (
"test", std::string(
"Executes specified tests. requires compilation without flag RSVS_NOTESTS."),
181 cxxopts::value(testString)->implicit_value(
"short"),
"STRING")
185 auto result = options.parse(argc, argv);
187 if (result.count(
"help"))
189 std::cout << options.help({
"",
"Execution control",
"Parameter configuration"}) << std::endl;
193 if (result.count(
"noexec") > 0 && result.count(
"exec") > 0)
195 std::cerr << std::endl <<
" Invalid specification of -e (exec) and -n (noexec)";
196 std::cerr <<
" on the command line." << std::endl;
197 std::cerr <<
" see --help for more info" << std::endl;
200 else if ((result.count(
"exec") || result.count(
"interactive")) && result.count(
"test"))
202 std::cerr << std::endl <<
" Invalid specification of -e/i (exec/interactive) and -t (test)";
203 std::cerr <<
" on the command line." << std::endl;
204 std::cerr <<
" see --help for more info" << std::endl;
207 else if (result.count(
"noexec") && result.count(
"test"))
209 std::cerr << std::endl <<
" Invalid specification of -n (noexec) and -t (test)";
210 std::cerr <<
" on the command line." << std::endl;
211 std::cerr <<
" see --help for more info" << std::endl;
214 else if (result.count(
"interactive"))
216 parseOut.execFlow = 2;
218 else if (result.count(
"exec"))
220 parseOut.execFlow = 1;
222 else if (result.count(
"test"))
224 parseOut.execFlow = -3;
225 for (
auto testCase : testString)
227 parseOut.testCase = testCase;
228 std::cout << parseOut.testCase <<
" " << testCase << std::endl;
231 else if (result.count(
"noexec"))
233 parseOut.execFlow = -1;
234 for (
auto confCase : noexecStr)
236 parseOut.paramFileOut = confCase;
239 std::cout << parseOut.paramFileOut << std::endl;
241 if (result.count(
"no-gui"))
243 parseOut.isHeadless =
true;
248 if (parseOut.execFlow == 0)
250 for (
auto i : triggerExec)
254 parseOut.execFlow = 1;
260 if (result.count(
"use-config"))
262 for (
auto confCase : configPredef)
264 parse::config::useconfig(confCase, paramconf);
267 if (result.count(
"load-config"))
269 for (
auto confCase : configFiles)
271 parse::config::loadconfig(confCase, paramconf);
274 if (result.count(
"param"))
276 if (param::io::updatefromstring(configParam, paramconf) > 0)
278 parseOut.execFlow = -2;
285 #pragma GCC diagnostic push
286 #pragma GCC diagnostic ignored "-Wunused-parameter"
287 void parse::config::useconfig(
const std::string &confCase,
param::parameters ¶mconf)
289 std::cerr <<
"No predefined cases yet." << std::endl;
291 #pragma GCC diagnostic pop
292 void parse::config::loadconfig(
const std::string &confCase,
param::parameters ¶mconf)
294 param::io::read(confCase, paramconf);
299 int argc = commands.size();
301 argv =
new char *[argc];
302 for (
int i = 0; i < argc; ++i)
304 argv[i] =
new char[commands[i].length() + 1];
305 strcpy(argv[i], commands[i].c_str());
310 for (
int i = 0; i < argc; ++i)
Simple class containing all the information needed for the 3D-RSVS execution.
Integration into the full 3 dimensional Restricted Snake Volume of Solid method.
Root class for all the parameters.
file containing the main functions and the command line parser.
ParserOutput CommandLineParser(int argc, char *argv[], param::parameters ¶mconf)
Takes in the command line arguments and returns an integer specifying the execution flow of the rest ...
bool TEST_HEADLESS
Boolean controlling wether tests are run in headless mode or not.
Parameters for the integrated 3DRSVS.
Provides the custom testing system used by the RSVS3D project.
#define RSVS3D_ERROR(M)
Throw generic rsvs errors.
#define RSVS3D_ERROR_ARGUMENT(M)
Throw a invalid_argument.