1 //:
2 // \file
3 // \author Charlene Tsai
4 // \date Sep 2003
5
6 #include "rgrl_matcher_fixed.h"
7 #include "rgrl_match_set.h"
8 #include "rgrl_transformation.h"
9 #include "rgrl_view.h"
10
11 rgrl_matcher_fixed::
rgrl_matcher_fixed(const rgrl_match_set_sptr & init_match_set_)12 rgrl_matcher_fixed( const rgrl_match_set_sptr& init_match_set_ ):
13 match_set_( init_match_set_ )
14 {
15 }
16
17 rgrl_matcher_fixed::
18 ~rgrl_matcher_fixed() = default;
19
20 rgrl_match_set_sptr
21 rgrl_matcher_fixed::
compute_matches(rgrl_feature_set const &,rgrl_feature_set const &,rgrl_view const & current_view,rgrl_transformation const & current_xform,rgrl_scale const &,rgrl_match_set_sptr const &)22 compute_matches( rgrl_feature_set const& /*from_features*/,
23 rgrl_feature_set const& /*to_features*/,
24 rgrl_view const& current_view,
25 rgrl_transformation const& current_xform,
26 rgrl_scale const& /* current_scale */,
27 rgrl_match_set_sptr const& /*old_matches*/ )
28 {
29 // Iterators to go over the matches
30 //
31 typedef rgrl_match_set::from_iterator FIter;
32 typedef FIter::to_iterator TIter;
33
34 // extract matches with from-features falling into the current_view
35 // from the pre-computed match_set
36
37 rgrl_match_set_sptr
38 sub_match_set = new rgrl_match_set(match_set_->from_feature_type(),
39 match_set_->to_feature_type(),
40 match_set_->from_label(),
41 match_set_->to_label());
42 for ( FIter fi = match_set_->from_begin(); fi != match_set_->from_end(); ++fi ) {
43 rgrl_feature_sptr from_feature = fi.from_feature();
44 if ( current_view.region().inside(from_feature->location()) ) {
45 std::vector<rgrl_feature_sptr> matching_to;
46 for ( TIter ti = fi.begin(); ti != fi.end(); ++ti ) {
47 matching_to.push_back( ti.to_feature());
48 }
49 sub_match_set->add_feature_and_matches( from_feature, nullptr, matching_to);
50 }
51 }
52 sub_match_set->remap_from_features( current_xform );
53
54 return sub_match_set;
55 }
56