Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_MINMAX_FACE_AREA_H
00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MESH_COMPUTE_MINMAX_FACE_AREA_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace mesh
00015 {
00016
00024 template< typename mesh_type >
00025 void compute_minmax_face_area( mesh_type const & mesh, double & min_area, double & max_area )
00026 {
00027 using std::max;
00028 using std::min;
00029 using std::fabs;
00030
00031 typedef typename mesh_type::const_face_iterator face_iterator;
00032 typedef typename mesh_type::const_face_vertex_circulator face_vertex_circulator;
00033 typedef typename mesh_type::math_types math_types;
00034 typedef typename math_types::value_traits value_traits;
00035 typedef typename math_types::vector3_type vector3_type;
00036 typedef typename math_types::real_type real_type;
00037
00038 real_type max_area_sqr = 0;
00039 real_type min_area_sqr = math::detail::highest<real_type>();
00040
00041 for(face_iterator f = mesh.face_begin();f!=mesh.face_end();++f)
00042 {
00043 face_vertex_circulator v0(*f);
00044 face_vertex_circulator v1(*f);++v1;
00045 face_vertex_circulator v2(*f);--v2;
00046
00047 vector3_type const & p0 = v0->m_coord;
00048 vector3_type const & p1 = v1->m_coord;
00049 vector3_type const & p2 = v2->m_coord;
00050 vector3_type u1 = p2 - p1;
00051 vector3_type u2 = p1 - p0;
00052 vector3_type u1xu2 = u1 % u2;
00053 real_type area_sqr = u1xu2*u1xu2;
00054 max_area_sqr = max( max_area_sqr, area_sqr);
00055 min_area_sqr = min( min_area_sqr, area_sqr);
00056 }
00057 max_area = sqrt(max_area_sqr)*.5;
00058 min_area = sqrt(min_area_sqr)*.5;
00059
00060 }
00061
00062 }
00063 }
00064
00065
00066 #endif