00001
00007 #ifndef __WEIGHTSET_H__
00008 #define __WEIGHTSET_H__
00009
00010 #include <utility>
00011 #include <string>
00012 using std::string;
00013
00014 #include "matrix.h"
00015 #include "boundingbox.h"
00016 #include "scale.h"
00017 #include "allocatingpointer.h"
00018
00019
00020
00023 template <class MatrixT, class BoundsT, class MapBaseType, class MapType>
00024 class WeightSet {
00025 public:
00026 typedef MatrixT Matrix;
00027 typedef BoundsT Bounds;
00028 typedef typename Matrix::size_type size_type;
00029
00031 WeightSet(const Matrix& matrix, const Bounds& bounds) : m(matrix), b(bounds) { };
00032
00034 WeightSet(Matrix* matrix, Bounds* bounds) : m(*matrix), mptr(matrix), b(*bounds), bptr(bounds) { };
00035
00036 const Matrix& matrix() const { return m; }
00037
00038 const Bounds& bounds() const { return b; }
00039
00041 template <class MapMatrix>
00042 MapBaseType* as_map(const MapMatrix& reference, const Scale::Linear<double>& scale=Scale::Linear<double>()) const {
00043 typedef Boundary::AAArbitraryRectangle<double,int> Region;
00044 const Region region(b.aarectangle().corners().yl,
00045 b.aarectangle().corners().xl,
00046 b.aarectangle().corners().yl-reference.nrows(),
00047 b.aarectangle().corners().xl-reference.ncols());
00048 return new MapType(new Matrix(m),scale,region);
00049 }
00050
00051 private:
00052 const Matrix& m; MemoryReference<Matrix> mptr;
00053 const Bounds& b; MemoryReference<Bounds> bptr;
00054 };
00055
00056
00057 #endif