27 #ifndef MLN_CANVAS_BROWSING_SNAKE_GENERIC_HH
28 # define MLN_CANVAS_BROWSING_SNAKE_GENERIC_HH
35 # include <mln/core/concept/browsing.hh>
90 # ifndef MLN_INCLUDE_ONLY
92 # ifndef MLN_WO_GLOBAL_VARS
96 # endif // ! MLN_WO_GLOBAL_VARS
103 template <
typename F>
108 mln_trace(
"canvas::browsing::snake_generic");
109 mln_precondition(f.input.is_valid());
112 f.p = f.input.bbox().pmin();
114 std::vector< int > directions(f.moves.size(), 0);
116 unsigned total_deph = f.moves.size() / 2 + 1;
122 directions[deph] = 1;
123 deph = total_deph - 1;
126 (f.*(f.moves[(deph - 1) * 2 - 1 + directions[deph - 1]])) ();
129 mln_assertion(deph <= total_deph);
130 mln_assertion(deph > 0);
132 if (!f.input.domain().has(f.p +
133 f.dps[(deph - 1) * 2 - 1 + directions[deph - 1]]))
139 directions[deph] = directions[deph] == 1 ? 0 : 1;
146 f.p += f.dps[(deph - 1) * 2 - 1 + directions[deph - 1]];
148 (f.*(f.moves[(deph - 1) * 2 - 1 + directions[deph - 1]])) ();
153 if (deph != total_deph)
163 # endif // ! MLN_INCLUDE_ONLY
172 #endif // ! MLN_CANVAS_BROWSING_SNAKE_GENERIC_HH