contrib/tbl/vipl/vipl_with_section/accessors/vipl_accessors_section.txx
Go to the documentation of this file.
00001 #ifndef vipl_accessors_section_txx_
00002 #define vipl_accessors_section_txx_
00003 
00004 #include "vipl_accessors_section.h"
00005 #include "../vipl_filterable_section_container_generator_section.txx"
00006 
00007 template <class DataType>
00008 DataType fgetpixel(section<DataType,2> const& i, int x, int y, DataType /* dummy */) {
00009   return i.Value(x,y);
00010 }
00011 template <class DataType>
00012 void fsetpixel(section<DataType,2>& i, int x, int y, DataType e) {
00013   i.Set(e,x,y);
00014 }
00015 template <class DataType>
00016 DataType getpixel(section<DataType,2> const& i, int x, int y, DataType /* dummy */) {
00017   if (x<0 || y<0 || x>=int(i.Size(0)) || y>=int(i.Size(1))) return DataType();
00018   return i.Value(x,y);
00019 }
00020 template <class DataType>
00021 void setpixel(section<DataType,2>& i, int x, int y, DataType e) {
00022   if (x<0 || y<0 || x>=int(i.Size(0)) || y>=int(i.Size(1))) return;
00023   i.Set(e,x,y);
00024 }
00025 
00026 #undef VIPL_INSTANTIATE_ACCESSORS
00027 #define VIPL_INSTANTIATE_ACCESSORS(T) \
00028 template T fgetpixel(section<T,2> const&, int, int, T);\
00029 template void fsetpixel(section<T,2>&, int, int, T);\
00030 template T getpixel(section<T,2> const&, int, int, T);\
00031 template void setpixel(section<T,2>&, int, int, T)
00032 
00033 #endif // vipl_accessors_section_txx_