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:
00022 CompoundSystem()
00023
00024 {}
00025
00027 ~CompoundSystem() {
00028 for (int i=0; i < (int)compounds.size(); ++i)
00029 delete compounds[i];
00030 }
00031
00032
00033
00034
00035
00036
00037
00044 Compound::Index adoptCompound(
00045 Compound& child,
00046 const Transform& compoundTransform = Transform()
00047 )
00048 {
00049 const Compound::Index id((int)compounds.size());
00050
00051 compounds.push_back(new Compound((CompoundRep*)0));
00052 Compound& c = *compounds.back();
00053
00054 child.disown(c);
00055
00056
00057
00058 c.setCompoundSystem(*this, id);
00059
00060
00061
00062
00063 c.setTopLevelTransform(compoundTransform * c.getTopLevelTransform());
00064
00065
00066
00067 return id;
00068 }
00069
00071 void modelCompounds();
00072
00076 size_t getNumCompounds() const {return compounds.size();}
00077
00079 const Compound& getCompound(Compound::Index i
00080 ) const {return *compounds.at(i);}
00081
00083 Compound& updCompound(Compound::Index i
00084 ) {return *compounds.at(i);}
00085
00086 private:
00087
00088 void modelOneCompound(Compound::Index compoundId);
00089
00090 void setClusterCompound(DuMM::ClusterIndex clusterIx, const Compound& compound)
00091 {
00092 assert(! clusterHasCompound(clusterIx));
00093 compoundPtrsByClusterIndex[clusterIx] = &compound;
00094 assert(clusterHasCompound(clusterIx));
00095 }
00096
00097 bool clusterHasCompound(DuMM::ClusterIndex clusterIx) {
00098 return compoundPtrsByClusterIndex.find(clusterIx) != compoundPtrsByClusterIndex.end();
00099 }
00100
00101 void generateTopologyFromCompounds();
00102
00103
00104 CompoundSystem(const CompoundSystem&);
00105 CompoundSystem& operator=(const CompoundSystem&);
00106
00107
00108
00109
00110
00111 #if defined(_MSC_VER)
00112 #pragma warning(push)
00113 #pragma warning(disable:4251)
00114 #endif
00115
00116 std::vector<Compound*> compounds;
00117 std::map<DuMM::ClusterIndex, const Compound*> compoundPtrsByClusterIndex;
00118 std::map<DuMM::ClusterIndex, int> clusterAtomCounts;
00119 std::map<DuMM::ClusterIndex, MobilizedBodyIndex> clusterBodies;
00120
00121 #if defined(_MSC_VER)
00122 #pragma warning(pop)
00123 #endif
00124
00125
00126
00127 };
00128
00129 }
00130
00131 #endif // SimTK_MOLMODEL_COMPOUNDSYSTEM_H_
00132