Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_PLANE_AABB_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_PLANE_AABB_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_constants.h>
00013
00014 #include <OpenTissue/core/geometry/geometry_aabb.h>
00015
00016 namespace OpenTissue
00017 {
00018 namespace geometry
00019 {
00020
00029 template<typename vector3_type,typename real_type>
00030 void compute_plane_aabb(vector3_type const & n,real_type const & w,vector3_type & min_coord,vector3_type & max_coord)
00031 {
00032 real_type thickness = 10.;
00033 if(n(0)==0 && n(1)==0 )
00034 {
00035 min_coord(0) = math::detail::lowest<real_type>();
00036 min_coord(1) = math::detail::lowest<real_type>();
00037 max_coord(0) = math::detail::highest<real_type>();
00038 max_coord(1) = math::detail::highest<real_type>();
00039 min_coord(2) = w - thickness;
00040 max_coord(2) = w + thickness;
00041 }
00042 else if(n(0)==0 && n(2)==0 )
00043 {
00044 min_coord(0) = math::detail::lowest<real_type>();
00045 min_coord(2) = math::detail::lowest<real_type>();
00046 max_coord(0) = math::detail::highest<real_type>();
00047 max_coord(2) = math::detail::highest<real_type>();
00048 min_coord(1) = w - thickness;
00049 max_coord(1) = w + thickness;
00050 }
00051 else if(n(1)==0 && n(2)==0 )
00052 {
00053 min_coord(1) = math::detail::lowest<real_type>();
00054 min_coord(2) = math::detail::lowest<real_type>();
00055 max_coord(1) = math::detail::highest<real_type>();
00056 max_coord(2) = math::detail::highest<real_type>();
00057 min_coord(0) = w - thickness;
00058 max_coord(0) = w + thickness;
00059 }
00060 else
00061 {
00062 min_coord(0) = math::detail::lowest<real_type>();
00063 min_coord(1) = math::detail::lowest<real_type>();
00064 min_coord(2) = math::detail::lowest<real_type>();
00065 max_coord(0) = math::detail::highest<real_type>();
00066 max_coord(1) = math::detail::highest<real_type>();
00067 max_coord(2) = math::detail::highest<real_type>();
00068 }
00069 }
00070
00079 template<typename plane_type,typename aabb_type>
00080 void compute_plane_aabb(plane_type const & plane,aabb_type & aabb)
00081 {
00082 compute_plane_aabb(plane.n(),plane.w(),aabb.min(),aabb.max());
00083 }
00084
00093 template<typename plane_type>
00094 geometry::AABB<typename plane_type::math_types> compute_plane_aabb(plane_type const & plane)
00095 {
00096 geometry::AABB<typename plane_type::math_types> aabb;
00097 compute_plane_aabb(plane,aabb);
00098 return aabb;
00099 }
00100
00101 }
00102 }
00103
00104
00105 #endif