Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MAKE_DISK_H
00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_COMMON_UTIL_MAKE_DISK_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/containers/mesh/common/util/mesh_profile_sweep.h>
00013 #include <OpenTissue/core/math/math_constants.h>
00014
00015 #include <vector>
00016
00017 namespace OpenTissue
00018 {
00019 namespace mesh
00020 {
00021
00022
00034 template<typename mesh_type, typename real_type>
00035 bool make_disk(
00036 real_type const & radius1
00037 , real_type const & radius2
00038 , unsigned int slices
00039 , unsigned int segments
00040 , mesh_type & mesh
00041 )
00042 {
00043 typedef typename mesh_type::math_types math_types;
00044 typedef typename math_types::value_traits value_traits;
00045 typedef typename math_types::vector3_type vector3_type;
00046
00047
00048 assert(slices>=3);
00049 assert(segments>=2);
00050
00051
00052 std::vector<vector3_type> profile(segments+3);
00053 real_type delta_angle = static_cast<real_type>(math::detail::pi<real_type>()/segments);
00054 real_type angle = delta_angle;
00055
00056 profile[0] = vector3_type(0,0,-radius2);
00057 profile[1] = vector3_type(-radius1,0,-radius2);
00058 for(unsigned int s=2;s<=(segments);++s)
00059 {
00060 real_type cosinus = static_cast<real_type>(std::cos(angle));
00061 real_type sinus = static_cast<real_type>(std::sin(angle));
00062
00063 profile[s](0) = - sinus*radius2 - radius1;
00064 profile[s](1) = 0;
00065 profile[s](2) = - cosinus * radius2 ;
00066
00067 angle += delta_angle;
00068 }
00069 profile[segments+1] = vector3_type(-radius1,0,radius2);
00070 profile[segments+2] = vector3_type(0,0,radius2);
00071 return profile_sweep(profile.begin(),profile.end(),2.0*math::detail::pi<real_type>(),slices,mesh);
00072 }
00073
00074 }
00075 }
00076
00077
00078 #endif