Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.hpp

    r5be798 re39e7a  
    2222
    2323#include <string>
     24
     25#include <boost/bimap/bimap.hpp>
     26#include <boost/bimap/unordered_set_of.hpp>
     27#include <boost/bimap/multiset_of.hpp>
     28#include <boost/optional.hpp>
     29#include <boost/shared_ptr.hpp>
    2430
    2531#include "AtomIdSet.hpp"
     
    115121    MoleculeNameChanged,
    116122    IndexChanged,
     123    BoundingBoxChanged,
    117124    AboutToBeRemoved,
    118125    NotificationType_MAX
     
    238245  bool changeAtomNr(int oldNr, int newNr, atom* target=0);
    239246
     247  friend bool atom::changeId(atomId_t newId);
     248  /**
     249   * used when changing an ParticleInfo::Id.
     250   * Note that this number is global (and the molecule uses it to know which atoms belong to it)
     251   *
     252   * @param oldId old Id
     253   * @param newId new Id to set
     254   * @return indicates wether the change could be done or not.
     255   */
     256  bool changeAtomId(int oldId, int newId);
     257
    240258  /** Updates the internal lookup fro local to global indices.
    241259   *
     
    260278
    261279public:
     280
     281  /** Structure for the required information on the bounding box.
     282   *
     283   */
     284  struct BoundingBoxInfo {
     285    //!> position of center
     286    Vector position;
     287    //!> radius of sphere
     288    double radius;
     289
     290    /** Equivalence operator for bounding box.
     291     *
     292     * \return true - both bounding boxes have same position and radius
     293     */
     294    bool operator==(const BoundingBoxInfo &_other) const
     295    {  return (radius == _other.radius) && (position == _other.position); }
     296
     297    /** Inequivalence operator for bounding box.
     298     *
     299     * \return true - bounding boxes have either different positions or different radii or both
     300     */
     301    bool operator!=(const BoundingBoxInfo &_other) const
     302    { return !(*this == _other); }
     303  };
     304
     305private:
     306
     307  /** Returns the current bounding box.
     308   *
     309   * \return Shape with center and extension of box
     310   */
     311  BoundingBoxInfo updateBoundingBox() const;
     312
     313  // stuff for keeping bounding box up-to-date efficiently
     314
     315  //!> Cacheable for the bounding box, ptr such that
     316  boost::shared_ptr< Cacheable<BoundingBoxInfo> > BoundingBox;
     317  /** Bimap storing atomic ids and the component per axis.
     318   *
     319   * We need a bimap in order to have the components sorted and be able to
     320   * access max and min values in linear time and also access the ids in
     321   * constant time in order to update the map, when atoms move, are inserted,
     322   * or removed.
     323   */
     324  typedef boost::bimaps::bimap<
     325          boost::bimaps::unordered_set_of< atomId_t >,
     326          boost::bimaps::multiset_of< double, std::greater<double> >
     327      > AtomDistanceMap_t;
     328  std::vector<AtomDistanceMap_t> BoundingBoxSweepingAxis;
     329
     330public:
     331
     332  /** Returns the current bounding box of this molecule.
     333   *
     334   * \return bounding box info with center and radius
     335   */
     336  BoundingBoxInfo getBoundingBox() const;
    262337
    263338  /** Function to create a bounding spherical shape for the currently associated atoms.
Note: See TracChangeset for help on using the changeset viewer.