27 #ifndef MLN_CORE_ALIAS_WINDOW2D_HH
28 # define MLN_CORE_ALIAS_WINDOW2D_HH
35 # include <mln/core/window.hh>
36 # include <mln/core/alias/dpoint2d.hh>
37 # include <mln/metal/math/sqrt.hh>
92 typedef window<mln::dpoint2d> window2d;
129 template <
unsigned S>
130 void from_to_(
const bool (&values)[S], window2d& win);
133 template <
unsigned R,
unsigned C>
134 void from_to_(
const bool (&values)[R][C], window2d& win);
137 # ifndef MLN_INCLUDE_ONLY
139 inline const window2d&
155 inline const window2d&
176 template <
unsigned S>
178 from_to_(
const bool (&values)[S], window2d& win)
180 enum { H = mlc_sqrt_int(S) / 2 };
181 mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
186 _h = static_cast<def::coord>(-h);
190 win.insert(row, col);
193 template <
unsigned R,
unsigned C>
195 from_to_(
const bool (&values)[R][C], window2d& win)
197 mlc_bool(R % 2 == 1)::check();
198 mlc_bool(C % 2 == 1)::check();
202 _drow = static_cast<def::coord>(- drow),
204 _dcol = static_cast<def::coord>(- dcol);
205 for (
def::coord row = _drow; row <= drow; ++row)
206 for (
def::coord col = _dcol; col <= dcol; ++col)
207 if (values[row + drow][col + dcol])
208 win.insert(row, col);
211 # endif // ! MLN_INCLUDE_ONLY
216 #endif // ! MLN_CORE_ALIAS_WINDOW2D_HH