Ignore:
Timestamp:
Jul 6, 2010, 3:50:04 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
192f6e
Parents:
62c3dde
Message:

changed validate() for VectorValue, parsing not 10. 10. 10. but "10., 10., 10." to allow for negative values.

  • i.e. we now parse a single string and tokenize it ourselves.
  • TESTFIX: alle test cases asking the user for vectors had to be changed accordingly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MapOfActions.cpp

    r62c3dde rb540f3  
    7171{
    7272  VectorValue VV;
    73   if (values.size() != 3) {
    74     cerr <<  "Specified vector does not have three components but " << values.size() << endl;
     73  std::vector<std::string> components;
     74
     75  // split comma-separated values
     76  if (values.size() != 1) {
     77    cerr <<  "Not one vector but " << components.size() << " given " << endl;
     78    throw boost::program_options::validation_error("Unequal to one vector given");
     79  }
     80  std::string argument(values.at(0));
     81  std::string::iterator Aiter = argument.begin();
     82  std::string::iterator Biter = argument.begin();
     83  for (; Aiter != argument.end(); ++Aiter) {
     84    if (*Aiter == ',') {
     85      components.push_back(string(Biter,Aiter));
     86      do {
     87        Aiter++;
     88      } while (*Aiter == ' ' || *Aiter == '\t');
     89      Biter = Aiter;
     90    }
     91  }
     92  components.push_back(string(Biter,argument.end()));
     93
     94  if (components.size() != 3) {
     95    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
    7596    throw boost::program_options::validation_error("Specified vector does not have three components");
    7697  }
    77   VV.x = boost::lexical_cast<double>(values.at(0));
    78   VV.y = boost::lexical_cast<double>(values.at(1));
    79   VV.z = boost::lexical_cast<double>(values.at(2));
     98  VV.x = boost::lexical_cast<double>(components.at(0));
     99  VV.y = boost::lexical_cast<double>(components.at(1));
     100  VV.z = boost::lexical_cast<double>(components.at(2));
    80101  v = boost::any(VectorValue(VV));
    81102}
     
    84105{
    85106  BoxValue BV;
    86   if (values.size() != 6) {
    87     cerr <<  "Specified vector does not have three components but " << values.size() << endl;
     107  std::vector<std::string> components;
     108
     109  // split comma-separated values
     110  if (values.size() != 1) {
     111    cerr <<  "Not one vector but " << components.size() << " given " << endl;
     112    throw boost::program_options::validation_error("Unequal to one vector given");
     113  }
     114  std::string argument(values.at(0));
     115  std::string::iterator Aiter = argument.begin();
     116  std::string::iterator Biter = argument.begin();
     117  for (; Aiter != argument.end(); ++Aiter) {
     118    if (*Aiter == ',') {
     119      components.push_back(string(Biter,Aiter));
     120      do {
     121        Aiter++;
     122      } while (*Aiter == ' ' || *Aiter == '\t');
     123      Biter = Aiter;
     124    }
     125  }
     126  components.push_back(string(Biter,argument.end()));
     127
     128  if (components.size() != 6) {
     129    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
    88130    throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
    89131  }
    90   BV.xx = boost::lexical_cast<double>(values.at(0));
    91   BV.xy = boost::lexical_cast<double>(values.at(1));
    92   BV.xz = boost::lexical_cast<double>(values.at(2));
    93   BV.yy = boost::lexical_cast<double>(values.at(3));
    94   BV.yz = boost::lexical_cast<double>(values.at(4));
    95   BV.zz = boost::lexical_cast<double>(values.at(5));
     132  BV.xx = boost::lexical_cast<double>(components.at(0));
     133  BV.xy = boost::lexical_cast<double>(components.at(1));
     134  BV.xz = boost::lexical_cast<double>(components.at(2));
     135  BV.yy = boost::lexical_cast<double>(components.at(3));
     136  BV.yz = boost::lexical_cast<double>(components.at(4));
     137  BV.zz = boost::lexical_cast<double>(components.at(5));
    96138  v = boost::any(BoxValue(BV));
    97139}
     
    587629            ListRunner->second->add_options()
    588630              (getKeyAndShortForm(*OptionRunner).c_str(),
    589                   po::value<VectorValue>()->multitoken(),
     631                  po::value<VectorValue>(),
    590632                  getDescription(*OptionRunner).c_str())
    591633              ;
Note: See TracChangeset for help on using the changeset viewer.