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_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
00027 # define MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
00028
00034
00035 # include <mln/core/concept/gpoint.hh>
00036 # include <mln/core/concept/site_proxy.hh>
00037 # include <mln/world/inter_pixel/is_pixel.hh>
00038 # include <mln/world/inter_pixel/is_separator.hh>
00039
00040
00041 namespace mln
00042 {
00043
00044 namespace world
00045 {
00046
00047 namespace inter_pixel
00048 {
00049
00050
00051 template <typename P>
00052 void
00053 separator_to_pixels(const Gpoint<P>& s,
00054 Gpoint<P>& p1, Gpoint<P>& p2);
00055
00056 template <typename Ps, typename P>
00057 void
00058 separator_to_pixels(const Site_Proxy<Ps>& s,
00059 Gpoint<P>& p1, Gpoint<P>& p2);
00060
00061
00062 # ifndef MLN_INCLUDE_ONLY
00063
00064
00065 template <typename P>
00066 inline
00067 void
00068 separator_to_pixels(const Gpoint<P>& s_,
00069 Gpoint<P>& p1_, Gpoint<P>& p2_)
00070 {
00071 const P& s = exact(s_);
00072 P& p1 = exact(p1_);
00073 P& p2 = exact(p2_);
00074
00075 # ifndef NDEBUG
00076 {
00077
00078 is_separator is_separator_;
00079 mln_precondition(is_separator_(s));
00080 (void) is_separator_;
00081 }
00082 # endif // ! NDEBUG
00083
00084
00085 if (s.row() % 2)
00086 {
00087
00088 p1 = point2d(s.row() - 1, s.col());
00089 p2 = point2d(s.row() + 1, s.col());
00090 }
00091 else
00092 {
00093
00094 p1 = point2d(s.row(), s.col() - 1);
00095 p2 = point2d(s.row(), s.col() + 1);
00096 }
00097
00098 # ifndef NDEBUG
00099 {
00100
00101 is_pixel is_pixel_;
00102 mln_postcondition(is_pixel_(p1));
00103 mln_postcondition(is_pixel_(p2));
00104 (void) is_pixel_;
00105 }
00106 # endif // ! NDEBUG
00107 }
00108
00109 template <typename Ps, typename P>
00110 inline
00111 void
00112 separator_to_pixels(const Site_Proxy<Ps>& s_,
00113 Gpoint<P>& p1_, Gpoint<P>& p2_)
00114 {
00115 const Ps& s = exact(s_);
00116 P& p1 = exact(p1_);
00117 P& p2 = exact(p2_);
00118
00119 # ifndef NDEBUG
00120 {
00121
00122 is_separator is_separator_;
00123 mln_precondition(is_separator_(s));
00124 (void) is_separator_;
00125 }
00126 # endif // ! NDEBUG
00127
00128 separator_to_pixels(s.to_site(), p1, p2);
00129
00130 # ifndef NDEBUG
00131 {
00132
00133 is_pixel is_pixel_;
00134 mln_postcondition(is_pixel_(p1));
00135 mln_postcondition(is_pixel_(p2));
00136 (void) is_pixel_;
00137 }
00138 # endif // ! NDEBUG
00139 }
00140
00141 # endif // ! MLN_INCLUDE_ONLY
00142
00143 }
00144
00145 }
00146
00147 }
00148
00149 #endif // ! MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH