00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00021 #include "Gral/Geometries/cell-as-volume.h"
00022
00023 #include "Gral/Grids/CartesianND/all.h"
00024 #include "Geometry/affine-mapping.h"
00025 #include "Geometry/matrix.h"
00026
00027 #include <iostream>
00028
00029 using namespace GrAL;
00030
00031 namespace cnd = cartesiannd;
00032 typedef cnd::grid<2> grid_type;
00033 typedef cnd::default_coord<cnd::grid<2> >::type coord2d;
00034 typedef matrix<2,2,0> matrix2d;
00035 typedef affine_mapping<matrix2d, coord2d> mapping2d;
00036 typedef cnd::mapped_geometry<grid_type, mapping2d> geom_type;
00037 typedef grid_types<grid_type> gt;
00038
00039 template class cell_as_volume<geom_type, gt::Cell, gt>;
00040
00041 int main()
00042 {
00043 using namespace std;
00044 grid_type R(gt::index_type(5,5));
00045 matrix2d A(0.0); A(0,0) = A(1,1) = 1.0;
00046 mapping2d M(A);
00047 geom_type GeomR(R, gt::index_type(0,0), gt::index_type(1,1), M);
00048 typedef cell_as_volume<geom_type, gt::Cell, gt> volume_type;
00049 volume_type Vol(GeomR, * R.FirstCell());
00050
00051 cout << "Grid 1:\n";
00052 for(gt::VertexIterator v(R); ! v.IsDone(); ++v)
00053 cout << "V @ " << GeomR.coord(*v) << " is "
00054 << (Vol.is_inside(GeomR.coord(*v)) ? " " : " not ") << "inside" << endl;
00055
00056 for(gt::CellIterator c(R); ! c.IsDone(); ++c)
00057 cout << "C " << (*c).index() << ": " << Vol.name(Vol.intersection_check(*c, GeomR)) << endl;
00058
00059
00060 grid_type R2(gt::index_type(0,0), gt::index_type(3,3));
00061 matrix2d A2(0.0); A2(0,0) = A2(1,1) = 0.25;
00062 mapping2d M2(A2);
00063 geom_type GeomR2(R2,M2);
00064
00065 cout << "Grid 2:\n";
00066 for(gt::VertexIterator v(R2); ! v.IsDone(); ++v)
00067 cout << "V @ " << GeomR2.coord(*v) << " is "
00068 << (Vol.is_inside(GeomR2.coord(*v)) ? " " : " not ") << "inside" << endl;
00069 for(gt::CellIterator c(R2); ! c.IsDone(); ++c)
00070 cout << "C2 " << (*c).index() << ": " << Vol.name(Vol.intersection_check(*c, GeomR2)) << endl;
00071 }
00072