source: src/WorldIterators.cpp@ cb2146

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
Last change on this file since cb2146 was 1c51c8, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added methods for querying molecules using descriptors

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * WorldIterators.cpp
3 *
4 * Created on: Feb 25, 2010
5 * Author: crueger
6 */
7
8#include "Descriptors/AtomDescriptor.hpp"
9#include "Descriptors/AtomDescriptor_impl.hpp"
10#include "Descriptors/MoleculeDescriptor.hpp"
11#include "Descriptors/MoleculeDescriptor_impl.hpp"
12#include "atom.hpp"
13#include "molecule.hpp"
14#include "World.hpp"
15
16/********************** Atoms *************************/
17
18World::AtomIterator::AtomIterator(){
19 state = World::get()->atomEnd();
20}
21
22World::AtomIterator::AtomIterator(AtomDescriptor _descr, World* _world) :
23 descr(_descr.get_impl()),
24 index(0),
25 world(_world)
26{
27 state = world->atoms.begin();
28 advanceState();
29}
30
31World::AtomIterator::AtomIterator(const AtomIterator& rhs) :
32 state(rhs.state),
33 descr(rhs.descr),
34 index(rhs.index),
35 world(rhs.world)
36 {}
37
38World::AtomIterator& World::AtomIterator::operator=(const AtomIterator& rhs)
39{
40 if(&rhs!=this){
41 state=rhs.state;
42 descr=rhs.descr;
43 index=rhs.index;
44 world=rhs.world;
45 }
46 return *this;
47}
48
49World::AtomIterator& World::AtomIterator::operator++(){
50 ++state;
51 ++index;
52 advanceState();
53 return *this;
54}
55
56World::AtomIterator World::AtomIterator::operator++(int){
57 AtomIterator res(*this);
58 ++(*this);
59 return res;
60}
61
62bool World::AtomIterator::operator==(const AtomIterator& rhs){
63 return state==rhs.state;
64}
65
66bool World::AtomIterator::operator==(const World::AtomSet::iterator& rhs){
67 return state==rhs;
68}
69
70bool World::AtomIterator::operator!=(const AtomIterator& rhs){
71 return state!=rhs.state;
72}
73
74bool World::AtomIterator::operator!=(const World::AtomSet::iterator& rhs){
75 return state!=rhs;
76}
77
78atom* World::AtomIterator::operator*(){
79 return (*state).second;
80}
81
82void World::AtomIterator::advanceState(){
83 // go forward until we have a matching atom or the end is reached
84 while((state!=world->atoms.end()) && (!descr->predicate(*state))){
85 ++state;
86 ++index;
87 }
88}
89
90int World::AtomIterator::getCount(){
91 return index;
92}
93
94/*********************************** Molecules ************************/
95
96World::MoleculeIterator::MoleculeIterator(){
97 state = World::get()->moleculeEnd();
98}
99
100World::MoleculeIterator::MoleculeIterator(MoleculeDescriptor _descr, World* _world) :
101 descr(_descr.get_impl()),
102 index(0),
103 world(_world)
104{
105 state = world->molecules.begin();
106 advanceState();
107}
108
109World::MoleculeIterator::MoleculeIterator(const MoleculeIterator& rhs) :
110 state(rhs.state),
111 descr(rhs.descr),
112 index(rhs.index),
113 world(rhs.world)
114 {}
115
116World::MoleculeIterator& World::MoleculeIterator::operator=(const MoleculeIterator& rhs)
117{
118 if(&rhs!=this){
119 state=rhs.state;
120 descr=rhs.descr;
121 index=rhs.index;
122 world=rhs.world;
123 }
124 return *this;
125}
126
127World::MoleculeIterator& World::MoleculeIterator::operator++(){
128 ++state;
129 ++index;
130 advanceState();
131 return *this;
132}
133
134World::MoleculeIterator World::MoleculeIterator::operator++(int){
135 MoleculeIterator res(*this);
136 ++(*this);
137 return res;
138}
139
140bool World::MoleculeIterator::operator==(const MoleculeIterator& rhs){
141 return state==rhs.state;
142}
143
144bool World::MoleculeIterator::operator==(const World::MoleculeSet::iterator& rhs){
145 return state==rhs;
146}
147
148bool World::MoleculeIterator::operator!=(const MoleculeIterator& rhs){
149 return state!=rhs.state;
150}
151
152bool World::MoleculeIterator::operator!=(const World::MoleculeSet::iterator& rhs){
153 return state!=rhs;
154}
155
156molecule* World::MoleculeIterator::operator*(){
157 return (*state).second;
158}
159
160void World::MoleculeIterator::advanceState(){
161 while((state!=world->molecules.end()) && (!descr->predicate(*state))){
162 ++state;
163 ++index;
164 }
165}
166
167int World::MoleculeIterator::getCount(){
168 return index;
169}
170
Note: See TracBrowser for help on using the repository browser.