5 #include "Space/Shape/Sphere.hpp" 
    6 #include <boost/fusion/sequence/intrinsic/at_c.hpp> 
    7 #include "Grid/grid_key.hpp" 
    8 #include "Grid/Encap.hpp" 
   55 template<
unsigned int dim , 
typename T>
 
   61     typedef boost::fusion::vector<T[dim],T[dim]> 
type;
 
   69     static const unsigned int p1 = 0;
 
   71     static const unsigned int p2 = 1;
 
   75     static const unsigned int dims = dim;
 
   78     template <
int i> 
inline auto get() -> decltype(boost::fusion::at_c<i>(
data))
 
   80         return boost::fusion::at_c<i>(
data);
 
   97         for (
size_t i = 0 ; i < dim ; i++)
 
  163         typename distance::ResultType distance_r = 0;
 
  165         for (
size_t i = 0 ; i < dim ; i++)
 
  171             if (boost::fusion::at_c<p1>(
data)[i] < sphere.
center(i))
 
  174                 distance_r += dist.accum_dist(sphere.
center(i),boost::fusion::at_c<p1>(
data)[i],i);
 
  176             else if ( boost::fusion::at_c<p2>(
data)[i] <= sphere.
center(i))
 
  179                 distance_r += dist.accum_dist(sphere.
center(i),boost::fusion::at_c<p2>(
data)[i],i);
 
  184         return distance_r < sphere.
radius();
 
  195     template<
unsigned int b> T 
getBase(
const unsigned int i)
 const 
  197         return boost::fusion::at_c<b>(
data)[i];
 
  222         for(
size_t i = 0 ; i < dim ; i++)
 
  225         for(
size_t i = 0 ; i < dim ; i++)
 
  256     Box(std::initializer_list<T> 
p1, std::initializer_list<T> 
p2)
 
  267     inline Box(T * high, T * low)
 
  271         for (
int i = 0 ; i < dim ; i++)
 
  275             boost::fusion::at_c<Box::p1>(
data)[i] = low[i];
 
  276             boost::fusion::at_c<Box::p2>(
data)[i] = high[i];
 
  289         for (
size_t i = 0 ; i < dim ; i++)
 
  291             boost::fusion::at_c<p1>(
data)[i] = boost::fusion::at_c<p1>(box.
data)[i];
 
  292             boost::fusion::at_c<p2>(
data)[i] = boost::fusion::at_c<p2>(box.
data)[i];
 
  305         for (
size_t i = 0 ; i < dim ; i++)
 
  307             boost::fusion::at_c<p1>(
data)[i] = boost::fusion::at_c<p1>(box_data)[i];
 
  308             boost::fusion::at_c<p2>(
data)[i] = boost::fusion::at_c<p2>(box_data)[i];
 
  317     inline Box(T (& box_data)[dim])
 
  321         for (
size_t i = 0 ; i < dim ; i++)
 
  323             boost::fusion::at_c<p1>(
data)[i] = 0;
 
  324             boost::fusion::at_c<p2>(
data)[i] = box_data[i];
 
  336         for (
size_t i = 0 ; i < dim ; i++)
 
  348     template<
unsigned int dimS> 
inline Box(boost::fusion::vector<T[dimS],T[dimS]> & box_data)
 
  352         for (
size_t i = 0 ; i < dim ; i++)
 
  354             boost::fusion::at_c<p1>(
data)[i] = boost::fusion::at_c<p1>(box_data)[i];
 
  355             boost::fusion::at_c<p2>(
data)[i] = boost::fusion::at_c<p2>(box_data)[i];
 
  368         for (
size_t i = 0 ; i < dim ; i++)
 
  370             boost::fusion::at_c<p1>(
data)[i] = b.template get<p1>()[i];
 
  371             boost::fusion::at_c<p2>(
data)[i] = b.template get<p2>()[i];
 
  382         for (
size_t d = 0 ; d < dim ; d++)
 
  385         for (
size_t d = 0 ; d < dim ; d++)
 
  398         for (
size_t i = 0 ; i < dim ; i++)
 
  417         for (
size_t i = 0 ; i < dim ; i++)
 
  434     inline void set(std::initializer_list<T> 
p1, std::initializer_list<T> 
p2)
 
  463         boost::fusion::at_c<p1>(
data)[i] = val;
 
  474         boost::fusion::at_c<p2>(
data)[i] = val;
 
  486         return boost::fusion::at_c<p1>(
data)[i];
 
  497         return boost::fusion::at_c<p2>(
data)[i];
 
  507         for (
size_t i = 0 ; i < dim ; i++)
 
  518         for (
size_t i = 0 ; i < dim ; i++)
 
  529         for (
size_t i = 0 ; i < dim ; i++)
 
  540         for (
size_t i = 0 ; i < dim ; i++)
 
  629         for (
size_t i = 0 ; i < dim ; i++)
 
  631             boost::fusion::at_c<p2>(
data)[i] -= p.
get(i);
 
  632             boost::fusion::at_c<p1>(
data)[i] -= p.
get(i);
 
  647         for (
size_t i = 0 ; i < dim ; i++)
 
  649             boost::fusion::at_c<p2>(
data)[i] += p.
get(i);
 
  650             boost::fusion::at_c<p1>(
data)[i] += p.
get(i);
 
  661     inline void expand(T (& exp)[dim])
 
  663         for (
size_t i = 0 ; i < dim ; i++)
 
  665             boost::fusion::at_c<p2>(
data)[i] = boost::fusion::at_c<p2>(
data)[i] + exp[i];
 
  693         typedef ::Box<dim,T> g;
 
  695         for (
size_t j = 0 ; j < dim ; j++)
 
  697             this->
