$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
sub_image.hh
1 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 EPITA
2 // Research and 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_SUB_IMAGE_HH
28 # define MLN_CORE_IMAGE_DMORPH_SUB_IMAGE_HH
29 
37 
38 # include <mln/core/internal/image_domain_morpher.hh>
39 
40 
41 
42 namespace mln
43 {
44 
45 
46  // Forward declaration.
47  template <typename I, typename S> class sub_image;
48 
49 
50  namespace internal
51  {
52 
56  template <typename I, typename S>
57  struct data< sub_image<I,S> >
58  {
59  data(const I& ima, const S& pset);
60 
61  I ima_;
62  S domain_;
63  };
64 
65  } // end of namespace mln::internal
66 
67 
68 
69  namespace trait
70  {
71 
72  template <typename I, typename S>
73  struct image_< sub_image<I,S> > : default_image_morpher< I,
74  mln_value(I),
75  sub_image<I,S> >
76  {
77 // private:
78 // typedef mln_trait_image_data(I) I_data_;
79 // typedef mlc_equal(I_data_, trait::data::linear) I_data_are_linear_;
80 // public:
81 
82  typedef trait::image::category::domain_morpher category;
83 
84  typedef trait::image::ext_domain::none ext_domain; // No extension of domain.
85  typedef trait::image::ext_value::irrelevant ext_value;
86  typedef trait::image::ext_io::irrelevant ext_io;
87 
88  typedef trait::image::vw_io::none vw_io;
89  typedef trait::image::vw_set::none vw_set;
90  typedef trait::image::value_alignment::not_aligned value_alignment;
91  typedef trait::image::value_storage::disrupted value_storage;
92  // HOT FIXME: except if S is a Box
93  };
94 
95  } // end of namespace mln::trait
96 
97 
98 
102  //
103  template <typename I, typename S>
105  S,
106  sub_image<I,S> >
107  {
108  public:
110  typedef sub_image< tag::image_<I>, tag::domain_<S> > skeleton;
111 
113  sub_image();
114 
116  sub_image(const I& ima, const S& pset);
117 
120  void init_(const I& ima, const S& pset);
122 
124  const S& domain() const;
125 
127  operator sub_image<const I, S>() const;
128  };
129 
130 
131 
132 
133 
134  template <typename I, typename S>
136  operator|(const Image<I>& ima, const Site_Set<S>& pset);
137 
138 
139  template <typename I, typename S>
141  operator|(Image<I>& ima, const Site_Set<S>& pset);
142 
143 
145  template <typename I, typename S, typename J>
146  void init_(tag::image_t, sub_image<I,S>& target, const J& model);
148 
149 
150 # ifndef MLN_INCLUDE_ONLY
151 
152  // init_
153 
154  template <typename I, typename S, typename J>
155  inline
156  void init_(tag::image_t, sub_image<I,S>& target, const J& model)
157  {
158  I ima;
159  init_(tag::image, ima, model);
160  S pset;
161  init_(tag::domain, pset, model);
162  target.init_(ima, pset);
163  }
164 
165 
166  // internal::data< sub_image<I,S> >
167 
168  namespace internal
169  {
170 
171  template <typename I, typename S>
172  inline
173  data< sub_image<I,S> >::data(const I& ima, const S& pset)
174  : ima_(ima),
175  domain_(pset)
176  {
177  }
178 
179  } // end of namespace mln::internal
180 
181 
182  // sub_image<I,S>
183 
184  template <typename I, typename S>
185  inline
186  sub_image<I,S>::sub_image()
187  {
188  }
189 
190  template <typename I, typename S>
191  inline
192  sub_image<I,S>::sub_image(const I& ima, const S& pset)
193  {
194  init_(ima, pset);
195  }
196 
197  template <typename I, typename S>
198  inline
199  void
200  sub_image<I,S>::init_(const I& ima, const S& pset)
201  {
202  mln_precondition(! this->is_valid());
203  this->data_ = new internal::data< sub_image<I,S> >(ima, pset);
204  }
205 
206  template <typename I, typename S>
207  inline
208  const S&
209  sub_image<I,S>::domain() const
210  {
211  return this->data_->domain_;
212  }
213 
214  template <typename I, typename S>
215  inline
216  sub_image<I,S>::operator sub_image<const I, S>() const
217  {
218  sub_image<const I, S> tmp(this->data_->ima_,
219  this->data_->domain_);
220  return tmp;
221  }
222 
223 
224  // Operators.
225 
226  template <typename I, typename S>
227  inline
228  sub_image<const I, S>
229  operator|(const Image<I>& ima, const Site_Set<S>& pset)
230  {
231  sub_image<const I, S> tmp(exact(ima), exact(pset));
232  return tmp;
233  }
234 
235  template <typename I, typename S>
236  inline
237  sub_image<I, S>
238  operator|(Image<I>& ima, const Site_Set<S>& pset)
239  {
240  sub_image<I, S> tmp(exact(ima), exact(pset));
241  return tmp;
242  }
243 
244 # endif // ! MLN_INCLUDE_ONLY
245 
246 } // end of namespace mln
247 
248 
249 #endif // ! MLN_CORE_IMAGE_DMORPH_SUB_IMAGE_HH