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
00032 {}
00033
00035 ~CompoundSystem() {
00036 for (int i=0; i < (int)compounds.size(); ++i)
00037 delete compounds[i];
00038 }
00039
00040
00041
00042
00043
00044
00045
00052 void adoptCompound(
00053 Compound& child,
00054 const Transform& compoundTransform = Transform()
00055 )
00056 {
00057
00058
00059 compounds.push_back(new Compound((CompoundRep*)0));
00060 Compound& c = *compounds.back();
00061
00062 child.disown(c);
00063
00064
00065
00066
00067 c.setMultibodySystem(*this);
00068
00069
00070
00071
00072 c.setTopLevelTransform(compoundTransform * c.getTopLevelTransform());
00073
00074
00075
00076
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
00113 CompoundSystem(const CompoundSystem&);
00114 CompoundSystem& operator=(const CompoundSystem&);
00115
00116
00117
00118
00119
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
00135
00136 };
00137
00138 }
00139
00140 #endif // SimTK_MOLMODEL_COMPOUNDSYSTEM_H_
00141