setLow(j,this->
template getBase<g::p1>(j) + gh.template getBase<g::p1>(j));
 
  698             this->
setHigh(j,this->
template getBase<g::p2>(j) + gh.template getBase<g::p2>(j));
 
  726         typedef ::Box<dim,T> g;
 
  728         for (
size_t j = 0 ; j < dim ; j++)
 
  730             this->
setHigh(j,this->
template getBase<g::p2>(j) + gh.template getBase<g::p2>(j) - gh.template getBase<g::p1>(j));
 
  746         typedef ::Box<dim,T> g;
 
  748         for (
size_t j = 0 ; j < dim ; j++)
 
  750             this->
setLow(j,mg * this->
template getBase<g::p1>(j));
 
  751             this->
setHigh(j,mg * this->
template getBase<g::p2>(j));
 
  764         typedef ::Box<dim,T> g;
 
  766         for (
size_t j = 0 ; j < dim ; j++)
 
  768             this->
setHigh(j,this->
template getBase<g::p1>(j) + mg * (this->
template getBase<g::p2>(j) - this->
template getBase<g::p1>(j)));
 
  778         for (
size_t j = 0 ; j < dim ; j++)
 
  791         for (
size_t j = 0 ; j < dim ; j++)
 
  811         for (
size_t j = 0 ; j < dim ; j++)
 
  816             if (reset_p1 == 
true)
 
  826         for (
size_t j = 0 ; j < dim ; j++)
 
  844         for (
size_t i = 0 ; i < dim ; i++)
 
  874         for (
size_t i = 0 ; i < dim ; i++)
 
  905         for (
size_t i = 0 ; i < dim ; i++)
 
  931         for (
size_t i = 0 ; i < dim ; i++)
 
  947         for (
size_t i = 0 ; i < dim ; i++)
 
  960         for (
size_t i = 0 ; i < dim ; i++)
 
  971         for (
size_t i = 0 ; i < dim ; i++)
 
  988         for (
size_t i = 0 ; i < dim ; i++)
 
 1015         for (
size_t i = 0 ; i < dim ; i++)
 
 1035         for (
size_t i = 0 ; i < dim ; i++)
 
 1036             vol *= (
p2[i] - 
p1[i] + 1.0);
 
 1056         for (
size_t i = 0 ; i < dim ; i++)
 
 1069         std::stringstream str;
 
 1071         for (
size_t i = 0 ; i < dim ; i++)
 
 1072             str << 
"x[" << i << 
"]=" << 
getLow(i) << 
" ";
 
 1076         for (
size_t i = 0 ; i < dim ; i++)
 
 1077             str << 
"x[" << i << 
"]=" << 
getHigh(i) << 
" ";
 
 1091         for (
size_t i = 0 ; i < dim ; i++)
 
T center(unsigned int i)
Get the component i of the center. 
 
void magnify_fix_P1(T mg)
Magnify the box by a factor keeping fix the point P1. 
 
void setP1(const grid_key_dx< dim > &p1)
Set the point P1 of the box. 
 
Box< dim, T > & operator+=(const Point< dim, T > &p)
Translate the box. 
 
bool isInsideNP(const Point< dim, T > &p) const 
Check if the point is inside the region excluding the positive part. 
 
Box(type box_data)
Box constructor from vector::fusion. 
 
T getLow(int i) const 
get the i-coordinate of the low bound interval of the box 
 
bool isValid() const 
Check if the Box is a valid box P2 >= P1. 
 
grid_key_dx is the key to access any element in the grid 
 
void shrinkP2(const Point< dim, T > &p)
Shrink the point P2 by one. 
 
Box(const Point< dim, T > &p1, const Point< dim, T > &p2)
Constructor from two points. 
 
bool isInside(const Point< dim, T > &p) const 
Check if the point is inside the region. 
 
Box(const encapc< 1, Box< dim, T >, Mem > &b)
Box constructor from encapsulated box. 
 
Box< dim-1, T > getSubBox()
Get the the box of dimensionality dim-1 (it eliminate the last dimension) 
 
Point< dim, T > middle() const 
Return the middle point of the box. 
 
void magnify(T mg)
Magnify the box. 
 
Box< dim, T > & operator-=(const Point< dim, T > &p)
Translate the box. 
 
static bool noPointers()
This structure has no internal pointers. 
 
Box(T *high, T *low)
Box constructor from a box. 
 
T getHigh(int i) const 
get the high interval of the box 
 
bool operator==(const Box< dim, T > &b) const 
Compare two boxes. 
 
Box(boost::fusion::vector< T[dimS], T[dimS]> &box_data)
Box constructor from vector::fusion of higher dimension. 
 
static const unsigned int max_prop
Maximum number of properties. 
 
void setHigh(int i, T val)
set the high interval of the box 
 
This class implement the point shape in an N-dimensional space. 
 
type data
It store the two point bounding the box. 
 
bool Intersect(Sphere< dim, T > &sphere)
Check if the sphere intersect the box. 
 
mem_id get(size_t i) const 
Get the i index. 
 
void setP2(const grid_key_dx< dim > &p2)
Set the point P2 of the box. 
 
bool isInside(const T(&p)[dim]) const 
Check if the point is inside the region. 
 
void enclose(Box< dim, T > &en)
Refine the box to enclose the given box and itself. 
 
Box< dim, T > & operator=(const Box< dim, T > &box)
Operator= between boxes. 
 
bool Intersect(const encapc< 1, Box< dim, T >, Mem > &e_b, Box< dim, T > &b_out) const 
Intersect. 
 
static const unsigned int p1
Low point. 
 
void setP2(const Point< dim, T > &p2)
Set the point P2 of the box. 
 
bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const 
Intersect. 
 
void setP1(const Point< dim, T > &p1)
Set the point P1 of the box. 
 
Box(const grid_key_dx< dim > &key1, const grid_key_dx< dim > &key2)
constructor from 2 grid_key_dx 
 
void ceilP1()
Translate P1 of a given vector P1. 
 
T get(int i) const 
Get coordinate. 
 
Box(const Box< dim, T > &box)
Box constructor from a box. 
 
Box< dim, T > operator*(const Point< dim, T > &p)
Multiply component wise each box points with a point. 
 
type data
structure that store the data of the point 
 
void zero()
Set p1 and p2 to 0. 
 
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin. 
 
Box(T(&box_data)[dim])
Box constructor from an array reference. 
 
bool isInside(const encapc< 1, Point< dim, T >, Mem > &p)
Check if the point is inside the region. 
 
this structure encapsulate an object of the grid 
 
void setLow(int i, T val)
set the low interval of the box 
 
static T getVolumeKey(T(&p1)[dim], T(&p2)[dim])
Get the volume spanned by the Box as grid_key_dx_iterator_sub. 
 
type & getVector()
Get the internal boost::fusion::vector that store the data. 
 
This class represent an N-dimensional box. 
 
Box< dim, T > & getBox()
Get the box enclosing this Box. 
 
T getBase(const unsigned int i) const 
Get the coordinate of the bounding point. 
 
void enlarge_fix_P1(Box< dim, S > &gh)
Enlarge the box with ghost margin keeping fix the point P1. 
 
static const unsigned int p2
High point. 
 
std::string toString() const 
Produce a string from the object. 
 
Box< dim, T > & operator/=(const Point< dim, T > &p)
Divide component wise each box points with a point. 
 
This class implement the Sphere concept in an N-dimensional space. 
 
Box(const Box< dim, S > &b)
constructor from a Box of different type 
 
Box(std::initializer_list< T > p1, std::initializer_list< T > p2)
Constructor from initializer list. 
 
boost::fusion::vector< T[dim], T[dim]> type
boost fusion that store the point 
 
void ceilP2()
Translate P1 of a unit vector on all directions. 
 
bool operator!=(const Box< dim, T > &b) const 
Compare two boxes. 
 
void contained(const Box< dim, T > &en, const bool reset_p1=true)
Refine the box to be contained in the given box and itself. 
 
T getVolumeKey() const 
Get the volume spanned by the Box P1 and P2 interpreted as grid key. 
 
void shrinkP2(T sh)
Shrink moving p2 of sh quantity (on each direction) 
 
void set(std::initializer_list< T > p1, std::initializer_list< T > p2)
Constructor from initializer list. 
 
T radius()
Get the radius of the sphere.