source: molecuilder/src/atom.cpp@ 4e4940

Last change on this file since 4e4940 was 4e4940, checked in by Frederik Heber <heber@…>, 16 years ago

We are one step further in fixing the convex hull: There are two functions of Saskia Metzler missing, but then we may proceed with testing whether the simple correction scheme of the convex envelope works, but one thing: Right now we cannot associate a Tesselation to its molecule as the snake bites it's one tail. Hence, the next commit will consist of fixing this bad-OOP issue.

  • Makefile.am: Just some alphabetical resorting.
  • atom::atom() new copy constructor
  • builder.cpp: some output for cluster volume, molecule::AddCopyAtom() uses new copy constructor
  • FillBoxWithMolecule() - new function to fill the remainder of the simulation box with some given filler molecules. Makes explicit use of the tesselated surfaces
  • find_convex_border() - InsertStraddlingPoints() and CorrectConcaveBaselines() is called to correct for atoms outside the envelope and caused-by concave points
  • Tesselation::InsertStraddlingPoints() enlarges the envelope for all atoms found outside, Tesselation::CorrectConcaveBaselines() corrects all found baselines if the adjacent triangles are concave by flipping.
  • boundary.cpp: Lots of helper routines for stuff further below:
  • The following routines are needed to check whether point is in- or outside:
  • FIX: Tesselation::AddPoint() - newly created BoundaryPoint is removed if already present.

Problem: We want to associate a Tesselation class with each molecule class. However, so far we have to know about atoms and bond and molecules inside the Tesselation. We have to remove this dependency and create some intermediate class which enables/encapsulates the access to Vectors, e.g. hidden inside the atom class. This is also good OOP! The Tesselation also only needs a set of Vectors, not more!

  • Property mode set to 100755
File size: 3.2 KB
Line 
1/** \file atom.cpp
2 *
3 * Function implementations for the class atom.
4 *
5 */
6
7#include "molecules.hpp"
8
9/************************************* Functions for class atom *************************************/
10
11/** Constructor of class atom.
12 */
13atom::atom()
14{
15 Name = NULL;
16 previous = NULL;
17 next = NULL;
18 father = this; // generally, father is itself
19 Ancestor = NULL;
20 type = NULL;
21 sort = NULL;
22 FixedIon = 0;
23 nr = -1;
24 GraphNr = -1;
25 ComponentNr = NULL;
26 IsCyclic = false;
27 SeparationVertex = false;
28 LowpointNr = -1;
29 AdaptiveOrder = 0;
30 MaxOrder = false;
31};
32
33/** Constructor of class atom.
34 *
35 */
36atom::atom(atom *pointer)
37{
38 Name = NULL;
39 previous = NULL;
40 next = NULL;
41 father = this; // generally, father is itself
42 Ancestor = NULL;
43 type = pointer->type; // copy element of atom
44 x.CopyVector(&pointer->x); // copy coordination
45 v.CopyVector(&pointer->v); // copy velocity
46 FixedIon = pointer->FixedIon;
47 nr = -1;
48 sort = &nr;
49}
50
51
52/** Destructor of class atom.
53 */
54atom::~atom()
55{
56 Free((void **)&Name, "atom::~atom: *Name");
57 Free((void **)&ComponentNr, "atom::~atom: *ComponentNr");
58};
59
60
61/** Climbs up the father list until NULL, last is returned.
62 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
63 */
64atom *atom::GetTrueFather()
65{
66 atom *walker = this;
67 do {
68 if (walker == walker->father) // top most father is the one that points on itself
69 break;
70 walker = walker->father;
71 } while (walker != NULL);
72 return walker;
73};
74
75/** Output of a single atom.
76 * \param ElementNo cardinal number of the element
77 * \param AtomNo cardinal number among these atoms of the same element
78 * \param *out stream to output to
79 * \param *comment commentary after '#' sign
80 */
81bool atom::Output(int ElementNo, int AtomNo, ofstream *out, const char *comment) const
82{
83 if (out != NULL) {
84 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint;
85 *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];
86 *out << "\t" << FixedIon;
87 if (v.Norm() > MYEPSILON)
88 *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t";
89 if (comment != NULL)
90 *out << " # " << comment << endl;
91 else
92 *out << " # molecule nr " << nr << endl;
93 return true;
94 } else
95 return false;
96};
97
98/** Output of a single atom as one lin in xyz file.
99 * \param *out stream to output to
100 */
101bool atom::OutputXYZLine(ofstream *out) const
102{
103 if (out != NULL) {
104 *out << type->symbol << "\t" << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2] << "\t" << endl;
105 return true;
106 } else
107 return false;
108};
109
110ostream & operator << (ostream &ost, const atom &a)
111{
112 ost << "[" << a.Name << "|" << &a << "]";
113 return ost;
114};
115
116/** Compares the indices of \a this atom with a given \a ptr.
117 * \param ptr atom to compare index against
118 * \return true - this one's is smaller, false - not
119 */
120bool atom::Compare(atom &ptr)
121{
122 if (nr < ptr.nr)
123 return true;
124 else
125 return false;
126};
127
128bool operator < (atom &a, atom &b)
129{
130 return a.Compare(b);
131};
132
Note: See TracBrowser for help on using the repository browser.