contrib/tbl/vipl/accessors/vipl_accessors_vcl_vector.txx
Go to the documentation of this file.
00001 #ifndef vipl_accessors_vcl_vector_txx_
00002 #define vipl_accessors_vcl_vector_txx_
00003 
00004 #include "vipl_accessors_vcl_vector.h"
00005 #include <vipl/section/vipl_filterable_section_container_generator_vcl_vector.txx>
00006 #include <vcl_cassert.h>
00007 
00008 template <class DataType>
00009 DataType fgetpixel(vcl_vector<DataType> const& i, int x, int y, DataType /* dummy */)
00010 {
00011   assert(y==0);
00012   return i[x];
00013 }
00014 template <class DataType>
00015 void fsetpixel(vcl_vector<DataType>& i, int x, int y, DataType e) {
00016   assert(y==0);
00017   i[x] = e;
00018 }
00019 template <class DataType>
00020 DataType getpixel(vcl_vector<DataType> const& i, int x, int y, DataType /* dummy */) {
00021   if (x<0 || (unsigned)x>=i.size() || y!=0) return DataType();
00022   return i[x];
00023 }
00024 template <class DataType>
00025 void setpixel(vcl_vector<DataType>& i, int x, int y, DataType e) {
00026   assert(x>=0 && y==0);
00027   if ((unsigned)x>=i.size()) i.resize(x+1,0);
00028   i[x] = e;
00029 }
00030 
00031 #undef VIPL_INSTANTIATE_ACCESSORS
00032 #define VIPL_INSTANTIATE_ACCESSORS(T) \
00033 template T fgetpixel(vcl_vector<T > const&, int, int, T);\
00034 template void fsetpixel(vcl_vector<T >&, int, int, T);\
00035 template T getpixel(vcl_vector<T > const&, int, int, T);\
00036 template void setpixel(vcl_vector<T >&, int, int, T)
00037 
00038 #endif // vipl_accessors_vcl_vector_txx_