Commit 6751e826b1e39524dc710404eefa46d30e0bb73b

Authored by David Mayerich
1 parent 70c0b942

fixed 'index out of range' error if a file isn't provided

Showing 1 changed file with 9 additions and 5 deletions   Show diff stats
@@ -844,7 +844,7 @@ int main(int argc, char* argv[]) { @@ -844,7 +844,7 @@ int main(int argc, char* argv[]) {
844 844
845 // add arguments 845 // add arguments
846 args.add("help", "prints the help"); 846 args.add("help", "prints the help");
847 - args.add("network", "load network from .obj or .swc file"); 847 + //args.add("network", "load network from .obj or .swc file");
848 args.add("maxpress", "maximum allowed pressure in g / units / s^2, default 2 is for blood when units = um", "2", "real value > 0"); 848 args.add("maxpress", "maximum allowed pressure in g / units / s^2, default 2 is for blood when units = um", "2", "real value > 0");
849 args.add("viscosity", "set the viscosity of the fluid (in g / units / s), default .00001 is for blood when units = um", ".00001", "real value > 0"); 849 args.add("viscosity", "set the viscosity of the fluid (in g / units / s), default .00001 is for blood when units = um", ".00001", "real value > 0");
850 args.add("rou", "set the desity of the fluid (in g / units^3), default 1.06*10^-12 is for blood when units = um", ".00000000000106", "real value > 0"); 850 args.add("rou", "set the desity of the fluid (in g / units^3), default 1.06*10^-12 is for blood when units = um", ".00000000000106", "real value > 0");
@@ -860,12 +860,16 @@ int main(int argc, char* argv[]) { @@ -860,12 +860,16 @@ int main(int argc, char* argv[]) {
860 } 860 }
861 861
862 // load network 862 // load network
863 - if (args["network"].is_set()) { // load network from user  
864 - std::vector<std::string> tmp = stim::parser::split(args["network"].as_string(), '.'); 863 + if (args.nargs() == 0) {
  864 + std::cout << "Network file required." << std::endl;
  865 + return 1;
  866 + }
  867 + else { // load network from user
  868 + std::vector<std::string> tmp = stim::parser::split(args.arg(0), '.');
865 if ("obj" == tmp[1]) 869 if ("obj" == tmp[1])
866 - flow.load_obj(args["network"].as_string()); 870 + flow.load_obj(args.arg(0));
867 else if ("swc" == tmp[1]) 871 else if ("swc" == tmp[1])
868 - flow.load_swc(args["network"].as_string()); 872 + flow.load_swc(args.arg(0));
869 else { 873 else {
870 std::cout << "Invalid file type" << std::endl; 874 std::cout << "Invalid file type" << std::endl;
871 std::exit(1); 875 std::exit(1);