Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_AABB_FIT_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_AABB_FIT_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <cassert>
00013 #include <OpenTissue/core/math/math_constants.h>
00014
00015
00016 namespace OpenTissue
00017 {
00018 namespace geometry
00019 {
00020
00046 template <typename vector3_iterator,typename aabb_type>
00047 void aabb_fit(vector3_iterator begin, vector3_iterator end,aabb_type & aabb)
00048 {
00049 typedef typename aabb_type::real_type real_type;
00050
00051 assert(begin!=end || !"aabb_fit(): beging was equal to end");
00052 aabb.min()(0) = aabb.min()(1)= aabb.min()(2) = math::detail::highest<real_type>();
00053 aabb.max()(0) = aabb.max()(1)= aabb.max()(2) = math::detail::lowest<real_type>();
00054 for(vector3_iterator v=begin; v!=end; ++v)
00055 {
00056 aabb.min() = min( aabb.min(), *v);
00057 aabb.max() = max( aabb.max(), *v);
00058 }
00059 }
00060
00061 }
00062 }
00063
00064
00065 #endif