Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory 00002 // (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 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 // FIXME: Keep this? (See below.) 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 | Complex. | 00047 `----------*/ 00048 00049 /* A 2-d (simplicial) complex and its adjacency graph. 00050 00051 c 0 1 2 3 00052 r .------------------------ 00053 | v0 e3 v3 00054 0 | o-----------o v0----e3----v3 00055 | / \ ,-----. / / \ | / 00056 | / . \ \ t1/ / / \ t1 / 00057 1 | e0 / / \ e1\ / / e4 e0. ,e1ยด `e4 00058 | / /t0 \ \ ' / / t0 \ / 00059 | / `-----' \ / / | \ / 00060 2 | o-----------o v1----e2----v2 00061 | v1 e2 v2 00062 00063 v = vertex 00064 e = edge 00065 t = triangle 00066 */ 00067 00068 00069 const unsigned D = 2; 00070 00071 mln::topo::complex<D> c; 00072 00073 // 0-faces (points). 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 // 1-faces (segments). 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 // 2-faces (triangles). 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 | Complex geometry (location). | 00093 `------------------------------*/ 00094 00095 typedef mln::discrete_plane_2complex_geometry G; 00096 G geom; 00097 geom.add_location(mln::point2d(0,1)); // 0-face #0. 00098 geom.add_location(mln::point2d(2,0)); // 0-face #1. 00099 geom.add_location(mln::point2d(2,2)); // 0-face #2. 00100 geom.add_location(mln::point2d(0,3)); // 0-face #3. 00101 00102 00103 /*---------------------. 00104 | Complex-based pset. | 00105 `---------------------*/ 00106 00107 // A pset. 00108 mln::p_complex<D, G> pc(c, geom); 00109 mln::topo::face<D> af(e0); 00110 // An associated psite. 00111 mln::complex_psite<D, G> cs(pc, af); 00112 00113 00114 /*--------------------. 00115 | Faces-based psets. | 00116 `--------------------*/ 00117 00118 /* FIXME: Not that p_faces have become less interesting since the 00119 introduction of p_complex_faces_{fwd,bkd}_piter_. Keep this part 00120 of the test? */ 00121 00122 /* FIXME: Move this parts out of this function? (into an existing 00123 test?) */ 00124 00125 // Pset of 0-faces. 00126 mln::p_faces<0, D, G> pf0(c); 00127 // Pset of 1-faces. 00128 mln::p_faces<1, D, G> pf1(c); 00129 // Pset of 2-faces. 00130 mln::p_faces<2, D, G> pf2(c); 00131 00132 // Some psites on faces. 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 | Complex-based image. | 00140 `----------------------*/ 00141 00142 using mln::value::int_u8; 00143 00144 // An image type built on a 2-complex with mln::int_u8 values on 00145 // each face. 00146 typedef mln::complex_image<D, G, int_u8> ima_t; 00147 00148 // Values. 00149 mln::metal::vec<D + 1, std::vector< int_u8 > > values; 00150 // Assign 0 to 0-faces, 1 to 1-faces and 2 to 2-faces. 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 // Create and init an image based on PC. 00156 ima_t ima(pc, values); 00157 00158 // Check the value associated to edge E0 (through complex psite CS). 00159 mln_postcondition(ima(cs) == 1u); 00160 00161 return ima; 00162 } 00163 00164 #endif // ! TESTS_CORE_IMAGE_COMPLEX_IMAGE_HH