Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_UNIFORM_POINT_SAMPLING_H
00002 #define OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_UNIFORM_POINT_SAMPLING_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/containers/grid/util/functions.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace grid
00017 {
00018
00026 template<typename grid_type,typename vector3_container>
00027 inline void uniform_point_sampling(
00028 grid_type const & phi
00029 , vector3_container & points
00030 , size_t sub_sample = 2u
00031 )
00032 {
00033 typedef typename vector3_container::value_type vector3_type;
00034 typedef typename vector3_type::value_type real_type;
00035
00036 points.clear();
00037
00038 real_type min_x = phi.min_coord(0);
00039 real_type min_y = phi.min_coord(1);
00040 real_type min_z = phi.min_coord(2);
00041
00042 real_type max_x = phi.max_coord(0);
00043 real_type max_y = phi.max_coord(1);
00044 real_type max_z = phi.max_coord(2);
00045
00046 real_type dx = phi.dx()*sub_sample;
00047 real_type dy = phi.dy()*sub_sample;
00048 real_type dz = phi.dz()*sub_sample;
00049
00050 for ( real_type x = (min_x+dx); x < (max_x-dx); x += dx )
00051 for ( real_type y = (min_y+dy); y < (max_y-dy); y += dy )
00052 for ( real_type z = (min_z+dz); z < (max_z-dz); z += dz )
00053 {
00054 points.push_back( vector3_type( x, y, z ) );
00055 }
00056 }
00057
00058 }
00059 }
00060
00061
00062 #endif