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>
38 # include <mln/convert/from_to.hxx>
91 void from_to_(
const bool (&values)[S],
window2d& win);
93 template <
unsigned R,
unsigned C>
94 void from_to_(
const bool (&values)[R][C],
window2d& win);
102 # ifndef MLN_INCLUDE_ONLY
147 template <
unsigned S>
149 from_to_(
const bool (&values)[S],
window2d& win)
151 enum { H = mlc_sqrt_int(S) / 2 };
152 mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
157 _h = static_cast<def::coord>(-h);
161 win.insert(row, col);
164 template <
unsigned R,
unsigned C>
166 from_to_(
const bool (&values)[R][C],
window2d& win)
168 mlc_bool(R % 2 == 1)::check();
169 mlc_bool(C % 2 == 1)::check();
173 _drow = static_cast<def::coord>(- drow),
175 _dcol = static_cast<def::coord>(- dcol);
176 for (
def::coord row = _drow; row <= drow; ++row)
177 for (
def::coord col = _dcol; col <= dcol; ++col)
178 if (values[row + drow][col + dcol])
179 win.insert(row, col);
186 # endif // ! MLN_INCLUDE_ONLY
191 #endif // ! MLN_CORE_ALIAS_WINDOW2D_HH