48 #ifndef _OPENGR_ACCELERATORS_INTERSECTION_FUNCTOR_H_ 49 #define _OPENGR_ACCELERATORS_INTERSECTION_FUNCTOR_H_ 51 #include "gr/accelerators/pairExtraction/intersectionNode.h" 57 template <
typename Scalar>
59 const int lvlMax = -std::log2(epsilon);
61 if (lvl != nullptr) *lvl = lvlMax;
64 return 1.f/pow(2,lvlMax);
73 template <
class _Primitive,
class _Point,
int _dim,
typename _Scalar>
80 template <
class PrimitiveContainer,
82 class ProcessingFunctor>
85 const PrimitiveContainer& M,
86 const PointContainer & Q,
88 unsigned int minNodeSize,
89 ProcessingFunctor& functor
99 template <
class PrimitiveContainer,
100 class PointContainer,
101 class ProcessingFunctor>
104 const PrimitiveContainer& M,
105 const PointContainer & Q,
107 unsigned int minNodeSize,
108 ProcessingFunctor& functor
114 typedef NdNode<Point, dim, Scalar, PointContainer> Node;
115 typedef typename std::vector<Node> NodeContainer;
117 typedef typename std::pair<
unsigned int,
unsigned int> ResPair;
118 typedef typename std::vector<ResPair> ResContainer;
121 const unsigned int nbPoint = Q.size();
123 epsilon = GetRoundedEpsilonValue(epsilon, &lvlMax);
128 NodeContainer ping, pong;
129 NodeContainer* nodes = &ping;
130 NodeContainer* childNodes = &pong;
133 std::vector< std::pair<Node, Scalar> > earlyNodes;
136 if (functor.ids.size() != nbPoint){
137 std::cout <<
"[IntersectionFunctor] Init id array" << std::endl;
139 for(
unsigned int i = 0; i < nbPoint; i++)
140 functor.ids.push_back(i);
145 childNodes->push_back(Node::buildUnitRootNode(Q, functor.ids));
148 Scalar edgeHalfLength = 0.f;
151 while (clvl != lvlMax-1){
153 if (childNodes->empty())
156 edgeLength =
Scalar(1.f)/pow(2, clvl);
157 edgeHalfLength = edgeLength/
Scalar(2.f);
160 std::swap(nodes, childNodes);
164 for(
typename NodeContainer::iterator nit = nodes->begin();
165 nit != nodes->end(); nit++){
170 for(
typename PrimitiveContainer::const_iterator pit = M.begin();
171 pit != M.end(); pit++){
173 if ((*pit).intersect(n.center(), edgeHalfLength+epsilon)){
176 if (n.rangeLength() >
int(minNodeSize)){
178 n.split(*childNodes, edgeHalfLength);
181 earlyNodes.emplace_back(n, edgeHalfLength+epsilon);
191 ResContainer results;
192 results.reserve(childNodes->size());
194 unsigned int pId = 0;
195 for(
typename PrimitiveContainer::const_iterator itP = M.begin();
196 itP != M.end(); itP++, pId++){
198 for(
typename NodeContainer::const_iterator itN = childNodes->begin();
199 itN != childNodes->end(); itN++){
200 if ((*itP).intersect((*itN).center(), epsilon*2.f)){
202 functor.beginPrimitiveCollect(pId);
203 for(
unsigned int j = 0; j!= (
unsigned int)((*itN).rangeLength()); j++){
204 if(pId>(*itN).idInRange(j))
205 if((*itP).intersectPoint((*itN).pointInRange(j),epsilon))
206 functor.process(pId, (*itN).idInRange(j));
208 functor.endPrimitiveCollect(pId);
213 for(
typename std::vector< std::pair<Node, Scalar> >::const_iterator itPairs =
215 itPairs != earlyNodes.end();
217 if((*itP).intersect((*itPairs).first.center(), (*itPairs).second)){
220 functor.beginPrimitiveCollect(pId);
221 for(
unsigned int j = 0; j!= (
unsigned int)((*itPairs).first.rangeLength()); j++){
222 if(pId>(*itPairs).first.idInRange(j))
223 if((*itP).intersectPoint((*itPairs).first.pointInRange(j),epsilon))
224 functor.process(pId, (*itPairs).first.idInRange(j));
227 functor.endPrimitiveCollect(pId);
_Primitive Primitive
Definition: intersectionFunctor.h:76
static Scalar GetRoundedEpsilonValue(Scalar epsilon, int *lvl=nullptr)
Definition: intersectionFunctor.h:58
Extract pairs of points by rasterizing primitives and collect points.
Definition: intersectionFunctor.h:74
_Point Point
Definition: intersectionFunctor.h:75
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
_Scalar Scalar
Definition: intersectionFunctor.h:77
Definition: intersectionFunctor.h:78
void process(const PrimitiveContainer &M, const PointContainer &Q, Scalar &epsilon, unsigned int minNodeSize, ProcessingFunctor &functor)
< Process the extracted pairs
Definition: intersectionFunctor.h:103