26 #ifndef MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH
27 # define MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH
34 # include <mln/core/concept/object.hh>
35 # include <mln/core/grids.hh>
36 # include <mln/trait/all.hh>
43 template <
typename E>
struct Delta_Point_Site;
50 template <
typename L,
typename R >
51 struct set_binary_< op::
plus,
54 typedef mln_dpoint(L) ret;
57 template < typename L, typename R >
58 struct set_binary_< op::minus,
59 mln::Delta_Point_Site, L, mln::Delta_Point_Site, R >
61 typedef mln_dpoint(L) ret;
70 struct Delta_Point_Site<
void>
79 struct Delta_Point_Site :
public Object<E>
103 template <
typename D>
105 operator<<(std::ostream& ostr, const Delta_Point_Site<D>& dp);
108 template <
typename L,
typename R>
112 template <
typename L,
typename R>
117 template <
typename L,
typename R>
119 operator+(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>& rhs);
121 template <typename L, typename R>
123 operator-(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>& rhs);
128 # ifndef MLN_INCLUDE_ONLY
130 template <
typename E>
135 mln_invariant(dim > 0);
137 typedef mln_mesh(E) mesh;
138 typedef mln_point(E)
point;
139 typedef mln_dpoint(E)
dpoint;
140 typedef mln_coord(E) coord;
141 const dpoint& (E::*m1)() const = & E::to_dpoint;
143 coord (E::*m2)(
unsigned i) const = & E::operator[];
148 template <typename D>
150 std::ostream& operator<<(std::ostream& ostr, const Delta_Point_Site<D>& dp_)
152 const D& dp = exact(dp_);
154 for (
unsigned i = 0; i < D::dim; ++i)
155 ostr << dp[i] << (i == D::dim - 1 ?
')' :
',');
160 template <
typename L,
typename R>
162 bool operator==(
const Delta_Point_Site<L>& lhs_,
const Delta_Point_Site<R>& rhs_)
164 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
165 const L& lhs = exact(lhs_);
166 const R& rhs = exact(rhs_);
167 for (
unsigned i = 0; i < L::dim; ++i)
168 if (lhs[i] != rhs[i])
173 template <
typename L,
typename R>
175 bool operator<(const Delta_Point_Site<L>& lhs_,
const Delta_Point_Site<R>& rhs_)
177 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
178 const L& lhs = exact(lhs_);
179 const R& rhs = exact(rhs_);
180 for (
unsigned i = 0; i < L::dim; ++i)
182 if (lhs[i] == rhs[i])
184 return lhs[i] < rhs[i];
189 template <
typename L,
typename R>
192 operator+(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_)
194 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
195 const L& lhs = exact(lhs_);
196 const R& rhs = exact(rhs_);
198 for (
unsigned i = 0; i < L::dim; ++i)
199 tmp[i] = lhs[i] + rhs[i];
203 template <typename L, typename R>
206 operator-(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_)
208 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
209 const L& lhs = exact(lhs_);
210 const R& rhs = exact(rhs_);
212 for (
unsigned i = 0; i < L::dim; ++i)
213 tmp[i] = lhs[i] - rhs[i];
217 # endif // ! MLN_INCLUDE_ONLY
222 #endif // ! MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH