OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
Box.hpp
1 
2 #ifndef BOX_HPP_
3 #define BOX_HPP_
4 
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"
9 #include <sstream>
10 
16 enum Base
17 {
18  UP,
19  DOWN
20 };
21 
55 template<unsigned int dim , typename T>
56 class Box
57 {
58 public:
59 
61  typedef boost::fusion::vector<T[dim],T[dim]> type;
63  typedef T btype;
64 
67 
69  static const unsigned int p1 = 0;
71  static const unsigned int p2 = 1;
73  static const unsigned int max_prop = 2;
74 
75  static const unsigned int dims = dim;
76 
77  // Get method
78  template <int i> inline auto get() -> decltype(boost::fusion::at_c<i>(data))
79  {
80  return boost::fusion::at_c<i>(data);
81  }
82 
93  bool Intersect(const Box<dim,T> & b, Box<dim,T> & b_out) const
94  {
95  // check if p1 of b is smaller than
96 
97  for (size_t i = 0 ; i < dim ; i++)
98  {
99  if (getLow(i) <= b.getLow(i))
100  b_out.setLow(i,b.getLow(i));
101  else if (getLow(i) <= b.getHigh(i))
102  b_out.setLow(i,getLow(i));
103  else
104  return false;
105 
106  if (getHigh(i) >= b.getHigh(i))
107  b_out.setHigh(i,b.getHigh(i));
108  else if (getHigh(i) >= b.getLow(i))
109  b_out.setHigh(i,getHigh(i));
110  else
111  return false;
112  }
113  return true;
114  }
115 
126  template<typename Mem> bool Intersect(const encapc<1,Box<dim,T>,Mem> & e_b, Box<dim,T> & b_out) const
127  {
128  return Intersect(e_b,b_out);
129  }
130 
157  template <typename distance> bool Intersect(Sphere<dim,T> & sphere)
158  {
159  // distance functor
160  distance dist;
161 
162  // Get the nearest point of the box from the center of the sphere
163  typename distance::ResultType distance_r = 0;
164 
165  for (size_t i = 0 ; i < dim ; i++)
166  {
167 
168  // if the center of the sphere on dimension i is not in the i box interval
169  // do not accumulate, otherwise accumulate from the nearest point on that
170  // dimension
171  if (boost::fusion::at_c<p1>(data)[i] < sphere.center(i))
172  {
173  // accumulate the distance from p1
174  distance_r += dist.accum_dist(sphere.center(i),boost::fusion::at_c<p1>(data)[i],i);
175  }
176  else if ( boost::fusion::at_c<p2>(data)[i] <= sphere.center(i))
177  {
178  // accumulate the distance from p2
179  distance_r += dist.accum_dist(sphere.center(i),boost::fusion::at_c<p2>(data)[i],i);
180  }
181  }
182 
183  // return if there is intersection
184  return distance_r < sphere.radius();
185  }
186 
195  template<unsigned int b> T getBase(const unsigned int i) const
196  {
197  return boost::fusion::at_c<b>(data)[i];
198  }
199 
206  Box<dim-1,T> getSubBox()
207  {
208  return Box<dim-1,T>(data);
209  }
210 
221  {
222  for(size_t i = 0 ; i < dim ; i++)
223  {setLow(i,box.getLow(i));}
224 
225  for(size_t i = 0 ; i < dim ; i++)
226  {setHigh(i,box.getHigh(i));}
227 
228  // return itself
229  return *this;
230  }
231 
232  public:
233 
235  Box()
236  {}
237 
244  Box(const Point<dim,T> & p1, const Point<dim,T> & p2)
245  {
246  setP1(p1);
247  setP2(p2);
248  }
249 
256  Box(std::initializer_list<T> p1, std::initializer_list<T> p2)
257  {
258  set(p1,p2);
259  }
260 
267  inline Box(T * high, T * low)
268  {
269  // copy all the data
270 
271  for (int i = 0 ; i < dim ; i++)
272  {
273  // p1 is low p2 is high
274 
275  boost::fusion::at_c<Box::p1>(data)[i] = low[i];
276  boost::fusion::at_c<Box::p2>(data)[i] = high[i];
277  }
278  }
279 
285  inline Box(const Box<dim,T> & box)
286  {
287  // we copy the data
288 
289  for (size_t i = 0 ; i < dim ; i++)
290  {
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];
293  }
294  }
295 
301  inline Box(type box_data)
302  {
303  // we copy the data
304 
305  for (size_t i = 0 ; i < dim ; i++)
306  {
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];
309  }
310  }
311 
317  inline Box(T (& box_data)[dim])
318  {
319  // we copy the data
320 
321  for (size_t i = 0 ; i < dim ; i++)
322  {
323  boost::fusion::at_c<p1>(data)[i] = 0;
324  boost::fusion::at_c<p2>(data)[i] = box_data[i];
325  }
326  }
327 
334  inline Box(const grid_key_dx<dim> & key1, const grid_key_dx<dim> & key2)
335  {
336  for (size_t i = 0 ; i < dim ; i++)
337  {
338  setLow(i,key1.get(i));
339  setHigh(i,key2.get(i));
340  }
341  }
342 
348  template<unsigned int dimS> inline Box(boost::fusion::vector<T[dimS],T[dimS]> & box_data)
349  {
350  // we copy the data
351 
352  for (size_t i = 0 ; i < dim ; i++)
353  {
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];
356  }
357  }
358 
364  template<typename Mem> inline Box(const encapc<1,Box<dim,T>,Mem> & b)
365  {
366  // we copy the data
367 
368  for (size_t i = 0 ; i < dim ; i++)
369  {
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];
372  }
373  }
374 
380  template <typename S> inline Box(const Box<dim,S> & b)
381  {
382  for (size_t d = 0 ; d < dim ; d++)
383  {this->setLow(d,b.getLow(d));}
384 
385  for (size_t d = 0 ; d < dim ; d++)
386  {this->setHigh(d,b.getHigh(d));}
387  }
388 
396  inline Box<dim,T> & operator/=(const Point<dim,T> & p)
397  {
398  for (size_t i = 0 ; i < dim ; i++)
399  {
400  setLow(i, getLow(i)/p.get(i));
401  setHigh(i, getHigh(i)/p.get(i));
402  }
403  return *this;
404  }
405 
414  {
415  Box<dim,T> ret;
416 
417  for (size_t i = 0 ; i < dim ; i++)
418  {
419  ret.setLow(i, getLow(i)*p.get(i));
420  ret.setHigh(i, getHigh(i)*p.get(i));
421  }
422  return ret;
423  }
424 
434  inline void set(std::initializer_list<T> p1, std::initializer_list<T> p2)
435  {
436  size_t i = 0;
437  for(T x : p1)
438  {
439  setLow(i,x);
440  i++;
441  if (i >= dim)
442  break;
443  }
444 
445  i = 0;
446  for(T x : p2)
447  {
448  setHigh(i,x);
449  i++;
450  if (i >= dim)
451  break;
452  }
453  }
454 
461  inline void setLow(int i, T val)
462  {
463  boost::fusion::at_c<p1>(data)[i] = val;
464  }
465 
472  inline void setHigh(int i, T val)
473  {
474  boost::fusion::at_c<p2>(data)[i] = val;
475  }
476 
484  inline T getLow(int i) const
485  {
486  return boost::fusion::at_c<p1>(data)[i];
487  }
488 
495  inline T getHigh(int i) const
496  {
497  return boost::fusion::at_c<p2>(data)[i];
498  }
499 
505  inline void setP1(const grid_key_dx<dim> & p1)
506  {
507  for (size_t i = 0 ; i < dim ; i++)
508  setLow(i,p1.get(i));
509  }
510 
516  inline void setP2(const grid_key_dx<dim> & p2)
517  {
518  for (size_t i = 0 ; i < dim ; i++)
519  setHigh(i,p2.get(i));
520  }
521 
527  inline void setP1(const Point<dim,T> & p1)
528  {
529  for (size_t i = 0 ; i < dim ; i++)
530  setLow(i,p1.get(i));
531  }
532 
538  inline void setP2(const Point<dim,T> & p2)
539  {
540  for (size_t i = 0 ; i < dim ; i++)
541  setHigh(i,p2.get(i));
542  }
543 
552  {
553  return *this;
554  }
555 
563  {
564  return data;
565  }
566 
567  /* \brief Get the point p1 as grid_key_dx
568  *
569  * \return the key
570  *
571  */
572  grid_key_dx<dim> getKP1() const
573  {
574  // grid key to return
575  grid_key_dx<dim> ret(boost::fusion::at_c<p1>(data));
576 
577  return ret;
578  }
579 
580  /* \brief Get the point p12 as grid_key_dx
581  *
582  * \return the key
583  *
584  */
585  grid_key_dx<dim> getKP2() const
586  {
587  // grid key to return
588  grid_key_dx<dim> ret(boost::fusion::at_c<p2>(data));
589 
590  return ret;
591  }
592 
593  /* \brief Get the point p1
594  *
595  * \return the point p1
596  *
597  */
598  inline Point<dim,T> getP1() const
599  {
600  // grid key to return
601  Point<dim,T> ret(boost::fusion::at_c<p1>(data));
602 
603  return ret;
604  }
605 
606  /* \brief Get the point p2
607  *
608  * \return the point p2
609  *
610  */
611 
612  inline Point<dim,T> getP2() const
613  {
614  // grid key to return
615  Point<dim,T> ret(boost::fusion::at_c<p2>(data));
616 
617  return ret;
618  }
619 
627  inline Box<dim,T> & operator-=(const Point<dim,T> & p)
628  {
629  for (size_t i = 0 ; i < dim ; i++)
630  {
631  boost::fusion::at_c<p2>(data)[i] -= p.get(i);
632  boost::fusion::at_c<p1>(data)[i] -= p.get(i);
633  }
634 
635  return *this;
636  }
637 
645  inline Box<dim,T> & operator+=(const Point<dim,T> & p)
646  {
647  for (size_t i = 0 ; i < dim ; i++)
648  {
649  boost::fusion::at_c<p2>(data)[i] += p.get(i);
650  boost::fusion::at_c<p1>(data)[i] += p.get(i);
651  }
652 
653  return *this;
654  }
655 
656  /* \brief expand expand the box by a vector
657  *
658  * \param vector
659  *
660  */
661  inline void expand(T (& exp)[dim])
662  {
663  for (size_t i = 0 ; i < dim ; i++)
664  {
665  boost::fusion::at_c<p2>(data)[i] = boost::fusion::at_c<p2>(data)[i] + exp[i];
666  }
667  }
668 
691  void enlarge(const Box<dim,T> & gh)
692  {
693  typedef ::Box<dim,T> g;
694 
695  for (size_t j = 0 ; j < dim ; j++)
696  {
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));
699  }
700  }
701 
724  template<typename S> inline void enlarge_fix_P1(Box<dim,S> & gh)
725  {
726  typedef ::Box<dim,T> g;
727 
728  for (size_t j = 0 ; j < dim ; j++)
729  {
730  this->setHigh(j,this->template getBase<g::p2>(j) + gh.template getBase<g::p2>(j) - gh.template getBase<g::p1>(j));
731  }
732  }
733 
734 
744  void magnify(T mg)
745  {
746  typedef ::Box<dim,T> g;
747 
748  for (size_t j = 0 ; j < dim ; j++)
749  {
750  this->setLow(j,mg * this->template getBase<g::p1>(j));
751  this->setHigh(j,mg * this->template getBase<g::p2>(j));
752  }
753  }
754 
762  inline void magnify_fix_P1(T mg)
763  {
764  typedef ::Box<dim,T> g;
765 
766  for (size_t j = 0 ; j < dim ; j++)
767  {
768  this->setHigh(j,this->template getBase<g::p1>(j) + mg * (this->template getBase<g::p2>(j) - this->template getBase<g::p1>(j)));
769  }
770  }
771 
776  inline void shrinkP2(T sh)
777  {
778  for (size_t j = 0 ; j < dim ; j++)
779  {
780  this->setHigh(j,this->getHigh(j) - sh);
781  }
782  }
783 
789  inline void enclose(Box<dim,T> & en)
790  {
791  for (size_t j = 0 ; j < dim ; j++)
792  {
793  if (getLow(j) > en.getLow(j))
794  this->setLow(j,en.getLow(j));
795 
796  if (getHigh(j) < en.getHigh(j))
797  this->setHigh(j,en.getHigh(j));
798  }
799  }
800 
809  inline void contained(const Box<dim,T> & en, const bool reset_p1 = true)
810  {
811  for (size_t j = 0 ; j < dim ; j++)
812  {
813  if (getHigh(j) > (en.getHigh(j) - en.getLow(j)))
814  setHigh(j,en.getHigh(j) - en.getLow(j));
815 
816  if (reset_p1 == true)
817  setLow(j,0);
818  }
819  }
820 
824  void zero()
825  {
826  for (size_t j = 0 ; j < dim ; j++)
827  {
828  setHigh(j,0);
829  setLow(j,0);
830  }
831  }
832 
840  bool isInside(const Point<dim,T> & p) const
841  {
842  // check if bound
843 
844  for (size_t i = 0 ; i < dim ; i++)
845  {
846  // if outside the region return false
847  if ( boost::fusion::at_c<Point<dim,T>::x>(p.data)[i] < boost::fusion::at_c<Box<dim,T>::p1>(this->data)[i]
848  || boost::fusion::at_c<Point<dim,T>::x>(p.data)[i] > boost::fusion::at_c<Box<dim,T>::p2>(this->data)[i])
849  {
850  // Out of bound
851 
852  return false;
853  }
854 
855  }
856 
857  // In bound
858 
859  return true;
860  }
861 
870  bool isInsideNP(const Point<dim,T> & p) const
871  {
872  // check if bound
873 
874  for (size_t i = 0 ; i < dim ; i++)
875  {
876  // if outside the region return false
877  if ( boost::fusion::at_c<Point<dim,T>::x>(p.data)[i] < boost::fusion::at_c<Box<dim,T>::p1>(this->data)[i]
878  || boost::fusion::at_c<Point<dim,T>::x>(p.data)[i] >= boost::fusion::at_c<Box<dim,T>::p2>(this->data)[i])
879  {
880  // Out of bound
881 
882 
883 
884  return false;
885  }
886 
887  }
888 
889  // In bound
890 
891  return true;
892  }
893 
901  bool isInside(const T (&p)[dim]) const
902  {
903  // check if bound
904 
905  for (size_t i = 0 ; i < dim ; i++)
906  {
907  // if outside the region return false
908  if ( p[i] < boost::fusion::at_c<Box<dim,T>::p1>(this->data)[i]
909  || p[i] > boost::fusion::at_c<Box<dim,T>::p2>(this->data)[i])
910  {
911  // Out of bound
912 
913  return false;
914  }
915 
916  }
917 
918  // In bound
919 
920  return true;
921  }
922 
923 
929  bool isValid() const
930  {
931  for (size_t i = 0 ; i < dim ; i++)
932  {
933  if (getLow(i) > getHigh(i))
934  return false;
935  }
936 
937  return true;
938  }
939 
945  void ceilP1()
946  {
947  for (size_t i = 0 ; i < dim ; i++)
948  {
949  setLow(i,std::ceil(getLow(i)));
950  }
951  }
952 
958  void ceilP2()
959  {
960  for (size_t i = 0 ; i < dim ; i++)
961  {
962  setHigh(i,std::ceil(getHigh(i)));
963  }
964  }
965 
969  void shrinkP2(const Point<dim,T> & p)
970  {
971  for (size_t i = 0 ; i < dim ; i++)
972  {
973  setHigh(i,getHigh(i) - p.get(i));
974  }
975  }
976 
984  template <typename Mem> bool isInside(const encapc<1,Point<dim,T>,Mem> & p)
985  {
986  // check if bound
987 
988  for (size_t i = 0 ; i < dim ; i++)
989  {
990  // if outside the region return false
991  if ( p.template get<Point<dim,T>::x>()[i] < boost::fusion::at_c<Box<dim,T>::p1>(this->data)[i]
992  || p.template get<Point<dim,T>::x>()[i] > boost::fusion::at_c<Box<dim,T>::p2>(this->data)[i])
993  {
994  // Out of bound
995 
996  return false;
997  }
998 
999  }
1000 
1001  // In bound
1002 
1003  return true;
1004  }
1005 
1011  inline T getVolumeKey() const
1012  {
1013  T vol = 1.0;
1014 
1015  for (size_t i = 0 ; i < dim ; i++)
1016  vol *= (getHigh(i) - getLow(i) + 1.0);
1017 
1018  return vol;
1019  }
1020 
1031  inline static T getVolumeKey(T (&p1)[dim], T(&p2)[dim])
1032  {
1033  T vol = 1.0;
1034 
1035  for (size_t i = 0 ; i < dim ; i++)
1036  vol *= (p2[i] - p1[i] + 1.0);
1037 
1038  return vol;
1039  }
1040 
1042  static bool noPointers()
1043  {
1044  return true;
1045  }
1046 
1052  inline Point<dim,T> middle() const
1053  {
1054  Point<dim,T> p;
1055 
1056  for (size_t i = 0 ; i < dim ; i++)
1057  p.get(i) = (getLow(i) + getHigh(i))/2;
1058 
1059  return p;
1060  }
1061 
1067  std::string toString() const
1068  {
1069  std::stringstream str;
1070 
1071  for (size_t i = 0 ; i < dim ; i++)
1072  str << "x[" << i << "]=" << getLow(i) << " ";
1073 
1074  str << " | ";
1075 
1076  for (size_t i = 0 ; i < dim ; i++)
1077  str << "x[" << i << "]=" << getHigh(i) << " ";
1078 
1079  return str.str();
1080  }
1081 
1089  bool operator==(const Box<dim,T> & b) const
1090  {
1091  for (size_t i = 0 ; i < dim ; i++)
1092  {
1093  if (getLow(i) != b.getLow(i))
1094  return false;
1095 
1096  if (getHigh(i) != b.getHigh(i))
1097  return false;
1098  }
1099 
1100  return true;
1101  }
1102 
1103 
1111  bool operator!=(const Box<dim,T> & b) const
1112  {
1113  return ! this->operator==(b);
1114  }
1115 };
1116 
1117 #endif
T center(unsigned int i)
Get the component i of the center.
Definition: Sphere.hpp:44
void magnify_fix_P1(T mg)
Magnify the box by a factor keeping fix the point P1.
Definition: Box.hpp:762
void setP1(const grid_key_dx< dim > &p1)
Set the point P1 of the box.
Definition: Box.hpp:505
Box< dim, T > & operator+=(const Point< dim, T > &p)
Translate the box.
Definition: Box.hpp:645
bool isInsideNP(const Point< dim, T > &p) const
Check if the point is inside the region excluding the positive part.
Definition: Box.hpp:870
Box(type box_data)
Box constructor from vector::fusion.
Definition: Box.hpp:301
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition: Box.hpp:484
bool isValid() const
Check if the Box is a valid box P2 >= P1.
Definition: Box.hpp:929
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
void shrinkP2(const Point< dim, T > &p)
Shrink the point P2 by one.
Definition: Box.hpp:969
Box(const Point< dim, T > &p1, const Point< dim, T > &p2)
Constructor from two points.
Definition: Box.hpp:244
bool isInside(const Point< dim, T > &p) const
Check if the point is inside the region.
Definition: Box.hpp:840
Box(const encapc< 1, Box< dim, T >, Mem > &b)
Box constructor from encapsulated box.
Definition: Box.hpp:364
Box< dim-1, T > getSubBox()
Get the the box of dimensionality dim-1 (it eliminate the last dimension)
Definition: Box.hpp:206
Point< dim, T > middle() const
Return the middle point of the box.
Definition: Box.hpp:1052
void magnify(T mg)
Magnify the box.
Definition: Box.hpp:744
Box< dim, T > & operator-=(const Point< dim, T > &p)
Translate the box.
Definition: Box.hpp:627
static bool noPointers()
This structure has no internal pointers.
Definition: Box.hpp:1042
Box(T *high, T *low)
Box constructor from a box.
Definition: Box.hpp:267
T getHigh(int i) const
get the high interval of the box
Definition: Box.hpp:495
bool operator==(const Box< dim, T > &b) const
Compare two boxes.
Definition: Box.hpp:1089
Box(boost::fusion::vector< T[dimS], T[dimS]> &box_data)
Box constructor from vector::fusion of higher dimension.
Definition: Box.hpp:348
static const unsigned int max_prop
Maximum number of properties.
Definition: Box.hpp:73
T btype
type of the box
Definition: Box.hpp:63
void setHigh(int i, T val)
set the high interval of the box
Definition: Box.hpp:472
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:20
type data
It store the two point bounding the box.
Definition: Box.hpp:66
bool Intersect(Sphere< dim, T > &sphere)
Check if the sphere intersect the box.
Definition: Box.hpp:157
mem_id get(size_t i) const
Get the i index.
Definition: grid_key.hpp:302
void setP2(const grid_key_dx< dim > &p2)
Set the point P2 of the box.
Definition: Box.hpp:516
bool isInside(const T(&p)[dim]) const
Check if the point is inside the region.
Definition: Box.hpp:901
void enclose(Box< dim, T > &en)
Refine the box to enclose the given box and itself.
Definition: Box.hpp:789
Box< dim, T > & operator=(const Box< dim, T > &box)
Operator= between boxes.
Definition: Box.hpp:220
bool Intersect(const encapc< 1, Box< dim, T >, Mem > &e_b, Box< dim, T > &b_out) const
Intersect.
Definition: Box.hpp:126
Box()
default constructor
Definition: Box.hpp:235
static const unsigned int p1
Low point.
Definition: Box.hpp:69
void setP2(const Point< dim, T > &p2)
Set the point P2 of the box.
Definition: Box.hpp:538
bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
Definition: Box.hpp:93
void setP1(const Point< dim, T > &p1)
Set the point P1 of the box.
Definition: Box.hpp:527
Box(const grid_key_dx< dim > &key1, const grid_key_dx< dim > &key2)
constructor from 2 grid_key_dx
Definition: Box.hpp:334
void ceilP1()
Translate P1 of a given vector P1.
Definition: Box.hpp:945
T get(int i) const
Get coordinate.
Definition: Point.hpp:42
Box(const Box< dim, T > &box)
Box constructor from a box.
Definition: Box.hpp:285
Box< dim, T > operator*(const Point< dim, T > &p)
Multiply component wise each box points with a point.
Definition: Box.hpp:413
type data
structure that store the data of the point
Definition: Point.hpp:30
void zero()
Set p1 and p2 to 0.
Definition: Box.hpp:824
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
Definition: Box.hpp:691
Box(T(&box_data)[dim])
Box constructor from an array reference.
Definition: Box.hpp:317
bool isInside(const encapc< 1, Point< dim, T >, Mem > &p)
Check if the point is inside the region.
Definition: Box.hpp:984
this structure encapsulate an object of the grid
Definition: Encap.hpp:209
void setLow(int i, T val)
set the low interval of the box
Definition: Box.hpp:461
static T getVolumeKey(T(&p1)[dim], T(&p2)[dim])
Get the volume spanned by the Box as grid_key_dx_iterator_sub.
Definition: Box.hpp:1031
type & getVector()
Get the internal boost::fusion::vector that store the data.
Definition: Box.hpp:562
This class represent an N-dimensional box.
Definition: Box.hpp:56
Box< dim, T > & getBox()
Get the box enclosing this Box.
Definition: Box.hpp:551
T getBase(const unsigned int i) const
Get the coordinate of the bounding point.
Definition: Box.hpp:195
void enlarge_fix_P1(Box< dim, S > &gh)
Enlarge the box with ghost margin keeping fix the point P1.
Definition: Box.hpp:724
static const unsigned int p2
High point.
Definition: Box.hpp:71
std::string toString() const
Produce a string from the object.
Definition: Box.hpp:1067
Box< dim, T > & operator/=(const Point< dim, T > &p)
Divide component wise each box points with a point.
Definition: Box.hpp:396
This class implement the Sphere concept in an N-dimensional space.
Definition: Sphere.hpp:23
Box(const Box< dim, S > &b)
constructor from a Box of different type
Definition: Box.hpp:380
Box(std::initializer_list< T > p1, std::initializer_list< T > p2)
Constructor from initializer list.
Definition: Box.hpp:256
boost::fusion::vector< T[dim], T[dim]> type
boost fusion that store the point
Definition: Box.hpp:61
void ceilP2()
Translate P1 of a unit vector on all directions.
Definition: Box.hpp:958
bool operator!=(const Box< dim, T > &b) const
Compare two boxes.
Definition: Box.hpp:1111
void contained(const Box< dim, T > &en, const bool reset_p1=true)
Refine the box to be contained in the given box and itself.
Definition: Box.hpp:809
T getVolumeKey() const
Get the volume spanned by the Box P1 and P2 interpreted as grid key.
Definition: Box.hpp:1011
void shrinkP2(T sh)
Shrink moving p2 of sh quantity (on each direction)
Definition: Box.hpp:776
void set(std::initializer_list< T > p1, std::initializer_list< T > p2)
Constructor from initializer list.
Definition: Box.hpp:434
T radius()
Get the radius of the sphere.
Definition: Sphere.hpp:74