Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
extended.hh
1 // Copyright (C) 2008, 2009, 2011 EPITA Research and Development
2 // Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_IMAGE_DMORPH_EXTENDED_HH
28 # define MLN_CORE_IMAGE_DMORPH_EXTENDED_HH
29 
37 
38 # include <mln/core/internal/image_domain_morpher.hh>
39 # include <mln/core/site_set/box.hh>
40 
41 
42 namespace mln
43 {
44 
45 
46  // Forward declaration.
47  template <typename I> struct extended;
48 
49 
50  namespace internal
51  {
52 
54  template <typename I>
55  struct data< extended<I> >
56  {
57  data(I& ima, const box<mln_site(I)>& b_);
58 
59  I ima_;
60  box<mln_site(I)> b_;
61  };
62 
63  } // end of namespace mln::internal
64 
65 
66 
67  namespace trait
68  {
69 
70  template <typename I>
71  struct image_< extended<I> > : default_image_morpher< I,
72  mln_value(I),
73  extended<I> >
74  {
75  typedef trait::image::category::domain_morpher category;
76 
77  typedef trait::image::ext_domain::none ext_domain;
78  typedef trait::image::ext_value::irrelevant ext_value;
79  typedef trait::image::ext_io::irrelevant ext_io;
80 
81  typedef trait::image::value_storage::disrupted value_storage;
82  };
83 
84  } // end of namespace mln::trait
85 
86 
87 
91  //
92  template <typename I>
93  struct extended : public internal::image_domain_morpher< I,
94  box<mln_site(I)>,
95  extended<I> >,
96  private mlc_not_equal(mln_trait_image_ext_domain(I),
97  trait::image::ext_domain::none)::check_t
98  {
100  typedef mln_value(I) value;
101 
103  typedef tag::image_<I> skeleton; // This property is lost!
104 
106  extended();
107 
109  extended(I& ima, const box<mln_site(I)>& b);
110 
112  void init_(I& ima, const box<mln_site(I)>& b);
113 
115  const box<mln_site(I)>& domain() const;
116  };
117 
118 
119 
120  template <typename I, typename J>
121  void init_(tag::image_t, extended<I>& target, const J& model);
122 
123 
124  template <typename I, typename B>
125  extended<const I>
126  extended_to(const Image<I>& ima, const Box<B>& b);
127 
128  template <typename I, typename B>
129  extended<I>
130  extended_to(Image<I>& ima, const Box<B>& b);
131 
132 
133 
134 # ifndef MLN_INCLUDE_ONLY
135 
136  // init_
137 
138  template <typename I, typename J>
139  inline
140  void init_(tag::image_t, extended<I>& target, const J& model)
141  {
142  I ima;
143  init_(tag::image, ima, model);
145  init_(tag::bbox, b, model);
146  target.init_(ima, b);
147  }
148 
149 
150  // internal::data< extended<I> >
151 
152  namespace internal
153  {
154 
155  template <typename I>
156  inline
157  data< extended<I> >::data(I& ima, const box<mln_site(I)>& b)
158  : ima_(ima),
159  b_(b)
160  {
161  }
162 
163  } // end of namespace mln::internal
164 
165 
166  // extended<I>
167 
168  template <typename I>
169  inline
171  {
172  }
173 
174  template <typename I>
175  inline
176  extended<I>::extended(I& ima, const box<mln_site(I)>& b)
177  {
178  init_(ima, b);
179  }
180 
181  template <typename I>
182  inline
183  void
184  extended<I>::init_(I& ima, const box<mln_site(I)>& b)
185  {
186  mln_precondition(! this->is_valid());
187  this->data_ = new internal::data< extended<I> >(ima, b);
188  }
189 
190  template <typename I>
191  inline
192  const box<mln_site(I)>&
194  {
195  return this->data_->b_;
196  }
197 
198 
199  // extended_to
200 
201  template <typename I, typename B>
203  extended_to(const Image<I>& ima, const Box<B>& b)
204  {
205  mlc_not_equal(mln_trait_image_ext_domain(I),
206  trait::image::ext_domain::none)::check();
207  mln_precondition(exact(ima).is_valid());
208  extended<const I> tmp(exact(ima), exact(b));
209  return tmp;
210  }
211 
212  template <typename I, typename B>
213  extended<I>
214  extended_to(Image<I>& ima, const Box<B>& b)
215  {
216  mlc_not_equal(mln_trait_image_ext_domain(I),
217  trait::image::ext_domain::none)::check();
218  mln_precondition(exact(ima).is_valid());
219  extended<I> tmp(exact(ima), exact(b));
220  return tmp;
221  }
222 
223 # endif // ! MLN_INCLUDE_ONLY
224 
225 } // end of namespace mln
226 
227 
228 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENDED_HH