- Timestamp:
- Feb 3, 2011, 9:51:18 AM (14 years ago)
- 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:
- d6f886
- Parents:
- 0b15bb
- git-author:
- Frederik Heber <heber@…> (12/30/10 20:52:17)
- git-committer:
- Frederik Heber <heber@…> (02/03/11 09:51:18)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp
r0b15bb r66fd49 28 28 #include "World.hpp" 29 29 30 #include "Descriptors/MoleculeIdDescriptor.hpp" 30 31 #include "Parser/MpqcParser.hpp" 31 32 #include "Parser/PcpParser.hpp" … … 35 36 #include "Parser/FormatParserStorage.hpp" 36 37 38 #include <algorithm> 37 39 #include <iostream> 38 40 #include <string> … … 47 49 /** =========== define the function ====================== */ 48 50 Action::state_ptr MoleculeFillVoidWithMoleculeAction::performCall() { 49 50 51 // obtain information 51 52 getParametersfromValueStorage(); 52 53 53 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << params.lengths[0] << "," << params.lengths[1] << "," << params.lengths[2] << "), distances (" << params.distances[0] << "," << params.distances[1] << "," << params.distances[2] << "), DoRotate " << params.DoRotate << "." << endl); 54 if (!boost::filesystem::exists(params.fillername)) { 55 DoeLog(1) && (eLog() << Verbose(1) << "File with filler molecule " << params.fillername << " does not exist!" << endl); 56 return Action::failure; 57 } 58 59 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << params.lengths[0] << "," << params.lengths[1] << "," << params.lengths[2] << "), distances (" << params.distances[0] << "," << params.distances[1] << "," << params.distances[2] << "), MinDistance " << params.MinDistance << ", DoRotate " << params.DoRotate << "." << endl); 54 60 // construct water molecule 55 molecule *filler = World::getInstance().createMolecule(); 61 std::vector<molecule *> presentmolecules = World::getInstance().getAllMolecules(); 62 // DoLog(0) && (Log() << Verbose(0) << presentmolecules.size() << " molecules initially are present." << std::endl); 56 63 std::string FilenameSuffix = params.fillername.string().substr(params.fillername.string().find_last_of('.')+1, params.fillername.string().length()); 57 64 ifstream input; … … 92 99 break; 93 100 } 94 World::MoleculeIterator iter = World::getInstance().getMoleculeIter(); 95 for (; iter != World::getInstance().moleculeEnd(); ++iter) 101 102 // search the filler molecule that has been just parsed 103 molecule *filler = NULL; 104 for (World::MoleculeIterator iter = World::getInstance().getMoleculeIter(); 105 iter != World::getInstance().moleculeEnd(); 106 ++iter) 96 107 filler = *iter; // get last molecule 97 108 filler->SetNameFromFilename(params.fillername.string().c_str()); … … 102 113 for (int i=0;i<NDIM;i++) 103 114 distance[i] = params.distances[i]; 104 FillVoidWithMolecule(filler, *(World::getInstance().getConfig()), distance, params.lengths[0], params.lengths[1], params.lengths[2], params. DoRotate);115 FillVoidWithMolecule(filler, *(World::getInstance().getConfig()), distance, params.lengths[0], params.lengths[1], params.lengths[2], params.MinDistance, params.DoRotate); 105 116 106 return Action::success; 117 // generate list of newly created molecules 118 // (we can in general remove more quickly from a list than a vector) 119 std::vector<molecule *> fillermolecules = World::getInstance().getAllMolecules(); 120 // DoLog(0) && (Log() << Verbose(0) << fillermolecules.size() << " molecules are present." << std::endl); 121 std::list<molecule *> fillermolecules_list; 122 std::copy( fillermolecules.begin(), fillermolecules.end(), std::back_inserter( fillermolecules_list )); 123 // DoLog(0) && (Log() << Verbose(0) << fillermolecules_list.size() << " molecules have been copied." << std::endl); 124 for (std::vector<molecule *>::const_iterator iter = presentmolecules.begin(); 125 iter != presentmolecules.end(); 126 ++iter) { 127 fillermolecules_list.remove(*iter); 128 } 129 // DoLog(0) && (Log() << Verbose(0) << fillermolecules_list.size() << " molecules left after removal." << std::endl); 130 fillermolecules.clear(); 131 std::copy(fillermolecules_list.begin(), fillermolecules_list.end(), std::back_inserter( fillermolecules )); 132 133 // DoLog(0) && (Log() << Verbose(0) << fillermolecules.size() << " molecules have been inserted." << std::endl); 134 135 return Action::state_ptr(new MoleculeFillVoidWithMoleculeState(fillermolecules,params)); 107 136 } 108 137 109 138 Action::state_ptr MoleculeFillVoidWithMoleculeAction::performUndo(Action::state_ptr _state) { 110 //MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());139 MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get()); 111 140 112 // string newName = state->mol->getName(); 113 // state->mol->setName(state->lastName); 141 MoleculeListClass *MolList = World::getInstance().getMolecules(); 114 142 115 return Action::failure; 143 BOOST_FOREACH(molecule *_mol, state->fillermolecules) { 144 MolList->erase(_mol); 145 if ((_mol != NULL) && (!(World::getInstance().getAllMolecules(MoleculeById(_mol->getId()))).empty())) { 146 for(molecule::iterator iter = _mol->begin(); 147 !_mol->empty(); 148 iter = _mol->begin()) { 149 atom *Walker = *iter; 150 _mol->erase(iter); 151 World::getInstance().destroyAtom(Walker); 152 } 153 World::getInstance().destroyMolecule(_mol); 154 } 155 } 156 157 // as molecules and atoms from state are removed, we have to create a new one 158 std::vector<molecule *> fillermolecules; 159 return Action::state_ptr(new MoleculeFillVoidWithMoleculeState(fillermolecules,state->params)); 116 160 } 117 161 118 162 Action::state_ptr MoleculeFillVoidWithMoleculeAction::performRedo(Action::state_ptr _state){ 119 // Undo and redo have to do the same for this action 120 return performUndo(_state); 163 //MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get()); 164 165 return Action::failure; 166 //return Action::state_ptr(_state); 121 167 } 122 168 123 169 bool MoleculeFillVoidWithMoleculeAction::canUndo() { 124 return false;170 return true; 125 171 } 126 172 127 173 bool MoleculeFillVoidWithMoleculeAction::shouldUndo() { 128 return false;174 return true; 129 175 } 130 176 /** =========== end of function ====================== */
Note:
See TracChangeset
for help on using the changeset viewer.