source: src/Descriptors/AtomDescriptor.cpp@ 47d041

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 47d041 was ad011c, checked in by Frederik Heber <heber@…>, 14 years ago

CodePatterns places all includes now in subfolder CodePatterns/.

  • change all includes accordingly.
  • this was necessary as Helpers and Patterns are not very distinctive names for include folders. Already now, we had a conflict between Helpers from CodePatterns and Helpers from this project.
  • changed compilation test in ax_codepatterns.m4 when changing CodePatterns includes.
  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * AtomDescriptor.cpp
10 *
11 * Created on: Feb 5, 2010
12 * Author: crueger
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include "Descriptors/AtomDescriptor.hpp"
23#include "Descriptors/AtomDescriptor_impl.hpp"
24
25#include "World.hpp"
26#include "atom.hpp"
27#include "CodePatterns/ObservedContainer_impl.hpp"
28
29#include <boost/bind.hpp>
30
31#include <iostream>
32
33using namespace std;
34
35typedef World::AtomSet::internal_iterator atoms_iter_t;
36
37/************************ Forwarding object **************************************/
38
39
40AtomDescriptor::AtomDescriptor(impl_ptr _impl) :
41 impl(_impl)
42{}
43
44AtomDescriptor::AtomDescriptor(const AtomDescriptor& src) :
45 impl(src.get_impl())
46{}
47
48AtomDescriptor::~AtomDescriptor()
49{}
50
51AtomDescriptor& AtomDescriptor::operator=(AtomDescriptor &src){
52 if(&src!=this) {
53 impl=src.get_impl();
54 }
55 return *this;
56}
57
58atom* AtomDescriptor::find(){
59 return impl->find();
60}
61
62std::vector<atom*> AtomDescriptor::findAll(){
63 return impl->findAll();
64}
65
66AtomDescriptor::impl_ptr AtomDescriptor::get_impl() const{
67 return impl;
68}
69
70
71
72
73/**************************** implementation ********************/
74
75AtomDescriptor_impl::AtomDescriptor_impl()
76{
77}
78
79AtomDescriptor_impl::~AtomDescriptor_impl()
80{
81}
82
83World::AtomSet& AtomDescriptor_impl::getAtoms(){
84 return World::getInstance().atoms;
85}
86
87atom* AtomDescriptor_impl::find() {
88 World::AtomSet &atoms = getAtoms();
89 atoms_iter_t res = find_if(atoms.begin_internal(),atoms.end_internal(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));
90 return (res!=atoms.end_internal())?((*res).second):0;
91}
92
93vector<atom*> AtomDescriptor_impl::findAll() {
94 vector<atom*> res;
95 World::AtomSet atoms = getAtoms();
96 for_each(atoms.begin_internal(),
97 atoms.end_internal(),
98 boost::bind(&AtomDescriptor_impl::checkAndAdd,
99 this,&res,_1));
100 return res;
101}
102
103void AtomDescriptor_impl::checkAndAdd(std::vector<atom*> *v,std::pair<atomId_t,atom*> p){
104 if(predicate(p)){
105 v->push_back(p.second);
106 }
107}
108
109/************************** Universe and Emptyset *****************/
110
111AtomAllDescriptor_impl::AtomAllDescriptor_impl()
112{}
113
114AtomAllDescriptor_impl::~AtomAllDescriptor_impl()
115{}
116
117bool AtomAllDescriptor_impl::predicate(std::pair<atomId_t,atom*>){
118 return true;
119}
120
121AtomDescriptor AllAtoms(){
122 return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomAllDescriptor_impl));
123}
124
125AtomNoneDescriptor_impl::AtomNoneDescriptor_impl()
126{}
127
128AtomNoneDescriptor_impl::~AtomNoneDescriptor_impl()
129{}
130
131bool AtomNoneDescriptor_impl::predicate(std::pair<atomId_t,atom*>){
132 return false;
133}
134
135AtomDescriptor NoAtoms(){
136 return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomNoneDescriptor_impl));
137}
138
139/************************** Operator stuff ************************/
140
141// AND
142AtomAndDescriptor_impl::AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs) :
143 lhs(_lhs), rhs(_rhs)
144{}
145
146AtomAndDescriptor_impl::~AtomAndDescriptor_impl()
147{}
148
149bool AtomAndDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
150 return lhs->predicate(atom) && rhs->predicate(atom);
151}
152AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
153 AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomAndDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
154 return AtomDescriptor(newImpl);
155}
156
157// OR
158AtomOrDescriptor_impl::AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs ,AtomDescriptor::impl_ptr _rhs) :
159 lhs(_lhs), rhs(_rhs)
160{}
161
162AtomOrDescriptor_impl::~AtomOrDescriptor_impl(){
163}
164
165bool AtomOrDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
166 return lhs->predicate(atom) || rhs->predicate(atom);
167}
168
169AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
170 AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomOrDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
171 return AtomDescriptor(newImpl);
172}
173
174// NOT
175
176AtomNotDescriptor_impl::AtomNotDescriptor_impl(AtomDescriptor::impl_ptr _arg) :
177 arg(_arg)
178{}
179
180
181AtomNotDescriptor_impl::~AtomNotDescriptor_impl()
182{
183}
184
185bool AtomNotDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
186 return !(arg->predicate(atom));
187}
188
189AtomDescriptor operator!(const AtomDescriptor &arg){
190 AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomNotDescriptor_impl(arg.get_impl()));
191 return AtomDescriptor(newImpl);
192}
Note: See TracBrowser for help on using the repository browser.