Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_COMPUTE_MIN_MAX_DISTANCE_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_COMPUTE_MIN_MAX_DISTANCE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/utility/gl/gl_util.h>
00013
00014 #include <OpenTissue/core/math/math_constants.h>
00015
00016 #include <boost/cast.hpp>
00017
00018 namespace OpenTissue
00019 {
00020 namespace mbd
00021 {
00022 template<typename configuration_type, typename real_type2>
00023 void compute_min_max_distance(configuration_type & configuration, real_type2 & min_value, real_type2 & max_value)
00024 {
00025 using std::max;
00026 using std::min;
00027
00028 typedef typename configuration_type::body_type body_type;
00029 typedef typename configuration_type::edge_type edge_type;
00030 typedef typename edge_type::contact_iterator contact_iterator;
00031 typedef typename body_type::real_type real_type;
00032 typedef typename body_type::vector3_type vector3_type;
00033 typedef typename body_type::matrix3x3_type matrix3x3_type;
00034 typedef typename body_type::quaternion_type quaternion_type;
00035 typedef typename configuration_type::edge_iterator edge_iterator;
00036
00037 real_type m = OpenTissue::math::detail::highest<real_type>();
00038 real_type M = OpenTissue::math::detail::lowest<real_type>();
00039
00040 for(edge_iterator edge = configuration.edge_begin();edge!=configuration.edge_end();++edge)
00041 {
00042 if(edge->is_up_to_date())
00043 {
00044 for(contact_iterator contact = edge->contact_begin();contact!=edge->contact_end();++contact)
00045 {
00046 m=min(m,contact->m_distance);
00047 M=max(m,contact->m_distance);
00048 }
00049 }
00050 }
00051
00052 min_value = boost::numeric_cast<real_type2>(m);
00053 max_value = boost::numeric_cast<real_type2>(M);
00054 }
00055
00056 }
00057 }
00058
00059 #endif