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_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         
00120         return static_cast<result>(a2_.to_result()) / a1_.to_result().nsites();
00121       }
00122 
00123 # endif // ! MLN_INCLUDE_ONLY
00124 
00125     } 
00126 
00127   } 
00128 
00129 } 
00130 
00131 #endif // ! MLN_ACCU_SITE_SET_RECTANGULARITY_HH