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_ACCU_SITE_SET_RECTANGULARITY_HH 00027 # define MLN_ACCU_SITE_SET_RECTANGULARITY_HH 00028 00032 00033 # include <mln/accu/internal/couple.hh> 00034 # include <mln/accu/shape/bbox.hh> 00035 # include <mln/accu/math/count.hh> 00036 00037 namespace mln 00038 { 00039 00040 namespace accu 00041 { 00042 00043 namespace site_set 00044 { 00045 00049 // 00050 template <typename P> 00051 class rectangularity 00052 : public accu::internal::couple<accu::shape::bbox<P>, 00053 accu::math::count<P>, 00054 float, 00055 rectangularity<P> > 00056 { 00057 00058 public: 00059 00060 typedef accu::internal::couple<accu::shape::bbox<P>, 00061 accu::math::count<P>, 00062 float, 00063 rectangularity<P> > super_; 00064 00065 typedef accu::shape::bbox<P> A1; 00066 typedef accu::math::count<P> A2; 00067 00068 typedef float result; 00069 00071 rectangularity(); 00072 00074 mln_result(A1) bbox() const; 00076 mln_result(A2) area() const; 00077 00079 result to_result() const; 00080 00081 protected: 00082 using super_::a1_; 00083 using super_::a2_; 00084 00085 }; 00086 00087 # ifndef MLN_INCLUDE_ONLY 00088 00089 template <typename P> 00090 inline 00091 rectangularity<P>::rectangularity() 00092 { 00093 } 00094 00095 template <typename P> 00096 inline 00097 mln_result(rectangularity<P>::A1) 00098 rectangularity<P>::bbox() const 00099 { 00100 mln_precondition(a1_.is_valid()); 00101 return a1_.to_result(); 00102 } 00103 00104 template <typename P> 00105 inline 00106 mln_result(rectangularity<P>::A2) 00107 rectangularity<P>::area() const 00108 { 00109 mln_precondition(a2_.is_valid()); 00110 return a2_.to_result(); 00111 } 00112 00113 template <typename P> 00114 inline 00115 mln_result(rectangularity<P>) 00116 rectangularity<P>::to_result() const 00117 { 00118 mln_precondition(this->is_valid()); 00119 // Force division return type. 00120 return static_cast<result>(a2_.to_result()) / a1_.to_result().nsites(); 00121 } 00122 00123 # endif // ! MLN_INCLUDE_ONLY 00124 00125 } // end of namespace mln::accu::site_set 00126 00127 } // end of namespace mln::accu 00128 00129 } // end of namespace mln 00130 00131 #endif // ! MLN_ACCU_SITE_SET_RECTANGULARITY_HH