Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
hexa_piter.hh
1 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_CORE_IMAGE_DMORPH_HEXA_PITER_HH
27 # define MLN_CORE_IMAGE_DMORPH_HEXA_PITER_HH
28 
32 
33 # include <mln/core/internal/piter_adaptor.hh>
34 
35 # include <mln/core/alias/box2d.hh>
36 # include <mln/core/alias/box2d_h.hh>
37 
38 
39 namespace mln
40 {
41 
49  template <typename S>
50  class hexa_fwd_piter_
51  : public internal::piter_adaptor_< mln_fwd_piter(S),
52  S,
53  hexa_fwd_piter_<S> >
54  {
55  typedef mln_fwd_piter(S) adaptee_;
56  typedef hexa_fwd_piter_<S> self_;
57  typedef internal::piter_adaptor_<adaptee_, S, self_> super_;
58 
59  public:
60 
62  hexa_fwd_piter_(const box2d_h& subset);
63 
65  void start();
66 
68  void next_();
69 
70  operator point2d_h() const;
71  private:
72 
73  point2d_h p_;
74 
75  //adaptee's box2d.
76  box2d box_adaptee_;
77  };
78 
79 
80  // FIXME:
81  template <typename S>
82  class hexa_bkd_piter_
83  :
84  public mln::internal::fixme
85  {};
86 
87 
88 
89 # ifndef MLN_INCLUDE_ONLY
90 
91 
92  // hexa_fwd_piter_<I>
93 
94  template <typename S>
95  inline
96  hexa_fwd_piter_<S>::hexa_fwd_piter_(const box2d_h& b)
97  :
98  super_(adaptee_(box_adaptee_))
99  {
100  box_adaptee_ = make::box2d(b.pmin()[0] / 2,
101  b.pmin()[1] / 2,
102  b.pmax()[0] / 2 + b.pmax()[0] % 2,
103  b.pmax()[1] / 2);
104  }
105 
106  template <typename S>
107  inline
108  void
109  hexa_fwd_piter_<S>::start()
110  {
111  this->pi_.start();
112  p_[0] = this->pi_[0];
113  p_[1] = this->pi_[1];
114  }
115 
116  template <typename S>
117  inline
118  void
119  hexa_fwd_piter_<S>::next_()
120  {
121  this->pi_.next();
122  p_[0] = this->pi_[0] * 2;
123  p_[1] = this->pi_[1] * 2 + this->pi_[0] % 2;
124  }
125 
126  template <typename S>
127  inline
128  hexa_fwd_piter_<S>::operator point2d_h() const
129  {
130  return p_;
131  }
132 
133  // FIXME: hexa_bkd_piter_<S>
134 
135 
136 # endif // ! MLN_INCLUDE_ONLY
137 
138 } // end of namespace mln
139 
140 
141 #endif // ! MLN_CORE_IMAGE_DMORPH_HEXA_PITER_HH