$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
extended.hh
1 // Copyright (C) 2008, 2009, 2011, 2012, 2013 EPITA Research and
2 // Development 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 
56  template <typename I>
57  struct data< extended<I> >
58  {
59  data(I& ima, const box<mln_site(I)>& b_);
60 
61  I ima_;
62  box<mln_site(I)> b_;
63  };
64 
65  } // end of namespace mln::internal
66 
67 
68 
69  namespace trait
70  {
71 
72  template <typename I>
73  struct image_< extended<I> > : default_image_morpher< I,
74  mln_value(I),
75  extended<I> >
76  {
77  typedef trait::image::category::domain_morpher category;
78 
79  typedef trait::image::ext_domain::none ext_domain;
80  typedef trait::image::ext_value::irrelevant ext_value;
81  typedef trait::image::ext_io::irrelevant ext_io;
82 
83  typedef trait::image::value_storage::disrupted value_storage;
84  };
85 
86  } // end of namespace mln::trait
87 
88 
89 
93  //
94  template <typename I>
96  box<mln_site(I)>,
97  extended<I> >,
98  private mlc_not_equal(mln_trait_image_ext_domain(I),
99  trait::image::ext_domain::none)::check_t
100  {
102  typedef mln_value(I) value;
103 
105  typedef tag::image_<I> skeleton; // This property is lost!
106 
108  extended();
109 
111  extended(I& ima, const box<mln_site(I)>& b);
112 
115  void init_(I& ima, const box<mln_site(I)>& b);
117 
119  const box<mln_site(I)>& domain() const;
120  };
121 
122 
124  template <typename I, typename J>
125  void init_(tag::image_t, extended<I>& target, const J& model);
127 
128 
129  template <typename I, typename B>
130  extended<const I>
131  extended_to(const Image<I>& ima, const Box<B>& b);
132 
133  template <typename I, typename B>
134  extended<I>
135  extended_to(Image<I>& ima, const Box<B>& b);
136 
137 
138 
139 # ifndef MLN_INCLUDE_ONLY
140 
141  // init_
142 
143  template <typename I, typename J>
144  inline
145  void init_(tag::image_t, extended<I>& target, const J& model)
146  {
147  I ima;
148  init_(tag::image, ima, model);
150  init_(tag::bbox, b, model);
151  target.init_(ima, b);
152  }
153 
154 
155  // internal::data< extended<I> >
156 
157  namespace internal
158  {
159 
160  template <typename I>
161  inline
162  data< extended<I> >::data(I& ima, const box<mln_site(I)>& b)
163  : ima_(ima),
164  b_(b)
165  {
166  }
167 
168  } // end of namespace mln::internal
169 
170 
171  // extended<I>
172 
173  template <typename I>
174  inline
175  extended<I>::extended()
176  {
177  }
178 
179  template <typename I>
180  inline
181  extended<I>::extended(I& ima, const box<mln_site(I)>& b)
182  {
183  init_(ima, b);
184  }
185 
186  template <typename I>
187  inline
188  void
189  extended<I>::init_(I& ima, const box<mln_site(I)>& b)
190  {
191  mln_precondition(! this->is_valid());
192  this->data_ = new internal::data< extended<I> >(ima, b);
193  }
194 
195  template <typename I>
196  inline
197  const box<mln_site(I)>&
198  extended<I>::domain() const
199  {
200  return this->data_->b_;
201  }
202 
203 
204  // extended_to
205 
206  template <typename I, typename B>
207  extended<const I>
208  extended_to(const Image<I>& ima, const Box<B>& b)
209  {
210  mlc_not_equal(mln_trait_image_ext_domain(I),
211  trait::image::ext_domain::none)::check();
212  mln_precondition(exact(ima).is_valid());
213  extended<const I> tmp(exact(ima), exact(b));
214  return tmp;
215  }
216 
217  template <typename I, typename B>
218  extended<I>
219  extended_to(Image<I>& ima, const Box<B>& b)
220  {
221  mlc_not_equal(mln_trait_image_ext_domain(I),
222  trait::image::ext_domain::none)::check();
223  mln_precondition(exact(ima).is_valid());
224  extended<I> tmp(exact(ima), exact(b));
225  return tmp;
226  }
227 
228 # endif // ! MLN_INCLUDE_ONLY
229 
230 } // end of namespace mln
231 
232 
233 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENDED_HH