Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #include <mln/util/tree.hh> 00027 #include <mln/core/contract.hh> 00028 #include <mln/core/image/image2d.hh> 00029 #include <mln/core/site_set/p_set.hh> 00030 #include <mln/value/int_u8.hh> 00031 #include <mln/data/stretch.hh> 00032 #include <mln/data/fill.hh> 00033 #include <mln/data/compare.hh> 00034 #include <mln/io/pgm/save.hh> 00035 #include <vector> 00036 #include <mln/util/tree_to_image.hh> 00037 #include <mln/debug/println.hh> 00038 00039 template <typename P, typename V> 00040 struct fllt_node 00041 { 00042 V value; 00043 mln::p_set<P> points; 00044 mln::p_set<P> holes; 00045 }; 00046 00047 00048 int main (void) 00049 { 00050 using namespace mln; 00051 using value::int_u8; 00052 00053 typedef fllt_node<point2d , int_u8> I; 00054 00055 image2d<int_u8> output (16, 16); 00056 data::fill(output, 0); 00057 00058 I s1; 00059 I s2; 00060 I s3; 00061 I s4; 00062 I s5; 00063 I s6; 00064 I s7; 00065 00066 for (int i = 0; i < 4; ++i) 00067 for (int j = 0; j < 4; ++j) 00068 s1.points.insert(point2d(i, j)); 00069 s1.value = 60; 00070 for (int i = 8; i < 16; ++i) 00071 for (int j = 0; j < 4; ++j) 00072 s2.points.insert(point2d(i, j)); 00073 s1.value = 100; 00074 for (int i = 0; i < 4; ++i) 00075 for (int j = 0; j < 4; ++j) 00076 s3.points.insert(point2d(i, j)); 00077 s3.value = 110; 00078 for (int i = 10; i < 12; ++i) 00079 for (int j = 0; j < 2; ++j) 00080 s4.points.insert(point2d(i, j)); 00081 s4.value = 170; 00082 for (int i = 8; i < 14; ++i) 00083 for (int j = 0; j < 2; ++j) 00084 s5.points.insert(point2d(i, j)); 00085 s5.value = 180; 00086 for (int i = 13; i < 15; ++i) 00087 for (int j = 2; j < 4; ++j) 00088 s6.points.insert(point2d(i, j)); 00089 s6.value = 210; 00090 for (int i = 0; i < 16; ++i) 00091 for (int j = 0; j < 8; ++j) 00092 s7.points.insert(point2d(i, j)); 00093 s7.value = 10; 00094 00095 util::tree_node<I> node(s1); 00096 node.add_child(s2); 00097 node.add_child(s3); 00098 node.add_child(s4); 00099 node.add_child(s5); 00100 node.add_child(s6); 00101 util::tree<I> tree (&node); 00102 tree.add_tree_up(s7); 00103 util::tree_to_image(tree, output); 00104 00105 int_u8 vs[16][16] = { 00106 00107 00108 {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00109 {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00110 {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00111 {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00112 { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00113 { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00114 { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00115 { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00116 {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00117 {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00118 {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00119 {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00120 {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00121 {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00122 {252, 252, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00123 {252, 252, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0} 00124 00125 }; 00126 00127 image2d<int_u8> ref (make::image(vs)); 00128 mln_assertion(ref == output); 00129 }