00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00029 
00030 #ifndef TESTS_CORE_IMAGE_COMPLEX_IMAGE_HH
00031 # define TESTS_CORE_IMAGE_COMPLEX_IMAGE_HH
00032 
00033 # include <mln/core/image/complex_image.hh>
00034 # include <mln/core/alias/complex_image.hh>
00035 # include <mln/value/int_u8.hh>
00036 
00037 
00038 # include <mln/core/site_set/p_faces.hh>
00039 
00040 
00041 inline
00042 mln::int_u8_2complex_image2d
00043 make_test_complex_image()
00044 {
00045   
00046 
00047 
00048 
00049   
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069   const unsigned D = 2;
00070 
00071   mln::topo::complex<D> c;
00072 
00073   
00074   mln::topo::n_face<0, D> v0 = c.add_face();
00075   mln::topo::n_face<0, D> v1 = c.add_face();
00076   mln::topo::n_face<0, D> v2 = c.add_face();
00077   mln::topo::n_face<0, D> v3 = c.add_face();
00078  
00079   
00080   mln::topo::n_face<1, D> e0 = c.add_face(v0 + v1);
00081   mln::topo::n_face<1, D> e1 = c.add_face(v0 + v2);
00082   mln::topo::n_face<1, D> e2 = c.add_face(v1 + v2);
00083   mln::topo::n_face<1, D> e3 = c.add_face(v0 + v3);
00084   mln::topo::n_face<1, D> e4 = c.add_face(v2 + v3);
00085 
00086   
00087   mln::topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
00088   mln::topo::n_face<2, D> t1 = c.add_face(e1 + e3 + e4);
00089 
00090 
00091   
00092 
00093 
00094 
00095   typedef mln::discrete_plane_2complex_geometry G;
00096   G geom;
00097   geom.add_location(mln::point2d(0,1)); 
00098   geom.add_location(mln::point2d(2,0)); 
00099   geom.add_location(mln::point2d(2,2)); 
00100   geom.add_location(mln::point2d(0,3)); 
00101 
00102 
00103   
00104 
00105 
00106 
00107   
00108   mln::p_complex<D, G> pc(c, geom);
00109   mln::topo::face<D> af(e0);
00110   
00111   mln::complex_psite<D, G> cs(pc, af);
00112 
00113 
00114   
00115 
00116 
00117 
00118   
00119 
00120 
00121 
00122   
00123 
00124 
00125   
00126   mln::p_faces<0, D, G> pf0(c);
00127   
00128   mln::p_faces<1, D, G> pf1(c);
00129   
00130   mln::p_faces<2, D, G> pf2(c);
00131 
00132   
00133   mln::faces_psite<0, D, G> fs0(pf0, v0);
00134   mln::faces_psite<1, D, G> fs1(pf1, e0);
00135   mln::faces_psite<2, D, G> fs2(pf2, t0);
00136 
00137 
00138   
00139 
00140 
00141 
00142   using mln::value::int_u8;
00143 
00144   
00145   
00146   typedef mln::complex_image<D, G, int_u8> ima_t;
00147 
00148   
00149   mln::metal::vec<D + 1, std::vector< int_u8 > > values;
00150   
00151   for (unsigned d = 0; d <= D; ++d)
00152     for (unsigned n = 0; n < pc.cplx().nfaces(d); ++n)
00153       values[d].push_back(d);
00154 
00155   
00156   ima_t ima(pc, values);
00157 
00158   
00159   mln_postcondition(ima(cs) == 1u);
00160 
00161   return ima;
00162 }
00163 
00164 #endif // ! TESTS_CORE_IMAGE_COMPLEX_IMAGE_HH