Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_INSCRIBED_CIRCUMSCRIBED_RADIUS_QUALITY_MEASURE_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_INSCRIBED_CIRCUMSCRIBED_RADIUS_QUALITY_MEASURE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_is_number.h>
00013 #include <OpenTissue/core/math/math_basic_types.h>
00014 #include <OpenTissue/core/geometry/geometry_sphere.h>
00015 #include <OpenTissue/core/geometry/geometry_circumscribed_sphere.h>
00016 #include <OpenTissue/core/geometry/geometry_compute_inscribed_sphere.h>
00017
00018 #include <boost/cast.hpp>
00019
00020 #include <cmath>
00021 #include <cassert>
00022
00023 namespace OpenTissue
00024 {
00025 namespace geometry
00026 {
00027
00042 template<typename vector3_type>
00043 inline typename vector3_type::value_type
00044 compute_inscribed_circumscribed_radius_quality_measure (
00045 vector3_type const & p0
00046 , vector3_type const & p1
00047 , vector3_type const & p2
00048 , vector3_type const & p3
00049 )
00050 {
00051 typedef typename vector3_type::value_type real_type;
00052 typedef OpenTissue::math::BasicMathTypes<real_type, size_t> math_types;
00053 typedef Sphere<math_types> sphere_type;
00054 typedef typename math_types::value_traits value_traits;
00055
00056 sphere_type sphere;
00057 compute_circumscribed_sphere( p0, p1, p2, p3, sphere);
00058 real_type r_out = sphere.radius();
00059
00060 real_type r_in;
00061 vector3_type center;
00062 compute_tetrahedron_inscribed_sphere( p0, p1, p2, p3, center, r_in);
00063
00064 if(r_in<value_traits::zero())
00065 {
00066
00067 r_in = -r_in;
00068 }
00069
00070 real_type quality = boost::numeric_cast<real_type>(3.0) * (r_in / r_out);
00071 assert( is_number( r_out ) || !"circumscribed radius was not a number" );
00072 assert( r_out >= value_traits::zero() || !"circumscribed radius must be non-negative" );
00073 assert( is_number( r_in ) || !"circumscribed radius was not a number" );
00074 assert( r_in >= value_traits::zero() || !"inscribed radius must be non-negative" );
00075 assert( r_in <= r_out || !"inscribed radius must be less than circumscribed radius" );
00076 assert( is_number( quality ) || !"quality was not a number" );
00077 assert( quality>= value_traits::zero() || !"invalid qualtiy value" );
00078 assert( quality<= value_traits::one() || !"invalid qualtiy value" );
00079 return quality;
00080 };
00081
00082 }
00083
00084 }
00085
00086
00087 #endif