27 #ifndef MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH
28 # define MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH
35 # include <mln/core/concept/object.hh>
36 # include <mln/core/grids.hh>
37 # include <mln/trait/all.hh>
44 template <
typename E>
struct Delta_Point_Site;
51 template <
typename L,
typename R >
52 struct set_binary_< op::
plus,
55 typedef mln_dpoint(L)
ret;
58 template < typename L, typename R >
59 struct set_binary_< op::
minus,
60 mln::Delta_Point_Site, L, mln::Delta_Point_Site, R >
62 typedef mln_dpoint(L) ret;
72 struct Delta_Point_Site<
void>
84 struct Delta_Point_Site :
public Object<E>
108 template <
typename D>
110 operator<<(std::ostream& ostr, const Delta_Point_Site<D>& dp);
113 template <
typename L,
typename R>
117 template <
typename L,
typename R>
122 template <
typename L,
typename R>
124 operator+(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>&
rhs);
126 template <typename L, typename R>
128 operator-(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>& rhs);
133 # ifndef MLN_INCLUDE_ONLY
135 template <
typename E>
140 mln_invariant(dim > 0);
142 typedef mln_mesh(E) mesh;
143 typedef mln_point(E)
point;
144 typedef mln_dpoint(E)
dpoint;
145 typedef mln_coord(E)
coord;
146 const dpoint& (E::*m1)() const = & E::to_dpoint;
148 coord (E::*m2)(
unsigned i) const = & E::operator[];
153 template <typename D>
155 std::ostream& operator<<(std::ostream& ostr, const Delta_Point_Site<D>& dp_)
157 const D& dp =
exact(dp_);
159 for (
unsigned i = 0; i < D::dim; ++i)
160 ostr << dp[i] << (i == D::dim - 1 ?
')' :
',');
165 template <
typename L,
typename R>
167 bool operator==(
const Delta_Point_Site<L>& lhs_,
const Delta_Point_Site<R>& rhs_)
169 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
170 const L& lhs =
exact(lhs_);
171 const R& rhs =
exact(rhs_);
172 for (
unsigned i = 0; i < L::dim; ++i)
173 if (lhs[i] != rhs[i])
178 template <
typename L,
typename R>
180 bool operator<(const Delta_Point_Site<L>& lhs_,
const Delta_Point_Site<R>& rhs_)
182 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
183 const L& lhs =
exact(lhs_);
184 const R& rhs =
exact(rhs_);
185 for (
unsigned i = 0; i < L::dim; ++i)
187 if (lhs[i] == rhs[i])
189 return lhs[i] < rhs[i];
194 template <
typename L,
typename R>
197 operator+(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_)
199 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
200 const L& lhs =
exact(lhs_);
201 const R& rhs =
exact(rhs_);
203 for (
unsigned i = 0; i < L::dim; ++i)
204 tmp[i] = lhs[i] + rhs[i];
208 template <typename L, typename R>
211 operator-(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_)
213 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
214 const L& lhs =
exact(lhs_);
215 const R& rhs =
exact(rhs_);
217 for (
unsigned i = 0; i < L::dim; ++i)
218 tmp[i] = lhs[i] - rhs[i];
222 # endif // ! MLN_INCLUDE_ONLY
227 #endif // ! MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH