00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "Gral/Base/mapped-grid-function.h"
00019 #include "Gral/Grids/CartesianND/all.h"
00020
00021 #include <iostream>
00022
00023 class mymap {
00024 public:
00025 typedef double result_type;
00026 typedef int argument_type;
00027
00028 result_type operator()(argument_type x) const { return 0.5*x;}
00029 };
00030
00031 int main() {
00032
00033 typedef GrAL::cartesiannd::grid<2> grid_type;
00034 typedef GrAL::grid_types<grid_type > gt;
00035 typedef gt::vertex_index_type it;
00036 GrAL::cartesiannd::grid<2> R(it(3,3));
00037 typedef GrAL::grid_function<gt::Vertex, int> gf_type;
00038
00039 gf_type gf(R, 1);
00040 int cnt = 0;
00041 for(gt::VertexIterator v(R); !v.IsDone(); ++v)
00042 gf[*v] = ++cnt;
00043
00044 typedef mymap map_type;
00045 map_type f;
00046 GrAL::mapped_grid_function<const gf_type, const map_type> mgf(gf, f);
00047
00048 for(gt::VertexIterator v(R); !v.IsDone(); ++v)
00049 std::cout << gf(*v) << "->" << mgf(*v) << "\n";
00050
00051 }
00052