Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 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 // Pre-condition. 00078 is_separator is_separator_; 00079 mln_precondition(is_separator_(s)); 00080 (void) is_separator_; 00081 } 00082 # endif // ! NDEBUG 00083 00084 // FIXME: 2D only. 00085 if (s.row() % 2) 00086 { 00087 // Horizontal edge. 00088 p1 = point2d(s.row() - 1, s.col()); 00089 p2 = point2d(s.row() + 1, s.col()); 00090 } 00091 else 00092 { 00093 // Vertical edge. 00094 p1 = point2d(s.row(), s.col() - 1); 00095 p2 = point2d(s.row(), s.col() + 1); 00096 } 00097 00098 # ifndef NDEBUG 00099 { 00100 // Post-conditions. 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 // Pre-condition. 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 // Post-conditions. 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 } // end of namespace mln::world::inter_pixel 00144 00145 } // end of namespace mln::world 00146 00147 } // end of namespace mln 00148 00149 #endif // ! MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH