48 #ifndef _OPENGR_ACCELERATORS_INDEXED_NORMAL_HEAL_SET_H_ 49 #define _OPENGR_ACCELERATORS_INDEXED_NORMAL_HEAL_SET_H_ 51 #include "gr/utils/disablewarnings.h" 52 #include "gr/accelerators/utils.h" 69 using Scalar =
double;
75 #define VALIDATE_INDICES true 76 #pragma message "Index validation is enabled in debug mode" 78 #define VALIDATE_INDICES false 84 #undef VALIDATE_INDICES 91 std::vector<ChealMap*> _grid;
94 inline int indexCoordinates(
const Index3D& coord)
const 95 {
return Utils::UnrollIndexLoop<INDEX_VALIDATION_ENABLED>( coord, 2, _egSize ); }
98 inline int indexPos (
const Point& p)
const{
99 return indexCoordinates( coordinatesPos(p) );
103 inline int indexNormal(
const Point& n)
const {
105 vec2pix_ring(_resolution, n.data(), &id);
113 .unaryExpr([](
typename Point::Scalar in) {
return std::floor(in);} )
114 .cast<
typename Index3D::Scalar>();
120 : _epsilon(epsilon), _resolution(resolution) {
122 const int gridDepth = -std::log2(epsilon);
123 _egSize = std::pow(2,gridDepth);
125 if (gridDepth <= 0 || !isValid())
126 throw std::invalid_argument(
127 std::string(
"[IndexedNormalHealSet] Invalid configuration (depth=") +
128 std::to_string(gridDepth) +
129 std::string(
", size=") +
130 std::to_string(_egSize) +
132 _grid = std::vector<ChealMap*> (std::pow(_egSize, 3), NULL);
134 _ngLength = nside2npix(resolution);
136 _epsilon = 1.f/_egSize;
140 for(
unsigned int i = 0; i != _grid.size(); i++)
145 template <
typename PointT>
147 const PointT& normal,
152 const int pId = indexPos(p);
153 if (pId == -1)
return NULL;
159 const Index3D pId3 = coordinatesPos(p);
160 const int pId = indexCoordinates(pId3);
161 std::vector<ChealMap*> result;
163 if (pId == -1)
return result;
171 const int lastId = _egSize-1;
172 int imin = pId3[0] == 0 ? 0 : -1;
173 int jmin = pId3[1] == 0 ? 0 : -1;
174 int kmin = pId3[2] == 0 ? 0 : -1;
175 int imax = pId3[0] == lastId ? 1 : 2;
176 int jmax = pId3[1] == lastId ? 1 : 2;
177 int kmax = pId3[2] == lastId ? 1 : 2;
179 for (
int i = imin; i < imax; ++i)
180 for (
int j = jmin; j < jmax; ++j)
181 for (
int k = kmin; k < kmax; ++k)
183 const int id = indexCoordinates(pId3 + Index3D(i,j,k));
193 template <
typename PointT>
195 std::vector<
unsigned int>&nei);
197 template <
typename PointT>
201 template <
typename PointT>
220 template <
typename PointT>
227 const int pId = indexPos(p.
template cast<Scalar>());
228 if (pId == -1)
return false;
230 const int nId = indexNormal(n.
template cast<Scalar>());
231 if (nId == -1)
return false;
233 if (_grid[pId] == NULL) _grid[pId] =
new ChealMap(_ngLength);
234 (_grid[pId])->at(nId).push_back(id);
239 template <
typename PointT>
256 template <
typename PointT>
271 template <
typename PointT>
void getNeighbors(const PointT &p, const PointT &n, double alpha, std::vector< unsigned int > &nei)
Get closest poitns in euclidean an normal space with angular deviation.
Definition: normalHealSet.h:273
ChealMap * getMap(const Point &p)
Definition: normalHealSet.h:151
Eigen::Vector3i Index3D
Definition: normalHealSet.h:71
bool isValid() const
Definition: normalHealSet.h:208
#define M_PI
Definition: utils.h:57
std::vector< ChealMap * > getEpsilonMaps(const Point &p)
Definition: normalHealSet.h:158
bool addElement(const PointT &pos, const PointT &normal, unsigned int id)
Add a new couple pos/normal, and its associated id.
Definition: normalHealSet.h:222
CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::Scalar ComputeTransformation(const InputRange1 &P, const InputRange2 &Q, Eigen::Ref< typename CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::MatrixType > transformation, const Sampler< PointType > &sampler, TransformVisitor &v)
Definition: congruentSetExplorationBase.hpp:61
IndexedNormalHealSet(double epsilon, int resolution=4)
Definition: normalHealSet.h:119
virtual ~IndexedNormalHealSet()
Definition: normalHealSet.h:139
#define VALIDATE_INDICES
Definition: normalHealSet.h:78
std::vector< std::vector< unsigned int > > ChealMap
Definition: normalHealSet.h:72
void getNeighbors(const PointT &p, std::vector< unsigned int > &nei)
Get closest points in euclidean space.
Definition: normalHealSet.h:241
Definition: normalHealSet.h:82
Eigen::Vector3d Point
Definition: normalHealSet.h:70