OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
AdaptiveCylinderCone.hpp
1#ifndef ADAPTIVE_CONE_HPP_
2#define ADAPTIVE_CONE_HPP_
3
4#include <boost/fusion/include/mpl.hpp>
5#include "Space/Shape/Box.hpp"
6#include "Space/Shape/Point.hpp"
7#include <boost/mpl/range_c.hpp>
8#include <boost/mpl/for_each.hpp>
9
21template<typename S>
23{
25 const S * ptr;
26
28 copy_acc(const S * ptr)
29 :ptr(ptr){};
30
32 template<typename T>
33 void operator()(T& t) const
34 {
35 t = ptr[t];
36 }
37};
38
70template<unsigned int dim , typename T>
72{
75
76 public:
77
79 typedef boost::fusion::vector<T[dim]> type;
80
84
86 static const unsigned int p1 = 0;
87
94 template <typename distance> bool Intersect(Box<dim,T> b)
95 {
96// std::cout << "Intersection between" << "\n";
97/* for (int i = 0 ; i < dim ; i++)
98 {
99 std::cout << "Box: " << boost::fusion::at_c<0>(b.data)[i] << " " << boost::fusion::at_c<1>(b.data)[i] << "\n";
100 }*/
101
102 // We have to check if the upper-base of the box intersect the shape, if not we have done
103
104 // we get the upper base that is a box of dimension dim-1
105 Box<dim-1,T> upBase = b.getSubBox();
106
107 // Get the up level
108 T up = b.template getBase<Base::UP>(dim-1);
109
110 // we get the circle of dimension n-1 at the same level of the upper base of the box
111
112 // this is the radius of the circle
113 T r_p = 0;
114
115 // if the plane is at lower level than the point r_p is the cylinder radius
116 // otherwise is the cone cut
117
118 if (b.template getBase<Base::UP>(dim-1) < boost::fusion::at_c<PointA::x>(data)[dim-1] )
119 {
120 r_p = boost::fusion::at_c<PointA::x>(data)[dim-1];
121 }
122 else
123 {
124 // r_p is the cone cut (plane of base box cutting the cone)
125
126 r_p = b.template getBase<Base::UP>(dim-1);
127 }
128
129 // Create the cone-cylinder cut with the plane of the base
130 Sphere<dim-1,T> acon(data,up);
131
132 return upBase.Intersect<distance>(acon);
133 }
134
150 template <typename distance> bool Intersect(Box<dim,T> b, int div, T * dists, T & minsqdistance)
151 {
152 // we simply ignore all the optimization parameters we just check that
153 // the box intersect the adaptive cone
154
155 return Intersect<distance>(b);
156 }
157
158
165 {
166 // for all components from the pt and fill the center point of the
167 // Adaptive Cylinder Cone
168
169 for (int i = 0 ; i < dim ; i++)
170 {
171 boost::fusion::at_c<0>(data)[i] = pt[i];
172 }
173 }
174
183 template<typename Distance> bool isInside(Point<dim,T> pnt)
184 {
185 // Check if the point is inside the Adaptive cone
186
187 // get the radius
188
189 T r = pnt.get(dim-1);
190
191 // create a sphere
192
193 Sphere<dim-1,T> sphere(data,r);
194
195 sphere.isInside<Distance>(pnt.getSubPoint(dim-1));
196 }
197
205 template<typename Distance> bool isInside(float * pnt)
206 {
207 // Check if the point is inside the Adaptive cone
208
209 // get the radius
210
211 T r = pnt[dim-1];
212
213 // create a sphere
214
215 Sphere<dim-1,T> sphere(data,r);
216
217 sphere.isInside<Distance>(pnt);
218 }
219};
220
221#endif
This class represent an Adaptive cylinder cone.
bool Intersect(Box< dim, T > b)
This function check if a box intersect this shape.
bool isInside(float *pnt)
Is a point inside the adaptive cone.
bool isInside(Point< dim, T > pnt)
Is a point inside the adaptive cone.
static const unsigned int p1
Point where cone and cylinder base match.
bool Intersect(Box< dim, T > b, int div, T *dists, T &minsqdistance)
This function check if a box intersect this shape.
Point< dim, T > PointA
Base structure that define a Point.
boost::fusion::vector< T[dim]> type
boost fusion that store the point
AdaptiveCylinderCone(const T *pt)
Create an adaptive cylinder Cone for the point pt.
This class represent an N-dimensional box.
Definition Box.hpp:61
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Definition Point.hpp:172
This class implement the Sphere concept in an N-dimensional space.
Definition Sphere.hpp:24
this class is a functor for "for_each" algorithm
copy_acc(const S *ptr)
constructor it fix the size
void operator()(T &t) const
It call the copy function for each member.
const S * ptr
Pointer storing the data point.