Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_EVALUATE_CONSTRAINTS_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_EVALUATE_CONSTRAINTS_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace mbd
00015 {
00016 namespace detail
00017 {
00033 template<typename group_type,typename real_type>
00034 size_t evaluate_constraints(
00035 group_type & group
00036 , real_type const & fps
00037 , bool const & use_stabilization
00038 , bool const & use_friction
00039 , bool const & use_bounce
00040 , bool const & use_erp
00041 )
00042 {
00043 typedef typename group_type::indirect_constraint_iterator indirect_constraint_iterator;
00044 typedef typename group_type::indirect_contact_iterator indirect_contact_iterator;
00045
00046 assert( fps >= 0 || !"evaluate_constraints(): fps must be positive");
00047 size_t cnt = 0;
00048
00049 for(indirect_constraint_iterator constraint = group.constraint_begin();constraint!=group.constraint_end();++constraint)
00050 {
00051 constraint->set_frames_per_second(fps);
00052 constraint->use_erp() = use_erp;
00053 constraint->evaluate();
00054 if(constraint->is_active())
00055 {
00056 constraint->set_jacobian_index(cnt);
00057 cnt += constraint->get_number_of_jacobian_rows();
00058 }
00059 }
00060 for(indirect_contact_iterator contact = group.contact_begin();contact!=group.contact_end();++contact)
00061 {
00062 contact->set_frames_per_second(fps);
00063 contact->use_erp() = use_erp;
00064 contact->set_use_stabilization(use_stabilization);
00065 contact->set_use_friction(use_friction);
00066 contact->set_use_bounce(use_bounce);
00067 contact->evaluate();
00068 if(contact->is_active())
00069 {
00070 contact->set_jacobian_index(cnt);
00071 cnt += contact->get_number_of_jacobian_rows();
00072 }
00073 }
00074 return cnt;
00075 }
00076 }
00077 }
00078 }
00079
00080 #endif