00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef VECTORCOMPONENTACCESSOR_H
00010 #define VECTORCOMPONENTACCESSOR_H
00011
00012 #include <core/imaging2.hpp>
00013
00014 namespace imaging
00015 {
00016
00034 template <class vector_image_t>
00035 class VectorComponentAccessor : public ImageAccessorInterface<vector_image_t, typename vector_image_t::data_t::data_t>
00036 {
00037 public:
00038 typedef typename vector_image_t::data_t::data_t data_t;
00039 static const size_t dimension =
00040 ImageAccessorInterface<vector_image_t, data_t>::dimension;
00041 private:
00043 class data_reference
00044 {
00045 VectorComponentAccessor<vector_image_t> & _accessor_reference;
00046 const ublas::fixed_vector<size_t, dimension> & _index_reference;
00047
00048 public:
00049 data_reference(VectorComponentAccessor<vector_image_t> & accessor, const ublas::fixed_vector<size_t, dimension> & index) : _accessor_reference(accessor), _index_reference(index) {}
00050
00051 float_t operator=(const float_t & input)
00052 { _accessor_reference._image_reference[_index_reference](_accessor_reference._component) = input; return input; }
00053
00054 operator float_t() const { return _accessor_reference._image_reference[_index_reference](_accessor_reference._component); }
00055 };
00058 size_t _component;
00059
00060 public:
00065 VectorComponentAccessor(vector_image_t & image, size_t component) : ImageAccessorInterface<vector_image_t, data_t>(image), _component(component) {}
00066
00067 data_t operator[](const ublas::fixed_vector<size_t, dimension> & index) const { return ImageAccessorInterface<vector_image_t, data_t>::_image_reference[index](_component); }
00068
00069 data_reference operator[](const ublas::fixed_vector<size_t, dimension> & index) { return data_reference(*this, index); }
00070 };
00071 }
00072
00073 #endif