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_CONCEPT_POINT_HH
00027 # define MLN_CORE_CONCEPT_POINT_HH
00028 
00034 # include <mln/core/concept/point_site.hh>
00035 # include <mln/core/concept/dpoint.hh>
00036 # include <mln/value/concept/scalar.hh>
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   
00043   template <typename E> struct Point;
00044 
00045 
00046   
00047   template <>
00048   struct Point<void>
00049   {
00050     typedef Point_Site<void> super;
00051   };
00052 
00053 
00061   template <typename P>
00062   struct Point : public Point_Site<P>
00063   {
00066     typedef P point;
00067 
00070     const P& to_point() const;
00071 
00072   protected:
00073     Point();
00074   };
00075 
00076 
00088   template <typename P, typename D>
00089   P& operator+=(Point<P>& p, const Dpoint<D>& dp);
00090 
00091 
00103   template <typename P, typename D>
00104   P& operator-=(Point<P>& p, const Dpoint<D>& dp);
00105 
00114   template <typename P, typename D>
00115   P& operator/(Point<P>& p, const value::Scalar<D>& dp);
00116 
00117   
00118 
00119 # ifndef MLN_INCLUDE_ONLY
00120 
00121   template <typename P>
00122   inline
00123   Point<P>::Point()
00124   {
00125   }
00126 
00127   template <typename P>
00128   inline
00129   const P&
00130   Point<P>::to_point() const
00131   {
00132     return exact(*this);
00133   }
00134 
00135   template <typename P, typename D>
00136   inline
00137   P& operator+=(Point<P>& p_, const Dpoint<D>& dp_)
00138   {
00139     P& p = exact(p_);
00140     const D& dp = exact(dp_);
00141     
00142     for (unsigned i = 0; i < P::dim; ++i)
00143       p[i] += dp[i];
00144     return p;
00145   }
00146 
00147   template <typename P, typename D>
00148   inline
00149   P& operator-=(Point<P>& p_, const Dpoint<D>& dp_)
00150   {
00151     P& p = exact(p_);
00152     const D& dp = exact(dp_);
00153     
00154     for (unsigned i = 0; i < P::dim; ++i)
00155       p[i] -= dp[i];
00156     return p;
00157   }
00158 
00159 
00160   template <typename P, typename D>
00161   inline
00162   P&
00163   operator/(Point<P>& p_, const value::Scalar<D>& s_)
00164   {
00165     P& p = exact(p_);
00166     const D& s = exact(s_);
00167     for (unsigned i = 0; i < P::dim; ++i)
00168       p[i] /= s;
00169     return p;
00170   }
00171 
00172 # endif // ! MLN_INCLUDE_ONLY
00173 
00174 } 
00175 
00176 
00177 
00178 #endif // ! MLN_CORE_CONCEPT_POINT_HH