CompoundSystem.h

Go to the documentation of this file.
00001 #ifndef SimTK_MOLMODEL_COMPOUNDSYSTEM_H_
00002 #define SimTK_MOLMODEL_COMPOUNDSYSTEM_H_
00003 
00004 #include "SimTKsimbody.h"
00005 #include "molmodel/internal/common.h"
00006 #include "molmodel/internal/Compound.h"
00007 #include "molmodel/internal/MolecularMechanicsSystem.h"
00008 #include "molmodel/internal/DuMMForceFieldSubsystem.h"
00009 
00010 #include <map>
00011 
00012 namespace SimTK {
00013 
00019 class SimTK_MOLMODEL_EXPORT CompoundSystem : public MolecularMechanicsSystem {
00020 public:
00021 
00027     SimTK_DEFINE_UNIQUE_LOCAL_INDEX_TYPE(CompoundSystem,CompoundIndex);
00028 
00030     CompoundSystem() 
00031 //        : matter(*this), decorations(*this)
00032     {}
00033 
00035     ~CompoundSystem() {
00036         for (int i=0; i < (int)compounds.size(); ++i)
00037             delete compounds[i];
00038     }
00039 
00040     // const SimbodyMatterSubsystem& getMatter() const {return matter;}
00041     // SimbodyMatterSubsystem& updMatter() {return matter;}
00042 
00043     // const DecorationSubsystem& getDecorations() const {return decorations;}
00044     // DecorationSubsystem& updDecorations() {return decorations;}
00045 
00052     void adoptCompound(
00053         Compound& child, 
00054         const Transform& compoundTransform = Transform() 
00055         ) 
00056     {
00057         // const Compound::Index id((int)compounds.size());
00058 
00059         compounds.push_back(new Compound((CompoundRep*)0)); // grow
00060         Compound& c = *compounds.back(); // refer to the empty handle we just created
00061 
00062         child.disown(c); // transfer ownership to c
00063 
00064         // Now tell the Compound object its owning CompoundSystem and id within
00065         // that System.
00066         // c.setCompoundSystem(*this, id);
00067         c.setMultibodySystem(*this);
00068 
00069         // Save transform
00070         // March 6, 2008 -- adjust internal Transform of Compound, rather than 
00071         // saving the Transform in CompoundSystem
00072         c.setTopLevelTransform(compoundTransform * c.getTopLevelTransform());
00073         // assert((int) compoundTransforms.size() == (int) id);
00074         // compoundTransforms.push_back(compoundTransform);
00075 
00076         // return id;
00077     }
00078 
00080     void modelCompounds();
00081 
00085     size_t             getNumCompounds() const {return compounds.size();}
00086 
00088     const Compound& getCompound(CompoundIndex i 
00089         ) const {return *compounds.at(i);}
00090 
00092     Compound&       updCompound(CompoundIndex i 
00093         )       {return *compounds.at(i);}
00094 
00095 private:
00096 
00097     void modelOneCompound(CompoundIndex compoundId);
00098 
00099     void setClusterCompound(DuMM::ClusterIndex clusterIx, const Compound& compound) 
00100     {
00101         assert(! clusterHasCompound(clusterIx));
00102         compoundPtrsByClusterIndex[clusterIx] = &compound;
00103         assert(clusterHasCompound(clusterIx));
00104     }
00105 
00106     bool clusterHasCompound(DuMM::ClusterIndex clusterIx) {
00107         return compoundPtrsByClusterIndex.find(clusterIx) != compoundPtrsByClusterIndex.end();
00108     }
00109 
00110     void generateTopologyFromCompounds();
00111 
00112     // suppress
00113     CompoundSystem(const CompoundSystem&);
00114     CompoundSystem& operator=(const CompoundSystem&);
00115 
00116     // std::vector<Transform> compoundTransforms;
00117 
00118     // retarded visual studio compiler complains about being unable to 
00119     // export private stl class members
00120 #if defined(_MSC_VER)
00121 #pragma warning(push)
00122 #pragma warning(disable:4251)
00123 #endif
00124 
00125     std::vector<Compound*> compounds;
00126     std::map<DuMM::ClusterIndex, const Compound*> compoundPtrsByClusterIndex;
00127     std::map<DuMM::ClusterIndex, int> clusterAtomCounts;
00128     std::map<DuMM::ClusterIndex, MobilizedBodyIndex> clusterBodies;
00129 
00130 #if defined(_MSC_VER)
00131 #pragma warning(pop)
00132 #endif
00133 
00134     // SimbodyMatterSubsystem matter;
00135     // DecorationSubsystem decorations;
00136 };
00137 
00138 } // namespace SimTK
00139 
00140 #endif // SimTK_MOLMODEL_COMPOUNDSYSTEM_H_
00141 

Generated on Thu Aug 12 16:37:05 2010 for SimTKcore by  doxygen 1.6.1