00001 /** 00002 * \file SymmetrySampler.h 00003 * \brief Sample transformations of particles while preseving N-symmetry. 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 */ 00007 00008 #ifndef IMPDOMINO_SYMMETRY_SAMPLER_H 00009 #define IMPDOMINO_SYMMETRY_SAMPLER_H 00010 00011 #include "IMP/Particle.h" 00012 #include <map> 00013 #include <sstream> 00014 #include "IMP/base_types.h" 00015 #include "domino_config.h" 00016 #include "DiscreteSampler.h" 00017 #include "CombState.h" 00018 #include "TransformationDiscreteSet.h" 00019 #include <IMP/algebra/Transformation3D.h> 00020 #include <IMP/algebra/Cylinder3D.h> 00021 00022 IMPDOMINO_BEGIN_NAMESPACE 00023 //! SymmetrySampler 00024 /** 00025 The class symmetrically sample particles. 00026 /note We currently assume that the particles are Hierarchys, 00027 it should be changes to general Hierarchy. 00028 */ 00029 class IMPDOMINOEXPORT SymmetrySampler : public DiscreteSampler 00030 { 00031 public: 00032 //! Constructor 00033 /** 00034 /param[in] ps the particles that should obey N-symmetry ( N is the 00035 number of particles). 00036 /param[in] ts a set of transformations for the first particle 00037 /param[in] c the cylinder represent the symmery axis of the particles 00038 /note The sampler assumes that the order of the particles in the ring 00039 is the order of the input particles. 00040 /note The sampled set of transformations for particle number i is the set of 00041 input transformations rotated by (360/N)*i around the symmetry axis. 00042 /todo consider calculating the cylinder in construction 00043 */ 00044 SymmetrySampler(Particles *ps, TransformationDiscreteSet *ts, 00045 const algebra::Cylinder3D &c); 00046 void move2state(const CombState *cs); 00047 void populate_states_of_particles(Particles *particles, 00048 std::map<std::string, CombState *> *states) const; 00049 void show(std::ostream& out = std::cout) const {out<<"SymmetrySampler";} 00050 DiscreteSet* get_space(Particle *p) const{return ts_;} 00051 protected: 00052 00053 void reset_placement(const CombState *cs); 00054 00055 algebra::Cylinder3D cyl_; 00056 std::map<Particle*,int> symm_deg_; 00057 Particles *ps_; 00058 TransformationDiscreteSet *ts_; 00059 std::map<Particle*,algebra::Transformation3D> ref_; 00060 }; 00061 00062 IMPDOMINO_END_NAMESPACE 00063 00064 #endif /* IMPDOMINO_SYMMETRY_SAMPLER_H */