5 #ifndef SUPER4PCS_FUNCTORSUPER4PCS_H 6 #define SUPER4PCS_FUNCTORSUPER4PCS_H 10 #include "gr/utils/shared.h" 11 #include "gr/algorithms/pairCreationFunctor.h" 13 #ifdef SUPER4PCS_USE_CHEALPIX 14 #include "gr/accelerators/normalHealSet.h" 16 #include "gr/accelerators/normalset.h" 17 #include "gr/accelerators/utils.h" 31 template <
typename PointType,
typename PointFilterFunctor,
typename Options>
34 using BaseCoordinates =
typename Traits4pcs<PointType>::Coordinates;
35 using Scalar =
typename PointType::Scalar;
37 using VectorType =
typename PointType::VectorType;
38 using OptionType = Options;
39 using PairCreationFunctorType =
PairCreationFunctor<PointType, Scalar, PointFilterFunctor, OptionType>;
43 std::vector<PointType> &mySampled_Q_3D_;
44 BaseCoordinates &myBase_3D_;
46 mutable PairCreationFunctorType pcfunctor_;
51 BaseCoordinates& base_3D_,
52 const OptionType& options)
60 pcfunctor_.synch3DContent();
76 Scalar pair_normals_angle,
77 Scalar pair_distance_epsilon,
80 PairsVector* pairs)
const {
82 pcfunctor_.pairs = pairs;
85 pairs->reserve(2 * pcfunctor_.points.size());
87 pcfunctor_.pair_distance = pair_distance;
88 pcfunctor_.pair_distance_epsilon = pair_distance_epsilon;
89 pcfunctor_.pair_normals_angle = pair_normals_angle;
90 pcfunctor_.setRadius(pair_distance);
91 pcfunctor_.setBase(base_point1, base_point2, myBase_3D_);
95 <
typename PairCreationFunctorType::Primitive,
typename PairCreationFunctorType::Point, 3, Scalar> interFunctor;
98 <
typename PairCreationFunctorType::Primitive,
99 typename PairCreationFunctorType::Point, 3, Scalar> interFunctor;
102 Scalar eps = pcfunctor_.getNormalizedEpsilon(pair_distance_epsilon);
104 interFunctor.process(pcfunctor_.primitives,
128 Scalar distance_threshold2,
129 const std::vector<std::pair<
int,
int>>& First_pairs,
130 const std::vector<std::pair<
int,
int>>& Second_pairs,
131 typename Traits4pcs<PointType>::Set* quadrilaterals)
const {
133 typedef typename PairCreationFunctorType::Point Point;
135 #ifdef SUPER4PCS_USE_CHEALPIX 136 typedef gr::IndexedNormalHealSet IndexedNormalSet3D;
147 if (quadrilaterals == nullptr)
return false;
149 quadrilaterals->clear();
153 (myBase_3D_[1]->pos() - myBase_3D_[0]->pos()).normalized().dot(
154 (myBase_3D_[3]->pos() - myBase_3D_[2]->pos()).normalized());
157 const Scalar eps = pcfunctor_.getNormalizedEpsilon(distance_threshold2);
159 IndexedNormalSet3D nset (eps);
161 for (size_t i = 0; i < First_pairs.size(); ++i) {
162 const Point& p1 = pcfunctor_.points[First_pairs[i].first];
163 const Point& p2 = pcfunctor_.points[First_pairs[i].second];
164 const Point n = (p2 - p1).normalized();
166 nset.addElement((p1+
typename Point::Scalar(invariant1) * (p2 - p1)).eval(), n, i);
170 std::set< std::pair<
unsigned int,
unsigned int > > comb;
172 std::vector<
unsigned int> nei;
174 for (
unsigned int i = 0; i < Second_pairs.size(); ++i) {
175 const Point& p1 = pcfunctor_.points[Second_pairs[i].first];
176 const Point& p2 = pcfunctor_.points[Second_pairs[i].second];
178 const VectorType& pq1 = mySampled_Q_3D_[Second_pairs[i].first].pos();
179 const VectorType& pq2 = mySampled_Q_3D_[Second_pairs[i].second].pos();
183 const Point query = p1 + invariant2 * ( p2 - p1 );
184 const VectorType queryQ = pq1 + invariant2 * (pq2 - pq1);
186 const Point queryn = (p2 - p1).normalized();
188 nset.getNeighbors( query, queryn, alpha, nei);
193 for (
unsigned int k = 0; k != nei.size(); k++){
194 const int id = nei[k];
196 const VectorType& pp1 = mySampled_Q_3D_[First_pairs[id].first].pos();
197 const VectorType& pp2 = mySampled_Q_3D_[First_pairs[id].second].pos();
199 invPoint = pp1 + (pp2 - pp1) * invariant1;
202 if ((queryQ-invPoint).squaredNorm() <= distance_threshold2){
208 for (std::set< std::pair<
unsigned int,
unsigned int>>::const_iterator it = comb.cbegin();
209 it != comb.cend(); it++) {
210 const unsigned int & id = (*it).first;
211 const unsigned int & i = (*it).second;
213 quadrilaterals->push_back( {First_pairs[id].first, First_pairs[id].second,
214 Second_pairs[i].first, Second_pairs[i].second });
217 return quadrilaterals->size() != 0;
Definition: pairCreationFunctor.h:16
static constexpr int size()
Definition: match4pcsBase.h:27
bool FindCongruentQuadrilaterals(Scalar invariant1, Scalar invariant2, Scalar, Scalar distance_threshold2, const std::vector< std::pair< int, int >> &First_pairs, const std::vector< std::pair< int, int >> &Second_pairs, typename Traits4pcs< PointType >::Set *quadrilaterals) const
Finds congruent candidates in the set Q, given the invariants and threshold distances. Returns true if a non empty set can be found, false otherwise.
Definition: FunctorSuper4pcs.h:124
Extract pairs of points by rasterizing primitives and collect points.
Definition: intersectionFunctor.h:74
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
Processing functor for the computation of the Super4PCS algorithm.
Definition: FunctorSuper4pcs.h:32
void ExtractPairs(Scalar pair_distance, Scalar pair_normals_angle, Scalar pair_distance_epsilon, int base_point1, int base_point2, PairsVector *pairs) const
Constructs pairs of points in Q, corresponding to a single pair in the in basein P.
Definition: FunctorSuper4pcs.h:75
void Initialize()
Initializes the data structures and needed values before the match computation.
Definition: FunctorSuper4pcs.h:59
void getNeighbors(const Point &p, const Point &n, Scalar alpha, std::vector< unsigned int > &nei, bool tryReverse=false)
Get closest poitns in euclidean an normal space with angular deviation.
Definition: normalset.hpp:177
FunctorSuper4PCS(std::vector< PointType > &sampled_Q_3D_, BaseCoordinates &base_3D_, const OptionType &options)
Definition: FunctorSuper4pcs.h:50