4 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
5 #include <boost/fusion/include/at_c.hpp>
6 #include <boost/fusion/container/vector.hpp>
7 #include <boost/fusion/include/vector.hpp>
8 #include <boost/fusion/container/vector/vector_fwd.hpp>
9 #include <boost/fusion/include/vector_fwd.hpp>
10 #include "boost/multi_array.hpp"
11 #include "Grid/Encap.hpp"
20 template<
unsigned int dim ,
typename T>
class Point
27 typedef boost::fusion::vector<T[dim]>
type;
33 static const unsigned int x = 0;
42 inline T
get(
int i)
const
44 return boost::fusion::at_c<x>(
data)[i];
56 return boost::fusion::at_c<x>(
data)[i];
77 for (
size_t i = 0 ; i < dim ; i++)
94 for (
size_t i = 0 ; i < dim ; i++)
96 result.
get(i) =
get(i) * c;
111 for (
size_t i = 0 ; i < dim ; i++)
113 result.
get(i) =
get(i) * p.
get(i);
126 for (
size_t i = 0 ; i < dim ; i++)
141 for (
size_t i = 0 ; i < dim ; i++)
158 for (
size_t i = 0 ; i < dim ; i++)
175 for (
size_t i = 0 ; i < dim ; i++)
177 result.
get(i) =
get(i) + p.
get(i);
192 for (
size_t i = 0 ; i < dim ; i++)
194 result.
get(i) =
get(i) / ar[i];
209 for (
size_t i = 0 ; i < dim ; i++)
211 result.
get(i) =
get(i) / c;
228 for (
size_t i = 0 ; i < dim ; i++)
230 result.
get(i) =
get(i) - p.
get(i);
242 for (
size_t i = 0 ; i < dim ; i++)
254 for (
size_t i = 0 ; i < dim ; i++)
269 for (
size_t i = 0 ; i < dim ; i++)
284 std::stringstream ps;
286 for (
size_t i = 0 ; i < dim ; i++)
287 ps <<
"x[" << i <<
"]=" <<
get(i) <<
" ";
303 for (
size_t i = 0 ; i < dim - 1 ; i++)
305 str += std::to_string(
get(i)) +
" ";
307 str += std::to_string(
get(dim-1));
319 for(
size_t i = 0; i < dim ; i++)
330 for(
size_t i = 0; i < dim ; i++)
341 for(
size_t i = 0; i < dim ; i++)
352 for (
size_t i = 0 ; i < dim ; i++)
353 get(i) =
static_cast<S
>(p.
get(i));
363 for (
size_t i = 0 ; i < dim ; i++)
364 get(i) = p.template get<0>()[i];
372 inline Point(std::initializer_list<T> p1)
410 return boost::fusion::at_c<x>(
data);
422 for (
size_t i = 0; i < dim ; i++)
423 p.
get(i) =
static_cast<A
>(
get(i));
434 static const unsigned int max_prop = 1;
435 static const unsigned int dims = dim;
445 template <
unsigned int N,
typename T> std::string toPointString(
const T (&p)[N] )
447 std::stringstream ps;
449 for (
size_t i = 0 ; i < N ; i++)
450 ps <<
"x[" << i <<
"]=" << p[i] <<
" ";
464 template <
unsigned int N,
typename T,
typename Mem> std::string toPointString(
const encapc<1,
Point<N,T>,Mem> & p )
466 std::stringstream ps;
468 for (
size_t i = 0 ; i < N ; i++)
469 ps <<
"x[" << i <<
"]=" << p.template
get<
Point<N,T>::x>()[i] <<
" ";
Point(const Point< dim, T > &&p)
Point constructor from point.
Point()
Default contructor.
static bool noPointers()
This structure has no internal pointers.
Point< dim, T > operator-(const Point< dim, T > &p)
Operator subtraction.
std::string toString() const
Return the string with the point coordinate.
T & operator[](size_t i)
Get the component i.
Point< dim, T > operator+(const Point< dim, aT > &p)
Sum each components.
Point< dim, T > operator/(const aT(&ar)[dim])
divide each component
Point(const Point< dim, S > &p)
Point constructor.
This class implement the point shape in an N-dimensional space.
T & value(size_t i)
Return the reference to the value at coordinate i.
Point< dim, T > & operator+=(const Point< dim, T > &p)
Sum each components.
static Point< dim, T > zero_p()
Create a point set to zero.
Point(const T(&p)[dim])
Constructor from an array.
Point< dim, T > operator/(const aT c)
divide each component
Point< dim, T > & operator=(const Point< dim, T > &p)
operator= between points
T(& asArray())[dim]
Return the coordinated of the point as reference array.
T get(int i) const
Get coordinate.
type data
structure that store the data of the point
T value(size_t i) const
Return the value at coordinate i.
void one()
Set to one the point coordinate.
Point(const Point< dim, T > &p)
Point constructor from point.
Point< dim, T > & operator-=(const Point< dim, T > &p)
Subtract each components.
this structure encapsulate an object of the grid
boost::fusion::vector< T[dim]> type
boost fusion that store the point
static const unsigned int x
Property id of the point.
Point< dim, A > convertPoint() const
Point< dim, T > operator*(const Point< dim, aT > &p)
Multiply each components.
Point(const encapc< d, Point< dim, T >, M > &p)
Point constructor.
void zero()
Set to zero the point coordinate.
std::string toPointString() const
Convert the point into a string.
Point< dim, T > operator*(T c)
Multiply each components by a constant.
Point(std::initializer_list< T > p1)
Constructor from a list.