PBlock.h

Go to the documentation of this file.
00001 /*
00002     LoopTK: Protein Loop Kinematic Toolkit
00003     Copyright (C) 2007 Stanford University
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License along
00016     with this program; if not, write to the Free Software Foundation, Inc.,
00017     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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;  /* Needed so blocks can be connected together. */
00037   friend class PBlockReconnector; /* Needed for detached blocks to be reconnected. */
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; //atom Id's to the respective atom
00224 
00225   /* Collision detection helper methods. */
00226 
00227   bool InCollision(CollisionType type) const;
00228   pair<PAtom *, PAtom *> FindCollision(CollisionType type) const;
00229   AtomCollisions* getAllColliding(CollisionType type) const;
00230 
00231   //prepared by finalize()
00232   vector<PBond *> m_dofs;
00233 
00234 
00235   //selective manipulation data members:
00236   bool m_isOn;
00237   vector<PBlock *> m_connectedBlocks;
00238   PBlockReconnector *m_blockReconnector;
00239 
00240   
00241   //selective manipulation helper functions
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

Generated on Wed May 16 20:22:07 2007 for LoopTK: Protein Loop Kinematic Toolkit by  doxygen 1.5.1