48 #ifndef _SUPER4PCS_ACCELERATORS_INDEXED_NORMAL_SET_HPP_ 49 #define _SUPER4PCS_ACCELERATORS_INDEXED_NORMAL_SET_HPP_ 53 #include <Eigen/Geometry> 57 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
59 IndexedNormalSet<Point, dim, _ngSize, Scalar>::_nepsilon;
61 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
63 for(
unsigned int i = 0; i != _grid.size(); i++)
71 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
77 return Utils::UnrollIndexLoop<VALIDATE_INDICES>( coordinatesPos(p), dim-1, _egSize );
84 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
90 return Utils::UnrollIndexLoop<VALIDATE_INDICES>( coordinatesNormal(n), dim-1, _ngSize);
94 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
97 const Point& pCoord)
const 100 return Utils::UnrollIndexLoop<VALIDATE_INDICES>( pCoord, dim-1, _egSize );
104 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
107 const Point& nCoord)
const 110 return Utils::UnrollIndexLoop<VALIDATE_INDICES>( nCoord, dim-1, _ngSize);
114 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
121 const int pId = indexPos(p);
122 if (pId == -1)
return false;
124 const int nId = indexNormal(n);
125 if (nId == -1)
return false;
127 if (_grid[pId] == NULL) _grid[pId] =
new AngularGrid;
128 (_grid[pId])->at(nId).push_back(
id);
134 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
138 std::vector<unsigned int>&nei)
141 if ( grid == NULL )
return;
143 for(
typename AngularGrid::const_iterator it = grid->cbegin();
144 it != grid->cend(); it++){
145 const std::vector<unsigned int>& lnei = *it;
146 nei.insert( nei.end(), lnei.begin(), lnei.end() );
151 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
156 std::vector<unsigned int>&nei)
159 if ( grid == NULL )
return;
161 const std::vector<unsigned int>& lnei = grid->at(indexNormal(n));
162 nei.insert( nei.end(), lnei.begin(), lnei.end() );
166 template <
class Po
int,
int dim,
int _ngSize,
typename Scalar>
172 std::vector<unsigned int>&nei,
176 if ( grid == NULL )
return;
178 const Scalar alpha = std::acos(cosAlpha);
179 const Scalar perimeter =
Scalar(2) * M_PI * std::atan(alpha);
180 const unsigned int nbSample = 2*std::ceil(perimeter*
Scalar(_ngSize) /
Scalar(2.));
183 const Scalar sinAlpha = std::sin(alpha);
185 Eigen::Quaternion<Scalar> q;
186 q.setFromTwoVectors(Point(0.,0.,1.), n);
188 std::set<unsigned int> colored;
191 for(
unsigned int a = 0; a != nbSample; a++){
193 const Point dir = ( q * Point(sinAlpha*std::cos(theta),
194 sinAlpha*std::sin(theta),
195 cosAlpha ) ).normalized();
196 int id = indexNormal( dir );
197 if(grid->at(
id).size() != 0){
202 id = indexNormal( -dir );
203 if(grid->at(
id).size() != 0){
209 for( std::set<unsigned int>::const_iterator it = colored.cbegin();
210 it != colored.cend(); it++){
211 const std::vector<unsigned int>& lnei = grid->at(*it);
212 nei.insert( nei.end(), lnei.begin(), lnei.end() );
219 #endif // _INDEXED_NORMAL_SET_HPP_ Normal set indexed by a position in euclidean space.
Definition: normalset.h:71
virtual ~IndexedNormalSet()
Definition: normalset.hpp:62
bool addElement(const Point &pos, const Point &normal, unsigned int id)
Add a new couple pos/normal, and its associated id.
Definition: normalset.hpp:116
std::array< std::vector< unsigned int >, Utils::POW(_ngSize, dim)> AngularGrid
Definition: normalset.h:73
_Scalar Scalar
Definition: normalset.h:76
void getNeighbors(const Point &p, std::vector< unsigned int > &nei)
Get closest points in euclidean space.
Definition: normalset.hpp:136