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_fast.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_fast_to_image.hh> 00037 #include <mln/debug/println.hh> 00038 00039 00040 template <typename P, typename V> 00041 struct fllt_node 00042 { 00043 V value; 00044 mln::p_set<P> points; 00045 mln::p_set<P> holes; 00046 }; 00047 00048 00049 int main() 00050 { 00051 using namespace mln; 00052 using value::int_u8; 00053 00054 typedef fllt_node<point2d , int_u8> I; 00055 00056 I s1; 00057 I s2; 00058 I s3; 00059 I s4; 00060 I s5; 00061 I s6; 00062 I s7; 00063 00064 for (int i = 0; i < 4; ++i) 00065 for (int j = 0; j < 4; ++j) 00066 s1.points.insert(point2d(i, j)); 00067 s1.value = 60; 00068 for (int i = 8; i < 16; ++i) 00069 for (int j = 0; j < 4; ++j) 00070 s2.points.insert(point2d(i, j)); 00071 s1.value = 100; 00072 for (int i = 0; i < 4; ++i) 00073 for (int j = 0; j < 4; ++j) 00074 s3.points.insert(point2d(i, j)); 00075 s3.value = 110; 00076 for (int i = 10; i < 12; ++i) 00077 for (int j = 0; j < 2; ++j) 00078 s4.points.insert(point2d(i, j)); 00079 s4.value = 170; 00080 for (int i = 8; i < 16; ++i) 00081 for (int j = 0; j < 2; ++j) 00082 s5.points.insert(point2d(i, j)); 00083 s5.value = 180; 00084 for (int i = 8; i < 16; ++i) 00085 for (int j = 2; j < 4; ++j) 00086 s6.points.insert(point2d(i, j)); 00087 s6.value = 210; 00088 for (int i = 0; i < 16; ++i) 00089 for (int j = 0; j < 8; ++j) 00090 s7.points.insert(point2d(i, j)); 00091 s7.value = 10; 00092 00093 util::tree_fast<I> tree(s1); 00094 tree.add_child(tree.root_, s2); 00095 tree.add_child(tree.root_, s3); 00096 tree.add_child(tree.root_, s4); 00097 tree.add_child(tree.root_, s5); 00098 tree.add_child(tree.root_, s6); 00099 tree.add_parent(s7); 00100 image2d<int_u8> output (16, 16); 00101 data::fill(output, 0); 00102 util::tree_fast_to_image(tree, output); 00103 00104 int_u8 vs[16][16] = { 00105 00106 {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00107 {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 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 { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00111 { 10, 10, 10, 10, 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 {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00115 {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00116 {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00117 {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00118 {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00119 {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}, 00120 {180, 180, 210, 210, 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 00123 }; 00124 00125 debug::println(output); 00126 image2d<int_u8> ref (make::image(vs)); 00127 mln_assertion(ref == output); 00128 }