00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __P_BLOCK_H
00021 #define __P_BLOCK_H
00022
00023 #include "PBlockShell.h"
00024 #include "PEnums.h"
00025
00026 class PBlockReconnector;
00027
00034 class PBlock {
00035 public:
00036 friend class PBlockConnection;
00037 friend class PBlockReconnector;
00038
00046 PBlock(PResidue *myRes, const string &shellName);
00047
00056 PBlock(PResidue *myRes, const string &shellName, const PAtomPositionsSpec &spec);
00057
00068 PBlock(PResidue *myRes, const string &shellName, const PAtomPositionsSpec &spec, PBlock *toConnect);
00069
00080 PBlock(PResidue *myRes, const string &shellName, PBlock *toConnect);
00081
00082 ~PBlock();
00083
00088 string getName() const {return m_shell->getName(); }
00089
00094 string getType() const {return m_shell->getType(); }
00095
00101 bool isOn() const { return m_isOn; }
00102
00107 PResidue *getParentResidue() { return m_residue; }
00108
00113 int size() { return m_atoms.size(); }
00114
00119 PChain* getChain() const;
00120
00128 void Detach(const string &blockType);
00129
00134 void Reattach();
00135
00141 bool InStaticCollision() const;
00142
00148 bool InSelfCollision() const;
00149
00155 bool InAnyCollision() const;
00156
00163 pair<PAtom *, PAtom *> FindStaticCollision() const;
00164
00171 pair<PAtom *, PAtom *> FindSelfCollision() const;
00172
00179 pair<PAtom *, PAtom *> FindAnyCollision() const;
00180
00186 AtomCollisions* getAllCollidingStatic() const;
00187
00193 AtomCollisions* getAllCollidingSelf() const;
00194
00200 AtomCollisions* getAllCollidingEither() const;
00201
00207 void AddAtomsToMap(HASH_MAP_STR(PAtom *) &atomCache) const;
00208
00213 const PSpaceManager* getSpaceManager() const;
00214 private:
00215
00216 void CreateBlock(PResidue *myRes, const PAtomPositionsSpec &spec);
00217 void ActivateAndDestroyReattachment();
00218 void ApplyTransform(Matrix4 transform);
00219
00220
00221 PBlockShell *m_shell;
00222 PResidue *m_residue;
00223 HASH_MAP_STR(PAtom *) m_atoms;
00224
00225
00226
00227 bool InCollision(CollisionType type) const;
00228 pair<PAtom *, PAtom *> FindCollision(CollisionType type) const;
00229 AtomCollisions* getAllColliding(CollisionType type) const;
00230
00231
00232 vector<PBond *> m_dofs;
00233
00234
00235
00236 bool m_isOn;
00237 vector<PBlock *> m_connectedBlocks;
00238 PBlockReconnector *m_blockReconnector;
00239
00240
00241
00242 PBlock *FindFirstBlockOfType(const string &blockType);
00243 void TraverseBlocks(PBlock *from, void (*ManipulateBlockFunc)(PBlock *block, PBlock *from), bool skipOffBlocks);
00244 static void DeactivateBlock(PBlock *block, PBlock *from);
00245 static void ActivateBlock(PBlock *block, PBlock *from);
00246 static void ReattachBlock(PBlock *block, PBlock *from);
00247 };
00248
00249 #endif // __P_BLOCK_H