00001 #ifndef OPENTISSUE_DYNAMICS_MBD_BODY_GROUP_H 00002 #define OPENTISSUE_DYNAMICS_MBD_BODY_GROUP_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 namespace OpenTissue 00013 { 00014 namespace mbd 00015 { 00016 00017 template< typename mbd_types > 00018 class BodyGroup 00019 { 00020 public: 00021 00022 typedef typename mbd_types::math_policy math_policy; 00023 00024 protected: 00025 00026 typedef typename mbd_types::math_policy::index_type size_type; 00027 typedef typename mbd_types::contact_ptr_container contact_ptr_container; 00028 typedef typename mbd_types::constraint_ptr_container constraint_ptr_container; 00029 typedef typename mbd_types::body_ptr_container body_ptr_container; 00030 00031 public: // TODO should be protected! 00032 00033 contact_ptr_container m_contacts; 00034 constraint_ptr_container m_constraints; 00035 body_ptr_container m_bodies; 00036 00037 public: 00038 00039 BodyGroup(){} 00040 00041 ~BodyGroup(){ clear(); } 00042 00043 public: 00044 00045 typedef typename mbd_types::indirect_constraint_iterator indirect_constraint_iterator; 00046 typedef typename mbd_types::const_indirect_constraint_iterator const_indirect_constraint_iterator; 00047 typedef typename mbd_types::indirect_contact_iterator indirect_contact_iterator; 00048 typedef typename mbd_types::const_indirect_contact_iterator const_indirect_contact_iterator; 00049 typedef typename mbd_types::indirect_body_iterator indirect_body_iterator; 00050 typedef typename mbd_types::const_indirect_body_iterator const_indirect_body_iterator; 00051 00052 indirect_constraint_iterator constraint_begin() { return indirect_constraint_iterator(m_constraints.begin()); } 00053 indirect_constraint_iterator constraint_end() { return indirect_constraint_iterator(m_constraints.end()); } 00054 00055 const_indirect_constraint_iterator constraint_begin() const { return const_indirect_constraint_iterator(m_constraints.begin()); } 00056 const_indirect_constraint_iterator constraint_end() const { return const_indirect_constraint_iterator(m_constraints.end()); } 00057 00058 indirect_contact_iterator contact_begin() { return indirect_contact_iterator(m_contacts.begin()); } 00059 indirect_contact_iterator contact_end() { return indirect_contact_iterator(m_contacts.end()); } 00060 00061 const_indirect_contact_iterator contact_begin() const { return const_indirect_contact_iterator(m_contacts.begin()); } 00062 const_indirect_contact_iterator contact_end() const { return const_indirect_contact_iterator(m_contacts.end()); } 00063 00064 indirect_body_iterator body_begin() { return indirect_body_iterator(m_bodies.begin()); } 00065 indirect_body_iterator body_end() { return indirect_body_iterator(m_bodies.end()); } 00066 00067 const_indirect_body_iterator body_begin() const { return const_indirect_body_iterator(m_bodies.begin()); } 00068 const_indirect_body_iterator body_end() const { return const_indirect_body_iterator(m_bodies.end()); } 00069 00070 size_type size_bodies() const { return m_bodies.size(); } 00071 size_type size_contacts() const { return m_contacts.size(); } 00072 00073 void clear() 00074 { 00075 m_bodies.clear(); 00076 m_constraints.clear(); 00077 m_contacts.clear(); 00078 } 00079 00080 }; 00081 00082 } //--- End of namespace mbd 00083 } //--- End of namespace OpenTissue 00084 00085 // OPENTISSUE_DYNAMICS_MBD_BODY_GROUP_H 00086 #endif