00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_CORE_ALIAS_NEIGHB3D_HH
00027 # define MLN_CORE_ALIAS_NEIGHB3D_HH
00028
00033
00034
00035 # include <cmath>
00036 # include <mln/core/neighb.hh>
00037 # include <mln/core/alias/window3d.hh>
00038 # include <mln/win/sym.hh>
00039 # include <mln/convert/from_to.hh>
00040
00041
00042 namespace mln
00043 {
00044
00049
00050 typedef neighb<window3d> neighb3d;
00051
00052
00054
00076 const neighb3d& c2_3d_sli();
00077
00078
00080
00102 const neighb3d& c4_3d();
00103
00105
00127 const neighb3d& c8_3d();
00128
00129
00131
00153 const neighb3d& c6();
00154
00156
00178 const neighb3d& c18();
00179
00181
00203 const neighb3d& c26();
00204
00205
00206
00207
00208 namespace convert
00209 {
00210
00211 namespace over_load
00212 {
00213
00214 template <unsigned S>
00215 void from_to_(const bool (&values)[S], neighb3d& nbh);
00216
00217 }
00218
00219 }
00220
00221
00222
00223 # ifndef MLN_INCLUDE_ONLY
00224
00225 inline
00226 const neighb3d& c2_3d_sli()
00227 {
00228 static neighb3d it;
00229 if (it.size() == 0)
00230 {
00231 window3d& win = it.hook_win_();
00232 win
00233 .insert(-1, 0, 0)
00234 .insert(1, 0, 0);
00235 }
00236 return it;
00237 }
00238
00239
00240 inline
00241 const neighb3d& c4_3d()
00242 {
00243 static neighb3d it;
00244 if (it.size() == 0)
00245 {
00246 window3d& win = it.hook_win_();
00247 win
00248 .insert(0, 1, 0)
00249 .insert(0, 0, 1);
00250 win
00251 .insert(win::sym(win));
00252 }
00253 return it;
00254 }
00255
00256 inline
00257 const neighb3d& c8_3d()
00258 {
00259 static neighb3d it;
00260 if (it.size() == 0)
00261 {
00262 static const bool vals[] = { 1, 1, 1,
00263 1, 0, 1,
00264 1, 1, 1 };
00265 convert::from_to(vals, it);
00266 }
00267 return it;
00268 }
00269
00270 inline
00271 const neighb3d& c6()
00272 {
00273 static neighb3d it;
00274 if (it.size() == 0)
00275 {
00276 window3d& win = it.hook_win_();
00277 win
00278 .insert(1, 0, 0)
00279 .insert(0, 1, 0)
00280 .insert(0, 0, 1);
00281 win
00282 .insert(win::sym(win));
00283 }
00284 return it;
00285 }
00286
00287 inline
00288 const neighb3d& c18()
00289 {
00290 static neighb3d it;
00291 if (it.size() == 0)
00292 {
00293 window3d& win = it.hook_win_();
00294 win
00295 .insert(1, 0, 1)
00296 .insert(1, 0, -1)
00297 .insert(0, 1, 1)
00298 .insert(0, 1, -1)
00299 .insert(1, 1, 0)
00300 .insert(1, -1, 0);
00301 win
00302 .insert(win::sym(win))
00303 .insert(c6().win());
00304 }
00305 return it;
00306 }
00307
00308 inline
00309 const neighb3d& c26()
00310 {
00311 static neighb3d it;
00312 if (it.size() == 0)
00313 {
00314 window3d& win = it.hook_win_();
00315 win
00316 .insert(1, 1, 1)
00317 .insert(1, 1, -1)
00318 .insert(1, -1, 1)
00319 .insert(1, -1, -1);
00320 win
00321 .insert(win::sym(win))
00322 .insert(c18().win());
00323 }
00324 return it;
00325 }
00326
00327
00328 namespace convert
00329 {
00330
00331 namespace over_load
00332 {
00333
00334 template <unsigned S>
00335 void
00336 from_to_(const bool (&values)[S], neighb3d& nbh)
00337 {
00338 # ifndef NDEBUG
00339 const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
00340 mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
00341 # endif // ! NDEBUG
00342 window3d win;
00343 from_to_(values, win);
00344 mln_precondition(win.is_neighbable_());
00345 nbh.change_window(win);
00346 }
00347
00348 }
00349
00350 }
00351
00352 # endif // ! MLN_INCLUDE_ONLY
00353
00354 }
00355
00356
00357 #endif // ! MLN_CORE_ALIAS_NEIGHB3D_HH