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"
12 #include "Point_operators.hpp"
22 template<
unsigned int dim ,
typename T>
class Point
33 typedef boost::fusion::vector<T[dim]>
type;
39 static const unsigned int x = 0;
59 for(
size_t i = 0; i < dim ; i++)
70 for(
size_t i = 0; i < dim ; i++)
81 for(
size_t i = 0; i < dim ; i++)
102 for (
size_t i = 0 ; i < dim ; i++)
103 get(i) =
static_cast<S
>(p.
get(i));
113 for (
size_t i = 0 ; i < dim ; i++)
114 get(i) = p.template get<0>()[i];
124 inline Point(std::initializer_list<T> p1)
142 inline const T &
get(
size_t i)
const
144 return boost::fusion::at_c<x>(
data)[i];
156 return boost::fusion::at_c<x>(
data)[i];
166 inline T&
get(
size_t i)
168 return boost::fusion::at_c<x>(
data)[i];
206 for (
size_t i = 0 ; i < dim ; i++)
225 for (
size_t i = 0 ; i < dim ; i++)
226 tot += (this->
get(i) - q.
get(i)) * (this->
get(i) - q.
get(i));
244 for (
size_t i = 0 ; i < dim ; i++)
245 tot += (this->
get(i) - q.
get(i)) * (this->
get(i) - q.
get(i));
257 for (
size_t i = 0 ; i < dim ; i++)
269 for (
size_t i = 0 ; i < dim ; i++)
284 for (
size_t i = 0 ; i < dim ; i++)
299 std::stringstream ps;
301 for (
size_t i = 0 ; i < dim ; i++)
302 ps <<
"x[" << i <<
"]=" <<
get(i) <<
" ";
316 for (
size_t i = 0 ; i < dim ; i++)
333 for (
size_t i = 0 ; i < dim ; i++)
335 if (p.
get(i) !=
get(i))
375 for (
size_t i = 0 ; i < dim - 1 ; i++)
377 str += std::to_string(static_cast<double>(
get(i))) +
" ";
379 str += std::to_string(static_cast<double>(
get(dim-1)));
415 return boost::fusion::at_c<x>(
data);
427 for (
size_t i = 0; i < dim ; i++)
428 p.
get(i) =
static_cast<A
>(
get(i));
455 for (
size_t i = 0; i < dim ; i++)
456 get(i) = p_exp.value(i);
472 for (
size_t i = 0; i < dim ; i++)
473 get(i) = p_exp.value(i);
487 for (
size_t i = 0; i < dim ; i++)
506 for (
size_t i = 0; i < dim ; i++)
507 get(i) = p_exp.value(i);
523 for (
size_t i = 0 ; i < dim ; i++)
524 result.
get(i) =
get(i) / ar[i];
538 for (
size_t i = 0 ; i < dim ; i++)
554 for (
size_t i = 0; i < dim ; i++)
569 for (
size_t i = 0 ; i < dim ; i++)
584 for (
size_t i = 0 ; i < dim ; i++)
599 for (
size_t i = 0 ; i < dim ; i++)
618 static const unsigned int max_prop_real = 1;
621 static const unsigned int dims = dim;
624 static const unsigned int nvals = dim;
634 template <
unsigned int N,
typename T> std::string toPointString(
const T (&p)[N] )
636 std::stringstream ps;
638 for (
size_t i = 0 ; i < N ; i++)
639 ps <<
"x[" << i <<
"]=" << p[i] <<
" ";
653 template <
unsigned int N,
typename T,
typename Mem> std::string toPointString(
const encapc<1,
Point<N,T>,Mem> & p )
655 std::stringstream ps;
657 for (
size_t i = 0 ; i < N ; i++)
658 ps <<
"x[" << i <<
"]=" << p.template
get<
Point<N,T>::x>()[i] <<
" ";
Point< dim, T > & operator=(T d)
Fill the vector property with some value.
Point< dim, T > & operator=(const T(&p)[dim])
Fill the point with the value specified in the array.
Point(const Point< dim, T > &&p)
Point constructor from point.
Point< dim, T > & operator=(const point_expression_op< orig, exp1, exp2, op > &p_exp)
Fill the vector with the evaluated expression.
Point()
Default contructor.
Point< dim, T > & operator=(const point_expression< const T1[dim]> &p_exp)
Fill the vector property with the evaluated expression.
void swap(Point< dim, T > &p)
exchange the data of two points
static bool noPointers()
This structure has no internal pointers.
std::string toString() const
Return the string with the point coordinate.
int is_vtk_writable
Indicate that this object is vtk writable.
T & operator[](size_t i)
Get the component i.
Point< dim, T > operator/(const aT(&ar)[dim])
divide each component by an array
Unknown operation specialization.
static const unsigned int max_prop
The point has one property.
Point(const Point< dim, S > &p)
Point constructor.
This class implement the point shape in an N-dimensional space.
Main class that encapsulate a constant number used in a point expression.
T & value(size_t i)
Return the reference to the value at coordinate i.
Point< dim, T > & operator+=(const Point< dim, T > &p)
Sum two points.
static Point< dim, T > zero_p()
Create a point set to zero.
bool operator!=(const Point< dim, T > &p)
Check if two points match.
Point(const T(&p)[dim])
Constructor from an array.
Point< dim, T > & operator=(const Point< dim, T > &p)
operator= between points
void init() const
Do nothing stub operation.
T(& asArray())[dim]
Return the coordinated of the point as reference array.
const T & operator[](size_t i) const
Get the component i.
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< dim, T > operator/=(const aT c)
divide each component by a constant
T get_vtk(size_t i) const
Get coordinate.
Point(const Point< dim, T > &p)
Point constructor from point.
Point< dim, T > & operator-=(const Point< dim, T > &p)
Subtract two points.
Point(T d)
Constructor from scalar.
const T & get(size_t i) const
Get coordinate.
boost::fusion::vector< T[dim]> type
boost fusion that store the point
Point< dim, T > & operator=(const point_expression< T[dim]> &p_exp)
Fill the vector property with the evaluated expression.
T norm()
norm of the vector
static const unsigned int dims
expose the dimension
static const unsigned int x
Property id of the point.
Point< dim, A > convertPoint() const
T distance2(const Point< dim, T > &q)
It calculate the square distance between 2 points.
Point(const encapc< d, Point< dim, T >, M > &p)
Point constructor.
static const unsigned int nvals
expose the dimension with a different name
std::string to_string() const
Return the string with the point coordinate.
bool operator==(const Point< dim, T > &p)
Check if two points match.
Point(const point_expression_op< orig, exp1, exp2, op > &p_exp)
Evaluate the expression and save the result on the point.
void zero()
Set to zero the point coordinate.
T distance(const Point< dim, T > &q)
It calculate the distance between 2 points.
std::string toPointString() const
Convert the point into a string.
T coord_type
coordinate type
Point(std::initializer_list< T > p1)
Constructor from a list.