| 1 | /*
 | 
|---|
| 2 |  * ClusterInterface.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: Jan 20, 2012
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #ifndef CLUSTERINTERFACE_HPP_
 | 
|---|
| 9 | #define CLUSTERINTERFACE_HPP_
 | 
|---|
| 10 | 
 | 
|---|
| 11 | 
 | 
|---|
| 12 | // include config.h
 | 
|---|
| 13 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 14 | #include <config.h>
 | 
|---|
| 15 | #endif
 | 
|---|
| 16 | 
 | 
|---|
| 17 | #include <boost/shared_ptr.hpp>
 | 
|---|
| 18 | #include <set>
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "AtomIdSet.hpp"
 | 
|---|
| 21 | #include "types.hpp"
 | 
|---|
| 22 | 
 | 
|---|
| 23 | class atom;
 | 
|---|
| 24 | class CopyAtomsInterface;
 | 
|---|
| 25 | class RealSpaceMatrix;
 | 
|---|
| 26 | class Shape;
 | 
|---|
| 27 | class Vector;
 | 
|---|
| 28 | 
 | 
|---|
| 29 | /** This is the interface class for clusters.
 | 
|---|
| 30 |  *
 | 
|---|
| 31 |  * Clusters are containers for \refAtomIdSet that make sure that within a given
 | 
|---|
| 32 |  * shape each of the atoms in the \ref AtomIdSet is contained and none else.
 | 
|---|
| 33 |  *
 | 
|---|
| 34 |  * We need this ClusterInterface to allow for ClusterInterface::clone() to not
 | 
|---|
| 35 |  * return a pointer but a boost::shared_ptr which is much cleaner in terms of
 | 
|---|
| 36 |  * memory management.
 | 
|---|
| 37 |  *
 | 
|---|
| 38 |  */
 | 
|---|
| 39 | class ClusterInterface
 | 
|---|
| 40 | {
 | 
|---|
| 41 | public:
 | 
|---|
| 42 |   //!> typedef for pointer to ClusterInterface-compatible instances
 | 
|---|
| 43 |   typedef boost::shared_ptr<ClusterInterface> Cluster_impl;
 | 
|---|
| 44 |   typedef AtomIdSet::atomIdSet atomIdSet;
 | 
|---|
| 45 | 
 | 
|---|
| 46 |   virtual ~ClusterInterface() {}
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   /** Getter for the set of atomic ids associated to the cluster.
 | 
|---|
| 49 |    *
 | 
|---|
| 50 |    * @return set of atomic ids
 | 
|---|
| 51 |    */
 | 
|---|
| 52 |   virtual const atomIdSet & getAtomIds() const=0;
 | 
|---|
| 53 | 
 | 
|---|
| 54 |   /** Getter for the set of atoms associated to the cluster.
 | 
|---|
| 55 |    *
 | 
|---|
| 56 |    * @return set of atoms
 | 
|---|
| 57 |    */
 | 
|---|
| 58 |   AtomIdSet getAtoms() const
 | 
|---|
| 59 |   {
 | 
|---|
| 60 |     return AtomIdSet(getAtomIds());
 | 
|---|
| 61 |   }
 | 
|---|
| 62 | 
 | 
|---|
| 63 |   /** Getter for the cluster's Shape.
 | 
|---|
| 64 |    *
 | 
|---|
| 65 |    * @return Shape \a s
 | 
|---|
| 66 |    */
 | 
|---|
| 67 |   virtual const Shape& getShape() const=0;
 | 
|---|
| 68 | 
 | 
|---|
| 69 |   /** Clones this cluster.
 | 
|---|
| 70 |    *
 | 
|---|
| 71 |    * We copy the shape and we copy all contained atoms in such a way as
 | 
|---|
| 72 |    * functor \a copyMethod does. We also translate atoms by \a offset
 | 
|---|
| 73 |    * eventually.
 | 
|---|
| 74 |    *
 | 
|---|
| 75 |    * @param copyMethod functor that knows how to copy the atoms
 | 
|---|
| 76 |    * @param offset translational offset for contained atoms
 | 
|---|
| 77 |    * @return reference to the clone cluster
 | 
|---|
| 78 |    */
 | 
|---|
| 79 |   virtual Cluster_impl clone(CopyAtomsInterface& copyMethod, const Vector &offset) const =0;
 | 
|---|
| 80 | 
 | 
|---|
| 81 |   /** Move a cluster.
 | 
|---|
| 82 |    *
 | 
|---|
| 83 |    * This moves both all contained atoms associated to the cluster and the
 | 
|---|
| 84 |    * shape itself
 | 
|---|
| 85 |    *
 | 
|---|
| 86 |    * @param offset translation vector
 | 
|---|
| 87 |    */
 | 
|---|
| 88 |   virtual void translate(const Vector &offset)=0;
 | 
|---|
| 89 | 
 | 
|---|
| 90 |   /** Transforms a cluster.
 | 
|---|
| 91 |    *
 | 
|---|
| 92 |    * This transforms both all contained atoms associated to the cluster and the
 | 
|---|
| 93 |    * shape itself with respect to their spatial positions.
 | 
|---|
| 94 |    *
 | 
|---|
| 95 |    * @param M transformation matrix
 | 
|---|
| 96 |    */
 | 
|---|
| 97 |   virtual void transform(const RealSpaceMatrix &M)=0;
 | 
|---|
| 98 | 
 | 
|---|
| 99 |   /** Check whether the given atom is inside the Cluster's shape.
 | 
|---|
| 100 |    *
 | 
|---|
| 101 |    * @param id atom id to check
 | 
|---|
| 102 |    * @return true - is inside cluster's shape, false - else
 | 
|---|
| 103 |    */
 | 
|---|
| 104 |   virtual bool isInside(const atomId_t id) const = 0;
 | 
|---|
| 105 | };
 | 
|---|
| 106 | 
 | 
|---|
| 107 | /** Output operator for the atoms contained in \a cluster.
 | 
|---|
| 108 |  *
 | 
|---|
| 109 |  * @param out output stream to print to
 | 
|---|
| 110 |  * @param cluster cluster to print
 | 
|---|
| 111 |  * @return \a out for concatenation
 | 
|---|
| 112 |  */
 | 
|---|
| 113 | std::ostream &operator<<(std::ostream &out, const ClusterInterface& cluster);
 | 
|---|
| 114 | 
 | 
|---|
| 115 | #endif /* CLUSTERINTERFACE_HPP_ */
 | 
|---|