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 #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 }