Changeset 80ca29 for src/Actions/FillAction/FillRegularGridAction.cpp
- Timestamp:
- Apr 6, 2012, 11:44:51 AM (13 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:
- 531f27
- Parents:
- 72e4c95
- git-author:
- Frederik Heber <heber@…> (04/05/12 15:42:12)
- git-committer:
- Frederik Heber <heber@…> (04/06/12 11:44:51)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FillAction/FillRegularGridAction.cpp
r72e4c95 r80ca29 24 24 #include "Atom/AtomicInfo.hpp" 25 25 #include "Atom/CopyAtoms/CopyAtoms_withBonds.hpp" 26 #include "Bond/BondInfo.hpp" 26 27 #include "CodePatterns/Log.hpp" 27 28 #include "Descriptors/MoleculeOrderDescriptor.hpp" … … 67 68 getParametersfromValueStorage(); 68 69 69 // get the filler molecule and move to origin 70 // get the filler molecule 71 std::vector<AtomicInfo> movedatoms; 70 72 const std::vector< molecule *> molecules = World::getInstance().getSelectedMolecules(); 71 73 if (molecules.size() != 1) { … … 74 76 } 75 77 molecule *filler = *(molecules.begin()); 78 for(molecule::const_iterator iter = filler->begin(); iter != filler->end(); ++iter) 79 movedatoms.push_back( AtomicInfo(*(*iter)) ); 76 80 LOG(1, "INFO: Chosen molecule has " << filler->size() << " atoms."); 77 81 … … 82 86 Tesselation * TesselStruct = NULL; 83 87 if (params.SphereRadius != 0.) { 84 if ( molecules.size() == 0) {88 if ( atoms.size() == 0) { 85 89 ELOG(1, "You have given a sphere radius " << params.SphereRadius 86 90 << " != 0, but have not select any molecules."); 91 return Action::failure; 87 92 } 88 93 // create adaptor for the selected atoms … … 99 104 100 105 // create predicate, mesh, and filler 101 std::vector<AtomicInfo> clonedatoms;106 FillRegularGridState *UndoState = NULL; 102 107 bool successflag = false; 103 108 { … … 129 134 delete fillerFunction; 130 135 131 // append each cluster's atoms to clonedatoms 136 // append each cluster's atoms to clonedatoms (however not selected ones) 137 std::vector<const atom *> clonedatoms; 138 std::vector<AtomicInfo> clonedatominfos; 132 139 for (Filler::ClusterVector_t::const_iterator iter = ClonedClusters.begin(); 133 140 iter != ClonedClusters.end(); ++iter) { … … 135 142 clonedatoms.reserve(clonedatoms.size()+atoms.size()); 136 143 for (AtomIdSet::const_iterator atomiter = atoms.begin(); atomiter != atoms.end(); ++atomiter) 137 clonedatoms.push_back( AtomicInfo(*(*atomiter)) ); 144 if (!filler->containsAtom(*atomiter)) { 145 clonedatoms.push_back( *atomiter ); 146 clonedatominfos.push_back( AtomicInfo(*(*atomiter)) ); 147 } 138 148 } 149 std::vector< BondInfo > clonedbonds; 150 StoreBondInformationFromAtoms(clonedatoms, clonedbonds); 151 LOG(2, "DEBUG: There are " << clonedatominfos.size() << " newly created atoms."); 152 139 153 if (!successflag) { 140 ELOG(1, "Insertion failed, removing inserted clusters again.");141 RemoveAtomsFromAtomicInfo(clonedatom s);154 ELOG(1, "Insertion failed, removing inserted clusters, translating original one back"); 155 RemoveAtomsFromAtomicInfo(clonedatominfos); 142 156 clonedatoms.clear(); 157 SetAtomsFromAtomicInfo(movedatoms); 158 } else { 159 std::vector<Vector> MovedToVector(filler->size(), zeroVec); 160 std::transform(filler->begin(), filler->end(), MovedToVector.begin(), 161 boost::bind(&AtomInfo::getPosition, _1) ); 162 UndoState = new FillRegularGridState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params); 143 163 } 144 164 } … … 154 174 155 175 if (successflag) 156 return Action::state_ptr( new FillRegularGridState(clonedatoms,params));176 return Action::state_ptr(UndoState); 157 177 else 158 178 return Action::failure; … … 164 184 // remove all created atoms 165 185 RemoveAtomsFromAtomicInfo(state->clonedatoms); 186 // add the original cluster 187 SetAtomsFromAtomicInfo(state->movedatoms); 166 188 167 189 return Action::state_ptr(_state); … … 171 193 FillRegularGridState *state = assert_cast<FillRegularGridState*>(_state.get()); 172 194 173 if (AddAtomsFromAtomicInfo(state->clonedatoms)) 195 // place filler cluster again at new spot 196 ResetAtomPosition(state->movedatoms, state->MovedToVector); 197 198 // re-create all clusters 199 bool statusflag = AddAtomsFromAtomicInfo(state->clonedatoms); 200 201 // re-create the bonds 202 if (statusflag) 203 AddBondsFromBondInfo(state->clonedbonds); 204 if (statusflag) 174 205 return Action::state_ptr(_state); 175 206 else
Note:
See TracChangeset
for help on using the changeset viewer.