contrib/rpl/rgrl/rgrl_matcher_fixed.cxx
Go to the documentation of this file.
00001 //:
00002 // \file
00003 // \author Charlene Tsai
00004 // \date   Sep 2003
00005 
00006 #include "rgrl_matcher_fixed.h"
00007 #include "rgrl_match_set.h"
00008 #include "rgrl_transformation.h"
00009 #include "rgrl_view.h"
00010 
00011 rgrl_matcher_fixed::
00012 rgrl_matcher_fixed( rgrl_match_set_sptr  init_match_set_ ):
00013   match_set_( init_match_set_ )
00014 {
00015 }
00016 
00017 rgrl_matcher_fixed::
00018 ~rgrl_matcher_fixed()
00019 {
00020 }
00021 
00022 rgrl_match_set_sptr
00023 rgrl_matcher_fixed::
00024 compute_matches( rgrl_feature_set const&       /*from_features*/,
00025                  rgrl_feature_set const&       /*to_features*/,
00026                  rgrl_view const&              current_view,
00027                  rgrl_transformation const&    current_xform,
00028                  rgrl_scale const&             /* current_scale */,
00029                  rgrl_match_set_sptr const&    /*old_matches*/ )
00030 {
00031   // Iterators to go over the matches
00032   //
00033   typedef rgrl_match_set::from_iterator FIter;
00034   typedef FIter::to_iterator TIter;
00035 
00036   // extract matches with from-features falling into the current_view
00037   // from the pre-computed match_set
00038 
00039   rgrl_match_set_sptr
00040     sub_match_set = new rgrl_match_set(match_set_->from_feature_type(), 
00041                                        match_set_->to_feature_type(),
00042                                        match_set_->from_label(),
00043                                        match_set_->to_label());
00044   for ( FIter fi = match_set_->from_begin(); fi != match_set_->from_end(); ++fi ) {
00045     rgrl_feature_sptr from_feature = fi.from_feature();
00046     if ( current_view.region().inside(from_feature->location()) ) {
00047       vcl_vector<rgrl_feature_sptr> matching_to;
00048       for ( TIter ti = fi.begin(); ti != fi.end(); ++ti ) {
00049         matching_to.push_back( ti.to_feature());
00050       }
00051       sub_match_set->add_feature_and_matches( from_feature, 0, matching_to);
00052     }
00053   }
00054   sub_match_set->remap_from_features( current_xform );
00055 
00056   return sub_match_set;
00057 }