Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_SPLIT2SLICES_H
00002 #define OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_SPLIT2SLICES_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <cassert>
00013
00014 namespace OpenTissue
00015 {
00016 namespace grid
00017 {
00018
00026 template <typename grid_type,typename grid_container>
00027 inline void split2slices(grid_type & grid, grid_container & slices, size_t axis = 2)
00028 {
00029 typename grid_type::math_types math_types;
00030 typename math_types::vector3_type vector3_type;
00031
00032 assert( axis==2 || !"split2slices(): Only splits along k-axis is currently supported");
00033
00034 slices.clear();
00035
00036 if (axis != 2)
00037 return;
00038
00039 vector3_type min_coord = grid.min_coord();
00040 vector3_type max_coord = grid.max_coord();
00041 min_coord(2) = 0;
00042 max_coord(2) = 0;
00043 for (size_t z = 0; z < grid.K(); ++z)
00044 {
00045
00046 grid_type slice;
00047 slice.create(min_coord, max_coord, grid.I(), grid.J(), 2);
00048 for (size_t y = 0; y < grid.J(); ++y)
00049 for (size_t x = 0; x < grid.I(); ++x)
00050 {
00051 slice(x, y, 0) = grid(x, y, z);
00052 slice(x, y, 1) = grid(x, y, z);
00053 }
00054 slices.push_back(slice);
00055 }
00056 }
00057
00058 }
00059
00060 }
00061
00062
00063 #endif