Changeset 4e855e for src/Actions


Ignore:
Timestamp:
Feb 4, 2011, 6:56:38 PM (14 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:
febef3
Parents:
fd3788
git-author:
Frederik Heber <heber@…> (02/04/11 18:54:12)
git-committer:
Frederik Heber <heber@…> (02/04/11 18:56:38)
Message:

BondGraph::LoadBondLengthTable() now accepts istream instead of const char *.

  • This has been quite a lot of work because the matrix parsing is involved.
  • Hence, the fix is not really clean, this should get fixed as soon as we deal with the BondGraph implementation.
  • This fixes ticket #130.
Location:
src/Actions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/CommandAction/BondLengthTableAction.cpp

    rfd3788 r4e855e  
    4545  DoLog(0) && (Log() << Verbose(0) << "Using " << params.BondGraphFileName << " as bond length table." << endl);
    4646  config *configuration = World::getInstance().getConfig();
    47   if (configuration->BG == NULL) {
    48     configuration->BG = new BondGraph(configuration->GetIsAngstroem());
    49     if ((!params.BondGraphFileName.empty())
    50         && boost::filesystem::exists(params.BondGraphFileName)
    51         && (configuration->BG->LoadBondLengthTable(params.BondGraphFileName.string()))) {
    52       DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    53       return Action::success;
     47  BondGraph *OldBG;
     48  if (configuration->BG != NULL) {
     49    OldBG = configuration->BG;
     50    DoLog(0) && (Log() << Verbose(0) << "There is a bond length table already present." << endl);
     51  }
     52  configuration->BG = new BondGraph(configuration->GetIsAngstroem());
     53  if ((!params.BondGraphFileName.empty())
     54      && boost::filesystem::exists(params.BondGraphFileName)) {
     55    std::ifstream input(params.BondGraphFileName.string().c_str());
     56    if ((input.good()) && (configuration->BG->LoadBondLengthTable(input))) {
     57      DoLog(0) && (Log() << Verbose(0) << "Bond length table parsed successfully." << endl);
     58      input.close();
     59      return Action::state_ptr(new CommandBondLengthTableState(*OldBG, params));
    5460    } else {
    55       DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
     61      DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table parsing failed." << endl);
     62      input.close();
     63      configuration->BG = new BondGraph(*OldBG);
    5664      return Action::failure;
    5765    }
    5866  } else {
    59     DoLog(0) && (Log() << Verbose(0) << "Bond length table already present." << endl);
     67    DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
     68    configuration->BG = new BondGraph(*OldBG);
    6069    return Action::failure;
    6170  }
     
    6372
    6473Action::state_ptr CommandBondLengthTableAction::performUndo(Action::state_ptr _state) {
    65 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     74  CommandBondLengthTableState *state = assert_cast<CommandBondLengthTableState*>(_state.get());
    6675
    67   return Action::failure;
    68 //  string newName = state->mol->getName();
    69 //  state->mol->setName(state->lastName);
    70 //
    71 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     76  config *configuration = World::getInstance().getConfig();
     77  BondGraph *OldBG = new BondGraph(*configuration->BG);
     78  configuration->BG = new BondGraph(state->OldBG);
     79
     80  return Action::state_ptr(new CommandBondLengthTableState(*OldBG,params));
    7281}
    7382
    7483Action::state_ptr CommandBondLengthTableAction::performRedo(Action::state_ptr _state){
    75   return Action::failure;
     84  CommandBondLengthTableState *state = assert_cast<CommandBondLengthTableState*>(_state.get());
     85
     86  config *configuration = World::getInstance().getConfig();
     87  BondGraph *OldBG = new BondGraph(*configuration->BG);
     88  configuration->BG = new BondGraph(state->OldBG);
     89
     90  return Action::state_ptr(new CommandBondLengthTableState(*OldBG,params));
    7691}
    7792
  • src/Actions/CommandAction/BondLengthTableAction.def

    rfd3788 r4e855e  
    88// all includes and forward declarations necessary for non-integral types below
    99
     10#include "bondgraph.hpp"
    1011
    1112// i.e. there is an integer with variable name Z that can be found in
     
    1819#define paramreferences (BondGraphFileName)
    1920
    20 #undef statetypes
    21 #undef statereferences
     21#define statetypes (BondGraph)
     22#define statereferences (OldBG)
    2223
    2324// some defines for all the names, you may use ACTION, STATE and PARAMS
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    rfd3788 r4e855e  
    5252  std::deque<bond *> *BackEdgeStack = NULL;
    5353  std::deque<bond *> *LocalBackEdgeStack = NULL;
    54   mol->CreateAdjacencyList(params.distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
     54  BondGraph *BG = World::getInstance().getConfig()->BG;
     55  if (BG != NULL)
     56    mol->CreateAdjacencyList(params.distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::BondLengthMatrixMinMaxDistance, BG);
     57  else
     58    mol->CreateAdjacencyList(params.distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, BG);
    5559  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    5660  if (Subgraphs != NULL) {
Note: See TracChangeset for help on using the changeset viewer.