source: src/Atom/atom.hpp@ 4fc0ea

Candidate_v1.6.1 ChemicalSpaceEvaluator TremoloParser_IncreasedPrecision
Last change on this file since 4fc0ea was 8c6b68, checked in by Frederik Heber <frederik.heber@…>, 7 years ago

atom::removeStep() extended to removing interval of steps.

  • AtomInfo::removeTrajectorySteps() and BondedParticle::removeTrajectorySteps() changed and all calls adapted.
  • Property mode set to 100644
File size: 8.5 KB
Line 
1/*
2 * atom.hpp
3 *
4 * Created on: Aug 3, 2009
5 * Author: heber
6 */
7
8#ifndef ATOM_HPP_
9#define ATOM_HPP_
10
11using namespace std;
12
13/*********************************************** includes ***********************************/
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <iosfwd>
21#include <list>
22#include <vector>
23
24#include "atom_atominfo.hpp"
25#include "atom_bondedparticle.hpp"
26#include "atom_graphnode.hpp"
27#include "atom_observable.hpp"
28#include "atom_particleinfo.hpp"
29#include "Atom/TesselPoint.hpp"
30#include "types.hpp"
31
32#include "CodePatterns/Observer/Observer.hpp"
33#include "CodePatterns/enumeration.hpp"
34
35/****************************************** forward declarations *****************************/
36
37class AtomicInfo;
38class Vector;
39class World;
40class molecule;
41class Shape;
42
43/********************************************** declarations *******************************/
44
45/** Single atom.
46 * Class incorporates position, type
47 */
48class atom :
49 public GraphNode,
50 public BondedParticle,
51 public TesselPoint
52{
53 friend atom* NewAtom(atomId_t);
54 friend void DeleteAtom(atom*);
55
56 atom *father; //!< In many-body bond order fragmentations points to originating atom
57 int *sort; //!< sort criteria
58
59public:
60
61 /** Clones this atom.
62 *
63 * Does not clone the bonds!
64 *
65 * @return reference to atom
66 */
67 virtual atom *clone();
68
69 /** Pushes back another step in all trajectory vectors.
70 *
71 * This allows to extend all trajectories contained in different classes
72 * consistently. This is implemented by the topmost class which calls the
73 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses.
74 */
75 virtual void UpdateStep(const unsigned int _step);
76
77 /** Pops the last step in all trajectory vectors.
78 *
79 * This allows to decrease all trajectories contained in different classes
80 * by one consistently. This is implemented by the topmost class which calls
81 * the real functions, \sa removeTrajectorySteps(), by all necessary subclasses.
82 *
83 * \param _firststep first step in interval to be removed
84 * \param _laststep last step in interval to be removed
85 */
86 virtual void removeSteps(const unsigned int _firststep, const unsigned int _laststep);
87
88 /** Output of a single atom with given numbering.
89 * \param ElementNo cardinal number of the element
90 * \param AtomNo cardinal number among these atoms of the same element
91 * \param *out stream to output to
92 * \param *comment commentary after '#' sign
93 * \return true - \a *out present, false - \a *out is NULL
94 */
95 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
96
97 /** Output of a single atom with numbering from array according to atom::type.
98 * \param *ElementNo cardinal number of the element
99 * \param *AtomNo cardinal number among these atoms of the same element
100 * \param *out stream to output to
101 * \param *comment commentary after '#' sign
102 * \return true - \a *out present, false - \a *out is NULL
103 */
104 bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
105
106 /** Initialises the component number array.
107 * Size is set to atom::ListOfBonds.size()+1 (last is th encode end by -1)
108 */
109 void InitComponentNr();
110
111 /** Resets GraphNr to -1.
112 *
113 */
114 void resetGraphNr();
115
116 /** Check whether father is equal to given atom.
117 * \param *ptr atom to compare father to
118 * \param **res return value (only set if atom::father is equal to \a *ptr)
119 */
120 void EqualsFather ( const atom *ptr, const atom **res ) const;
121
122 /** States whether the given \a *ptr is our father.
123 *
124 * @param ptr atom to compare atom::Father with
125 * @return true - \a *ptr is father, false - not
126 */
127 bool isFather(const atom *ptr);
128
129 /** If we are copy of copy, we are linked to be just a copy.
130 *
131 */
132 void CorrectFather();
133
134 /** Climbs up the father list until NULL, last is returned.
135 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
136 */
137 atom *GetTrueFather();
138
139 /** Const version of \sa GetTrueFather().
140 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
141 */
142 const atom *GetTrueFather() const;
143
144 /** Const getter for the atoms father.
145 *
146 * \return father of this atom
147 */
148 atom * const getFather() const
149 { return father; }
150
151 /** Sets the father for this atom.
152 *
153 * \param _father ptr to father atom
154 */
155 void setFather(atom * const _father);
156
157 /** Compares the indices of \a this atom with a given \a ptr.
158 * \param ptr atom to compare index against
159 * \return true - this one's is smaller, false - not
160 */
161 bool Compare(const atom &ptr) const;
162
163 /** Returns distance to a given vector.
164 * \param origin vector to calculate distance to
165 * \return distance
166 */
167 double DistanceToVector(const Vector &origin) const;
168
169 /** Returns squared distance to a given vector.
170 * \param origin vector to calculate distance to
171 * \return distance squared
172 */
173 double DistanceSquaredToVector(const Vector &origin) const;
174
175 // getter and setter
176
177 /**
178 * returns the World that contains this atom.
179 * Use this if you need to get the world without locking
180 * the singleton for example.
181 *
182 */
183 World *getWorld();
184 void setWorld(World*);
185
186 virtual atomId_t getId() const;
187 virtual bool changeId(atomId_t newId);
188
189 /**
190 * this function sets the Id without notifying the world. Only use it, if the world has already
191 * gotten an ID for this Atom.
192 */
193 virtual void setId(atomId_t);
194
195 /** Returns pointer to the molecule which atom belongs to.
196 * \return containing molecule
197 */
198 const molecule* getMolecule() const;
199
200 /** Erases the atom in atom::mol's list of atoms and sets it to zero.
201 */
202 void removeFromMolecule();
203
204 /** Changes the molecule internal ParticleInfo::Nr of this atom.
205 *
206 * @param newNr new ParticleInfo::Nr to set
207 * @return true - change successful, false - changed not successful, id remains the old one
208 */
209 bool changeNr(int newNr);
210
211 /** Getter for ParticleInfo::Nr of the atom.
212 *
213 * @return index
214 */
215 int getNr() const;
216
217 // Output operator
218 std::ostream & operator << (std::ostream &ost) const;
219
220 protected:
221
222 /**
223 * Protected constructor to ensure construction of atoms through the world.
224 * see World::createAtom()
225 */
226 atom();
227
228 /**
229 * Protected copy-constructor to ensure construction of atoms by cloning.
230 * see atom::clone()
231 */
232 atom(class atom *pointer);
233
234 /**
235 * Protected destructor to ensure destruction of atoms through the world.
236 * see World::destroyAtom()
237 */
238 virtual ~atom();
239 private:
240 friend class molecule;
241 friend class AtomicInfo;
242 /** Makes the atom be contained in the new molecule \a *_mol.
243 * Uses atom::removeFromMolecule() to delist from old molecule.
244 * \param *_mol pointer to new molecule
245 */
246 void setMolecule(molecule*);
247
248 //!> grant World (only) access to selection state changers
249 friend class World;
250
251 /** Sets the internal selection state to true.
252 *
253 */
254 void select();
255
256 /** Unsets the internal selection state to true.
257 *
258 */
259 void unselect();
260
261// virtual void update(Observable *publisher);
262// virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
263 virtual void subjectKilled(Observable *publisher);
264
265 public:
266
267 /** Getter to internal selection status.
268 *
269 * \return true - atom is selected, false - else
270 */
271 bool getSelected() const { return selected; }
272
273 private:
274 molecule *mol; // !< the molecule this atom belongs to
275 World* world;
276 atomId_t id;
277 //!> internal state whether atom is selected or not
278 bool selected;
279};
280
281/**
282 * Global output operator for class atom.
283 */
284std::ostream & operator << (std::ostream &ost, const atom &_atom);
285
286/**
287 * internal method used by the world. Do not use if you don't know what you are doing.
288 * You might get burned...
289 * Use World::createAtom() instead.
290 */
291atom* NewAtom(atomId_t _id);
292
293/**
294* internal method used by the world. Do not use if you don't know what you are doing.
295 * You might get burned...
296 * Use World::destroyAtom() instead.
297 */
298void DeleteAtom(atom*);
299
300/**
301 * Simple function to compare atoms by their elements to allow sorting of atoms by this criteria
302 */
303bool compareAtomElements(atom* atom1,atom* atom2);
304
305
306#endif /* ATOM_HPP_ */
Note: See TracBrowser for help on using the repository browser.