27 #ifndef MLN_CORE_CONCEPT_POINT_SITE_HH
28 # define MLN_CORE_CONCEPT_POINT_SITE_HH
35 # include <mln/core/concept/object.hh>
36 # include <mln/core/concept/delta_point_site.hh>
37 # include <mln/core/grids.hh>
38 # include <mln/trait/all.hh>
46 template <
typename E>
struct Point_Site;
53 template <
typename P,
typename D >
54 struct set_binary_< op::
plus,
57 typedef mln_point(P)
ret;
60 template < typename P, typename D >
61 struct set_binary_< op::
minus,
62 mln::Point_Site, P, mln::Delta_Point_Site, D >
64 typedef mln_point(P) ret;
67 template < typename L, typename R >
68 struct set_binary_< op::minus,
69 mln::Point_Site, L, mln::Point_Site, R >
71 typedef mln_dpoint(L) ret;
81 struct Point_Site<
void>
110 template <
typename E>
147 template <
typename L,
typename R>
172 template <
typename L,
typename R>
174 operator-(const Point_Site<L>& lhs, const Point_Site<R>&
rhs);
190 template <typename P, typename D>
192 operator+(const Point_Site<P>&
p, const Delta_Point_Site<D>& dp);
209 template <typename P, typename D>
211 operator-(const Point_Site<P>& p, const Delta_Point_Site<D>& dp);
224 template <typename P>
225 std::ostream& operator<<(std::ostream& ostr, const Point_Site<P>& p);
230 # ifndef MLN_INCLUDE_ONLY
232 template <
typename E>
237 mln_invariant(dim > 0);
239 typedef mln_mesh(E) mesh;
240 typedef mln_point(E)
point;
241 typedef mln_dpoint(E)
dpoint;
242 typedef mln_coord(E)
coord;
243 const point& (E::*m1)() const = & E::to_point;
245 coord (E::*m2)(
unsigned i) const = & E::operator[];
254 template <typename L, typename R>
256 bool operator==(const Point_Site<L>& lhs_, const Point_Site<R>& rhs_)
258 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
259 const L& lhs =
exact(lhs_);
260 const R& rhs =
exact(rhs_);
261 for (
unsigned i = 0; i < L::dim; ++i)
262 if (lhs[i] != rhs[i])
269 template <
typename L,
typename R>
272 operator-(const Point_Site<L>& lhs_, const Point_Site<R>& rhs_)
274 mln::metal::bool_<(int(L::dim) == int(R::dim))>::check();
275 const L& lhs =
exact(lhs_);
276 const R& rhs =
exact(rhs_);
278 for (
unsigned i = 0; i < L::dim; ++i)
279 tmp[i] = lhs[i] - rhs[i];
280 mln_postcondition(rhs_ + tmp == lhs_);
284 template <typename P, typename D>
287 operator+(const Point_Site<P>& p_, const Delta_Point_Site<D>& dp_)
289 mln::metal::bool_<(int(P::dim) == int(D::dim))>::check();
290 const P& p =
exact(p_);
291 const D& dp =
exact(dp_);
293 for (
unsigned i = 0; i < P::dim; ++i)
294 tmp[i] = p[i] + dp[i];
298 template <typename P, typename D>
301 operator-(const Point_Site<P>& p_, const Delta_Point_Site<D>& dp_)
303 mln::metal::bool_<(int(P::dim) == int(D::dim))>::check();
304 const P& p =
exact(p_);
305 const D& dp =
exact(dp_);
307 for (
unsigned i = 0; i < P::dim; ++i)
308 tmp[i] = p[i] - dp[i];
314 template <typename P>
316 std::ostream& operator<<(std::ostream& ostr, const Point_Site<P>& p_)
318 const P& p =
exact(p_);
320 for (
unsigned i = 0; i < P::dim; ++i)
321 ostr << p[i] << (i == P::dim - 1 ?
')' :
',');
325 # endif // ! MLN_INCLUDE_ONLY
330 #endif // ! MLN_CORE_CONCEPT_POINT_SITE_HH