| [bcf653] | 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 | 
 | 
|---|
| [cee0b57] | 8 | /*
 | 
|---|
 | 9 |  * molecule_pointcloud.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: Oct 5, 2009
 | 
|---|
 | 12 |  *      Author: heber
 | 
|---|
 | 13 |  */
 | 
|---|
 | 14 | 
 | 
|---|
| [bf3817] | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
| [112b09] | 20 | #include "Helpers/MemDebug.hpp"
 | 
|---|
 | 21 | 
 | 
|---|
| [f66195] | 22 | #include "atom.hpp"
 | 
|---|
| [cee0b57] | 23 | #include "config.hpp"
 | 
|---|
| [952f38] | 24 | #include "Helpers/Info.hpp"
 | 
|---|
| [cee0b57] | 25 | #include "molecule.hpp"
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | /************************************* Functions for class molecule *********************************/
 | 
|---|
 | 28 | 
 | 
|---|
| [af2c424] | 29 | TesselPoint * molecule::getValue(const_iterator &rhs) const
 | 
|---|
 | 30 | {
 | 
|---|
 | 31 |   return *rhs;
 | 
|---|
 | 32 | }
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | TesselPoint * molecule::getValue(iterator &rhs) const
 | 
|---|
 | 35 | {
 | 
|---|
 | 36 |   return *rhs;
 | 
|---|
 | 37 | }
 | 
|---|
 | 38 | 
 | 
|---|
| [6a7f78c] | 39 | /** Returns a name for this point cloud, here the molecule's name.
 | 
|---|
 | 40 |  * \return name of point cloud
 | 
|---|
 | 41 |  */
 | 
|---|
 | 42 | const char * const molecule::GetName() const
 | 
|---|
 | 43 | {
 | 
|---|
 | 44 |   return name;
 | 
|---|
 | 45 | };
 | 
|---|
| [cee0b57] | 46 | 
 | 
|---|
 | 47 | /** Determine center of all atoms.
 | 
|---|
 | 48 |  * \param *out output stream for debugging
 | 
|---|
 | 49 |  * \return pointer to allocated with central coordinates
 | 
|---|
 | 50 |  */
 | 
|---|
| [e138de] | 51 | Vector *molecule::GetCenter() const
 | 
|---|
| [cee0b57] | 52 | {
 | 
|---|
| [e138de] | 53 |   Vector *center = DetermineCenterOfAll();
 | 
|---|
| [cee0b57] | 54 |   return center;
 | 
|---|
 | 55 | };
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 | 
 | 
|---|
| [9879f6] | 58 | /** PointCloud implementation of GoPoint
 | 
|---|
 | 59 |  * Uses atoms and STL stuff.
 | 
|---|
| [71b20e] | 60 |  */
 | 
|---|
| [9879f6] | 61 | TesselPoint* molecule::GetPoint() const
 | 
|---|
| [71b20e] | 62 | {
 | 
|---|
| [9879f6] | 63 |   return (*InternalPointer);
 | 
|---|
| [71b20e] | 64 | };
 | 
|---|
 | 65 | 
 | 
|---|
| [9879f6] | 66 | /** PointCloud implementation of GoToNext.
 | 
|---|
 | 67 |  * Uses atoms and STL stuff.
 | 
|---|
| [cee0b57] | 68 |  */
 | 
|---|
| [776b64] | 69 | void molecule::GoToNext() const
 | 
|---|
| [cee0b57] | 70 | {
 | 
|---|
| [d3347e] | 71 |   if (InternalPointer != atoms.end())
 | 
|---|
| [9879f6] | 72 |     InternalPointer++;
 | 
|---|
| [cee0b57] | 73 | };
 | 
|---|
 | 74 | 
 | 
|---|
| [9879f6] | 75 | /** PointCloud implementation of GoToFirst.
 | 
|---|
 | 76 |  * Uses atoms and STL stuff.
 | 
|---|
| [cee0b57] | 77 |  */
 | 
|---|
| [776b64] | 78 | void molecule::GoToFirst() const
 | 
|---|
| [cee0b57] | 79 | {
 | 
|---|
| [274d45] | 80 |   // evil hack necessary because
 | 
|---|
 | 81 |   // -# although InternalPointer is mutable
 | 
|---|
 | 82 |   // -# only const_iterator begin() is called due to const in the function declaration above
 | 
|---|
 | 83 |   // -# and there is no cast from const_iterator to const iterator
 | 
|---|
 | 84 |   atomSet::const_iterator test = begin();
 | 
|---|
 | 85 |   InternalPointer = *(reinterpret_cast<atomSet::iterator *>(&test));
 | 
|---|
| [cee0b57] | 86 | };
 | 
|---|
 | 87 | 
 | 
|---|
| [9879f6] | 88 | /** PointCloud implementation of IsEmpty.
 | 
|---|
 | 89 |  * Uses atoms and STL stuff.
 | 
|---|
| [cee0b57] | 90 |  */
 | 
|---|
| [776b64] | 91 | bool molecule::IsEmpty() const
 | 
|---|
| [cee0b57] | 92 | {
 | 
|---|
| [9879f6] | 93 |   return (empty());
 | 
|---|
| [cee0b57] | 94 | };
 | 
|---|
 | 95 | 
 | 
|---|
| [9879f6] | 96 | /** PointCloud implementation of IsLast.
 | 
|---|
 | 97 |  * Uses atoms and STL stuff.
 | 
|---|
| [cee0b57] | 98 |  */
 | 
|---|
| [776b64] | 99 | bool molecule::IsEnd() const
 | 
|---|
| [cee0b57] | 100 | {
 | 
|---|
| [d3347e] | 101 |   return (InternalPointer == atoms.end());
 | 
|---|
| [cee0b57] | 102 | };
 | 
|---|
| [c72112] | 103 | 
 | 
|---|
 | 104 | int molecule::GetMaxId() const {
 | 
|---|
 | 105 |   return getAtomCount();
 | 
|---|
 | 106 | }
 | 
|---|