Since I needed caching of my bonds so I decided to refactor things to
have bonded and nonbonded lists. Here are my proposed interfaces for
people's perusal. I then have a DynamicExclusionVolumeRestraint and
DynamicBondRestraint which take pointers to these states and get their
particle pairs from them.
I don't know the best way to make things accessible from python (I
don't think the C++ iterators will work from python, but I haven't
tried).
For reference, a BondDecorator is a decorator wrapping a particle
which contains information (length, stiffness, type) for a bond.
//! A pair of Particle * which can be used in maps
struct ParticlePair {
ParticlePair(Particle *a, Particle *b);
Particle *get_particle(unsigned int i) const ;
IMP_COMPARISONS_2(p_[0], p_[1]);
};
//! A state that maintains a list of bonded particles.
/**
The state uses the BondedDecorator to find bonded pairs in
its list of particles and builds a fast lookup structure on them.
*/
class IMPDLLEXPORT BondedListState : public State
{
public:
BondedListState(const Particles &pis);
virtual ~BondedListState();
IMP_STATE("0.5", "Daniel Russel");
void set_particles(const Particles &pis) ;
BondsIterator bonds_begin() const ;
BondsIterator bonds_end() const ;
//! Get a bonds between two particles
/**
\returns BondDecorator() if there is not bond or the appropriate
one if there is a bond.
*/
BondDecorator get_bond(Particle *a, Particle *b) const ;
};
//! A state that maintains a list of nonbonded particles.
/**
*/
class IMPDLLEXPORT NonbondedListState : public State
{
public:
/**
\note The distance_threshold parameter is just a guideline.
Particle
pairs with larger distance can be returned. But all with smaller
distance will be.
BondedListState will be updated when this one is and deleted when
this State is and so should not be added seperately to the Model.
*/
NonbondedListState(const Particles &pis, Float distance_threshold,
BondedList *bl=NULL);
virtual ~NonbondedListState();
IMP_STATE("0.5", "Daniel Russel");
void set_particles(const Particles &pis);
/*Eventually these iterators could generate the pairs on the fly
from the voxel grid*/