Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_COMPUTE_CONTACT_COUNT_MATRIX_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_COMPUTE_CONTACT_COUNT_MATRIX_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace mbd
00015 {
00016
00029 template< typename indirect_body_iterator,typename matrix_type>
00030 void compute_contact_count_matrix(indirect_body_iterator begin, indirect_body_iterator end,matrix_type & C)
00031 {
00032 typedef typename indirect_body_iterator::value_type body_type;
00033 typedef typename body_type::math_policy math_policy;
00034 typedef typename body_type::indirect_edge_iterator indirect_edge_iterator;
00035
00036
00037 typedef typename matrix_type::value_type value_type;
00038
00039 size_t n = std::distance(begin,end);
00040
00041 math_policy::resize(C,n,n);
00042 C.clear();
00043
00044 typename body_type::size_type i = 0;
00045 for(indirect_body_iterator body=begin;body!=end;++body,++i)
00046 body->m_tag = i;
00047
00048 for(indirect_body_iterator body=begin;body!=end;++body)
00049 {
00050 for(indirect_edge_iterator edge=body->edge_begin();edge!=body->edge_end();++edge)
00051 {
00052 if(edge->is_up_to_date())
00053 {
00054 C(edge->get_body_A()->m_tag,edge->get_body_B()->m_tag) = value_type(edge->size_contacts());
00055 }
00056 }
00057 }
00058 }
00059
00060 }
00061
00062 }
00063
00064
00065 #endif