contrib/brl/bseg/bbgm/bbgm_planes_to_sample.h
Go to the documentation of this file.
00001 // This is brl/bseg/bbgm/bbgm_planes_to_sample.h
00002 #ifndef bbgm_planes_to_sample_h_
00003 #define bbgm_planes_to_sample_h_
00004 //:
00005 // \file
00006 // \brief Templated Helper function extracting a data sample from image planes
00007 // \author Matt Leotta (mleotta@lems.brown.edu)
00008 // \date June 13, 2006
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   (none yet)
00013 // \endverbatim
00014 
00015 #include <vcl_cstddef.h>
00016 
00017 template <class T1, class T2, unsigned n>
00018 struct bbgm_planes_to_sample
00019 {
00020   static void apply(const T1* data, T2& sample, vcl_ptrdiff_t step){
00021     typename T2::iterator s_itr = sample.begin();
00022     for (unsigned int p=0; p<n; ++p, data += step, ++s_itr){
00023       *s_itr = *data;
00024     }
00025   }
00026 };
00027 
00028 template <class T1, class T2>
00029 struct bbgm_planes_to_sample<T1,T2,3>
00030 {
00031   static void apply(const T1* data, T2& sample, vcl_ptrdiff_t step){
00032   typename T2::iterator s_itr = sample.begin();
00033   *s_itr = *data;
00034   *(++s_itr) = *(data+=step);
00035   *(++s_itr) = *(data+=step);
00036   }
00037 };
00038 
00039 template <class T1, class T2>
00040 struct bbgm_planes_to_sample<T1,T2,1>
00041 {
00042   static void apply(const T1* data, T2& sample, vcl_ptrdiff_t /*step*/){
00043     sample = *data;
00044   }
00045 };
00046 
00047 
00048 #endif // bbgm_planes_to_sample_h_