contrib/rpl/rgrl/rgrl_match_set.cxx
Go to the documentation of this file.
00001 #include "rgrl_match_set.h"
00002 //:
00003 // \file
00004 // \brief  Represents a set of matches.
00005 // \author Amitha Perera
00006 // \date 14 Nov 2002
00007 // \verbatim
00008 // Modifications
00009 //      Nov 2008 J Becker: Change to use the new feature reader.
00010 // \endverbatim
00011 
00012 #include <rgrl/rgrl_feature_sptr.h>
00013 #include <rgrl/rgrl_transformation.h>
00014 
00015 #include <vcl_vector.h>
00016 #include <vcl_algorithm.h>
00017 #include <vcl_cassert.h>
00018 
00019 rgrl_match_set::
00020 rgrl_match_set(  )
00021   : from_type_( 0 ),
00022     to_type_( 0 ),
00023     num_constraints_per_match_( 0 )
00024 {
00025 }
00026 
00027 rgrl_match_set::
00028 rgrl_match_set( const vcl_type_info& feature_type )
00029   : from_type_( &feature_type ),
00030     to_type_( &feature_type ),
00031     num_constraints_per_match_( 0 )
00032 {
00033 }
00034 
00035 rgrl_match_set::
00036 rgrl_match_set( const vcl_type_info& from_type,
00037                 const vcl_type_info& to_type,
00038                 const rgrl_feature_set_label& from_label,
00039                 const rgrl_feature_set_label& to_label )
00040   : from_type_( &from_type ),
00041     to_type_( &to_type ),
00042     from_label_( from_label ),
00043     to_label_( to_label ),
00044     num_constraints_per_match_( 0 )
00045 {
00046 }
00047 
00048 
00049 rgrl_match_set::size_type
00050 rgrl_match_set::
00051 from_size() const
00052 {
00053   return from_features_.size();
00054 }
00055 
00056 
00057 rgrl_match_set::const_from_iterator
00058 rgrl_match_set::
00059 from_begin() const
00060 {
00061   return const_from_iterator( this, 0 );
00062 }
00063 
00064 
00065 rgrl_match_set::const_from_iterator
00066 rgrl_match_set::
00067 from_end() const
00068 {
00069   return const_from_iterator( this, from_features_.size() );
00070 }
00071 
00072 
00073 rgrl_match_set::from_iterator
00074 rgrl_match_set::
00075 from_begin()
00076 {
00077   return from_iterator( this, 0 );
00078 }
00079 
00080 
00081 rgrl_match_set::from_iterator
00082 rgrl_match_set::
00083 from_end()
00084 {
00085   return from_iterator( this, from_features_.size() );
00086 }
00087 
00088 
00089 void
00090 rgrl_match_set::
00091 clear()
00092 {
00093   from_features_.clear();
00094   xformed_from_features_.clear();
00095   matches_and_weights_.clear();
00096 }
00097 
00098 
00099 void
00100 rgrl_match_set ::
00101 add_feature_and_matches( rgrl_feature_sptr                      from_feature,
00102                          rgrl_feature_sptr                      mapped_feature,
00103                          vcl_vector< rgrl_feature_sptr > const& matching_to )
00104 {
00105   vcl_vector< rgrl_feature_sptr >::const_iterator to_itr;
00106 
00107   //  Check to make sure all features involve the same feature types
00108 
00109   assert ( from_feature->is_type( *(this->from_type_) ) );
00110   for ( to_itr = matching_to.begin(); to_itr != matching_to.end(); ++to_itr ) {
00111     assert ( (*to_itr)->is_type( *(this->to_type_ ) ) );
00112   }
00113 
00114   // Add from and xformed from
00115 
00116   from_features_.push_back( from_feature );
00117   xformed_from_features_.push_back( mapped_feature );
00118 
00119   // Add matches, with the initial sig weights computed by the from features.
00120 
00121   vcl_vector<match_info> blank;
00122   matches_and_weights_.push_back( blank );
00123   for ( to_itr = matching_to.begin(); to_itr != matching_to.end(); ++to_itr )
00124   {
00125     double sig_wgt = (*to_itr)->absolute_signature_weight( mapped_feature );
00126     matches_and_weights_.back().push_back( match_info( *to_itr, sig_wgt ));
00127   }
00128 }
00129 
00130 
00131 void
00132 rgrl_match_set ::
00133 add_feature_matches_and_weights( rgrl_feature_sptr                      from_feature,
00134                                  rgrl_feature_sptr                      mapped_feature,
00135                                  vcl_vector< rgrl_feature_sptr > const& matching_to,
00136                                  vcl_vector< double > const&            signature_weights )
00137 {
00138   vcl_vector< rgrl_feature_sptr >::const_iterator to_itr;
00139 
00140   //  Check to make sure all features involve the same feature types
00141 
00142   assert ( from_feature->is_type( *(this->from_type_ ) ) );
00143   for ( to_itr = matching_to.begin(); to_itr != matching_to.end(); ++to_itr ) {
00144     assert ( (*to_itr)->is_type( *(this->to_type_ ) ) );
00145   }
00146 
00147   // Make sure the
00148 
00149   assert ( matching_to.size() == signature_weights.size() );
00150 
00151   // Add from and xformed from
00152 
00153   from_features_.push_back( from_feature );
00154   xformed_from_features_.push_back( mapped_feature );
00155 
00156   // Add matches, with default initial weights.
00157 
00158   vcl_vector<match_info> blank;
00159   vcl_vector<double>::const_iterator s_itr;
00160   matches_and_weights_.push_back( blank );
00161   matches_and_weights_.back().reserve( matching_to.size() );
00162   for ( to_itr = matching_to.begin(), s_itr = signature_weights.begin();
00163         to_itr != matching_to.end(); ++to_itr,  ++s_itr )
00164   {
00165     matches_and_weights_.back().push_back( match_info( *to_itr, *s_itr ));
00166   }
00167 }
00168 
00169 void
00170 rgrl_match_set ::
00171 add_feature_matches_and_weights( rgrl_feature_sptr                      from_feature,
00172                                  rgrl_feature_sptr                      mapped_feature,
00173                                  vcl_vector< rgrl_feature_sptr > const& matching_to,
00174                                  vcl_vector< double > const&            sig_wgts,
00175                                  vcl_vector< double > const&            geo_wgts,
00176                                  vcl_vector< double > const&            cum_wgts )
00177 {
00178   vcl_vector< rgrl_feature_sptr >::const_iterator to_itr;
00179 
00180   //  Check to make sure all features involve the same feature types
00181 
00182   assert ( from_feature->is_type( *(this->from_type_ ) ) );
00183   for ( to_itr = matching_to.begin(); to_itr != matching_to.end(); ++to_itr ) {
00184     assert ( (*to_itr)->is_type( *(this->to_type_ ) ) );
00185   }
00186 
00187   // Make sure the
00188 
00189   assert ( matching_to.size() == sig_wgts.size() );
00190   assert ( matching_to.size() == geo_wgts.size() );
00191   assert ( matching_to.size() == cum_wgts.size() );
00192 
00193   // Add from and xformed from
00194 
00195   from_features_.push_back( from_feature );
00196   xformed_from_features_.push_back( mapped_feature );
00197 
00198   // Add matches, with default initial weights.
00199   //
00200   vcl_vector<match_info> blank;
00201   matches_and_weights_.push_back( blank );
00202   vcl_vector< vcl_vector< match_info > >::reverse_iterator back_it 
00203     = matches_and_weights_.rbegin();
00204 
00205   const unsigned size = matching_to.size();
00206   back_it->reserve( size);
00207   for( unsigned i=0; i<size; ++i ) {
00208     back_it->push_back( match_info( matching_to[i], geo_wgts[i], 
00209                                     sig_wgts[i], cum_wgts[i] ) );
00210   }
00211 }
00212 
00213 void
00214 rgrl_match_set ::
00215 add_feature_and_match( rgrl_feature_sptr from_feature,
00216                        rgrl_feature_sptr mapped_feature,
00217                        rgrl_feature_sptr matching_to,
00218                        double            wgt )
00219 {
00220   //  Check to make sure all features involve the same feature types
00221 
00222   assert ( from_feature->is_type( *(this->from_type_ ) ) );
00223   assert ( matching_to->is_type( *(this->to_type_ ) ) );
00224 
00225   // Add from and xformed from
00226 
00227   from_features_.push_back( from_feature );
00228   xformed_from_features_.push_back( mapped_feature );
00229 
00230   vcl_vector<match_info> match;
00231   match.push_back( match_info( matching_to, wgt, wgt, wgt ) );
00232   matches_and_weights_.push_back( match );
00233 }
00234 
00235 
00236 void
00237 rgrl_match_set::
00238 remap_from_features( rgrl_transformation const& trans )
00239 {
00240   assert ( from_features_.size() == xformed_from_features_.size() );
00241 
00242   vcl_vector<rgrl_feature_sptr>::size_type i = 0;
00243   for ( ; i < from_features_.size(); ++i ) {
00244     xformed_from_features_[i] = from_features_[i]->transform( trans );
00245   }
00246 }
00247 
00248 void
00249 rgrl_match_set::
00250 remap_only_location( rgrl_transformation const& trans )
00251 {
00252   assert ( from_features_.size() == xformed_from_features_.size() );
00253 
00254   vcl_vector<rgrl_feature_sptr>::size_type i = 0;
00255   vnl_vector<double> mapped_loc;
00256   for ( ; i < from_features_.size(); ++i ) {
00257     
00258     // remap only location
00259     trans.map_location( from_features_[i]->location(), mapped_loc );
00260     xformed_from_features_[i]->set_location( mapped_loc );
00261 
00262   }
00263 }
00264 
00265 
00266 unsigned int
00267 rgrl_match_set::
00268 num_constraints_per_match() const
00269 {
00270   if ( !num_constraints_per_match_ )
00271     set_num_constraints_per_match();
00272 
00273   return num_constraints_per_match_;
00274 }
00275 
00276 void
00277 rgrl_match_set::
00278 set_num_constraints_per_match() const
00279 {
00280   typedef rgrl_match_set::const_from_iterator FIter;
00281   typedef FIter::to_iterator TIter;
00282 
00283   bool has_to_features = false;
00284   for ( FIter fi = this->from_begin(); fi != this->from_end(); ++fi ) {
00285     for ( TIter ti = fi.begin(); ti != fi.end(); ++ti ) {
00286       num_constraints_per_match_ = ti.to_feature()->num_constraints();
00287       has_to_features = true;
00288       break;
00289     }
00290     if ( has_to_features ) break;
00291   }
00292 }
00293 
00294 // ---------------------------------------------------------------------------
00295 //                                                             stream operator
00296 //
00297 
00298 //: stream output
00299 void
00300 rgrl_match_set::
00301 write( vcl_ostream& os ) const
00302 {
00303   typedef rgrl_match_set::const_from_iterator FIter;
00304   typedef FIter::to_iterator TIter;
00305 
00306   // size
00307   os << this->from_size() << vcl_endl;
00308   
00309   for( FIter fi=this->from_begin(); fi!=this->from_end(); ++fi ) {
00310 
00311     // from feature
00312     fi.from_feature()->write( os );
00313     
00314     // mapped feature
00315     fi.mapped_from_feature()->write( os );
00316     
00317     // to size
00318     os << fi.size() << vcl_endl;
00319     
00320     for( TIter ti=fi.begin(); ti!=fi.end(); ++ti )  {
00321       os << ti.signature_weight() << ' ' 
00322          << ti.geometric_weight() << ' ' 
00323          << ti.cumulative_weight() << vcl_endl;
00324       
00325       // to feature
00326       ti.to_feature()->write( os );
00327     }
00328     os << vcl_endl;
00329   }
00330   
00331   os << "\n\n";
00332   //return os;
00333 } 
00334 
00335 //using anonymous namespace to restrict the use
00336 namespace{
00337   struct sort_node {
00338   
00339     unsigned ind_;
00340     rgrl_feature_sptr fea_;
00341   
00342     sort_node()
00343       : ind_(0) 
00344     { }
00345 
00346     sort_node( unsigned i, const rgrl_feature_sptr& f) 
00347       : ind_(i), fea_(f) 
00348     { }
00349   
00350     bool operator<( const sort_node& rhs ) const
00351     {
00352       const vnl_vector<double>&  loc = fea_->location(); 
00353       const vnl_vector<double>&  rhs_loc = rhs.fea_->location(); 
00354     
00355       if( loc[0] < rhs_loc[0] )
00356         return true;
00357       else if( loc[0] > rhs_loc[0] )
00358         return false;
00359       else
00360         return loc[1] < rhs_loc[1];
00361     }
00362   };
00363 }
00364 
00365 //: stream output
00366 void
00367 rgrl_match_set::
00368 write_sorted( vcl_ostream& os ) const
00369 {
00370   vcl_vector< sort_node > nodes;
00371   
00372   for( unsigned i=0; i<from_features_.size(); ++i ){
00373     nodes.push_back( sort_node( i, from_features_[i] ) );
00374   }
00375   vcl_sort( nodes.begin(), nodes.end() );
00376 
00377   os << from_features_.size() << vcl_endl;
00378     
00379   unsigned index;
00380   for( unsigned i=0; i<nodes.size(); ++i ){
00381     
00382     index = nodes[i].ind_;
00383     
00384     // output the index(th) match
00385     from_features_[index]->write( os );
00386     xformed_from_features_[index]->write( os );
00387     
00388     const vcl_vector<match_info>& this_match = matches_and_weights_[index];
00389     // to size
00390     os << this_match.size() << vcl_endl;
00391     
00392     typedef vcl_vector<match_info>::const_iterator MIter;
00393     for( MIter ti=this_match.begin(); ti!=this_match.end(); ++ti )  {
00394       os << ti->signature_weight << ' ' 
00395          << ti->geometric_weight << ' ' 
00396          << ti->cumulative_weight << vcl_endl;
00397       
00398       // to feature
00399       ti->to_feature->write( os );
00400     }
00401     os << vcl_endl;
00402   }
00403   
00404   os << "\n\n";
00405 }
00406     
00407 //: stream input
00408 bool
00409 rgrl_match_set::
00410 read( vcl_istream& is )
00411 {
00412   double sig, geo, cum;
00413   vcl_vector<double> sig_wgts, geo_wgts, cum_wgts;
00414   vcl_vector<rgrl_feature_sptr>  tos;
00415   rgrl_feature_sptr from, mapped, one;
00416   bool to_set_feature_type = true;
00417   
00418   // from size
00419   int from_size=-1;
00420   is >> from_size;
00421   if( !is || from_size<0 ) {
00422     vcl_cerr << "Error(" << __FILE__ <<"): cannot read from size" << vcl_endl;
00423     return false;
00424   }
00425   
00426   for( int i=0; i<from_size; ++i ) {
00427     
00428     // from feature
00429     from = rgrl_feature_reader::read( is );
00430       
00431     // mapped feature
00432     mapped = rgrl_feature_reader::read( is );
00433     if( !is || !from || !mapped ) {
00434       vcl_cerr << "Error(" << __FILE__ <<"): cannot read from feature" << vcl_endl;
00435       return false;
00436     }
00437 
00438     // to size
00439     int to_size=-1;
00440     is >> to_size;
00441     if( !is || to_size<0 ) {
00442       vcl_cerr << "Error(" << __FILE__ <<"): cannot read to feature size" << vcl_endl;
00443       return false;
00444     }
00445     
00446     // reset
00447     sig_wgts.clear();
00448     geo_wgts.clear();
00449     cum_wgts.clear();
00450     tos.clear();
00451     
00452     for( int i=0; i<to_size; ++i ) {
00453       is >> sig >> geo >> cum;
00454       if( !is ) {
00455         vcl_cerr << "Error(" << __FILE__ <<"): cannot read wgts" << vcl_endl;
00456         return false;
00457       }
00458       
00459       sig_wgts.push_back( sig );
00460       geo_wgts.push_back( geo );
00461       cum_wgts.push_back( cum );
00462       
00463       one = rgrl_feature_reader( is );
00464       if( !is || !one ) {
00465         vcl_cerr << "Error(" << __FILE__ <<"): cannot read to features" << vcl_endl;
00466         return false;
00467       }
00468       tos.push_back( one );
00469     }
00470     
00471     // set feature type
00472     if( to_set_feature_type && !tos.empty() ) {
00473       //set flag
00474       to_set_feature_type = false; 
00475       
00476       from_type_ = &(from->type_id());
00477       to_type_ = &(tos[0]->type_id());
00478     }
00479 
00480     // add features and weights
00481     this->add_feature_matches_and_weights( from, mapped, tos, sig_wgts, geo_wgts, cum_wgts );
00482 
00483   }
00484   
00485   // set num_constraints
00486   set_num_constraints_per_match();
00487   
00488   return true;
00489 }
00490 
00491 //: stream output
00492 vcl_ostream& 
00493 operator<< ( vcl_ostream& os, rgrl_match_set const& set )
00494 {
00495   set.write( os );
00496   return os;
00497 }
00498 
00499 //: stream input
00500 vcl_istream& 
00501 operator>> ( vcl_istream& is, rgrl_match_set& set )
00502 {
00503   bool ret = set.read( is );
00504   assert( ret );
00505   return is;
00506 }
00507 
00508 // ---------------------------------------------------------------------------
00509 //                                                                  match info
00510 //
00511 
00512 rgrl_match_set::match_info::
00513 match_info( rgrl_feature_sptr to_feat )
00514   : to_feature( to_feat ),
00515     geometric_weight( -1.0 ),
00516     signature_weight( 1.0 ),
00517     cumulative_weight( -1.0 )
00518 {
00519 }
00520 
00521 
00522 rgrl_match_set::match_info::
00523 match_info( rgrl_feature_sptr to_feat,
00524             double geometric_wgt,
00525             double signature_wgt,
00526             double cumulative_wgt )
00527   : to_feature( to_feat ),
00528     geometric_weight( geometric_wgt ),
00529     signature_weight( signature_wgt ),
00530     cumulative_weight( cumulative_wgt )
00531 {
00532 }
00533 
00534 
00535 rgrl_match_set::match_info::
00536 match_info( rgrl_feature_sptr to_feat,
00537             double signature_wgt )
00538   : to_feature( to_feat ),
00539     geometric_weight( -1.0 ),
00540     signature_weight( signature_wgt ),
00541     cumulative_weight( -1.0 )
00542 {
00543 }
00544 
00545 
00546 // ---------------------------------------------------------------------------
00547 //                                                               from iterator
00548 //
00549 
00550 rgrl_match_set_from_iterator::
00551 rgrl_match_set_from_iterator()
00552 {
00553 };
00554 
00555 
00556 rgrl_match_set_from_iterator&
00557 rgrl_match_set_from_iterator::
00558 operator++()
00559 {
00560   ++this->index_;
00561   return *this;
00562 }
00563 
00564 rgrl_match_set_from_iterator
00565 rgrl_match_set_from_iterator::
00566 operator+(int RHS)
00567 {
00568   this->index_ += RHS;
00569   return *this;
00570 }
00571 
00572 bool
00573 rgrl_match_set_from_iterator::
00574 operator==( const rgrl_match_set_from_iterator& other ) const
00575 {
00576   return this->index_ == other.index_;
00577 }
00578 
00579 
00580 bool
00581 rgrl_match_set_from_iterator::
00582 operator!=( const rgrl_match_set_from_iterator& other ) const
00583 {
00584   return this->index_ != other.index_;
00585 }
00586 
00587 
00588 rgrl_match_set_from_iterator::to_iterator
00589 rgrl_match_set_from_iterator::
00590 begin() const
00591 {
00592   return to_iterator( this->match_set_->matches_and_weights_[this->index_].begin() );
00593 }
00594 
00595 
00596 rgrl_match_set_from_iterator::to_iterator
00597 rgrl_match_set_from_iterator::
00598 end() const
00599 {
00600   return to_iterator( this->match_set_->matches_and_weights_[this->index_].end() );
00601 }
00602 
00603 
00604 rgrl_match_set_from_iterator::size_type
00605 rgrl_match_set_from_iterator::
00606 size() const
00607 {
00608   return this->match_set_->matches_and_weights_[this->index_].size();
00609 }
00610 
00611 
00612 bool
00613 rgrl_match_set_from_iterator::
00614 empty() const
00615 {
00616   return this->size() == 0;
00617 }
00618 
00619 
00620 rgrl_feature_sptr
00621 rgrl_match_set_from_iterator::
00622 from_feature() const
00623 {
00624   return this->match_set_->from_features_[this->index_];
00625 }
00626 
00627 
00628 rgrl_feature_sptr
00629 rgrl_match_set_from_iterator::
00630 mapped_from_feature() const
00631 {
00632   return this->match_set_->xformed_from_features_[this->index_];
00633 }
00634 
00635 
00636 rgrl_match_set_from_iterator::
00637 rgrl_match_set_from_iterator( rgrl_match_set* ms,
00638                               vcl_vector< rgrl_feature_sptr >::size_type ind )
00639   : match_set_( ms ),
00640     index_( ind )
00641 {
00642 }
00643 
00644 
00645 // ---------------------------------------------------------------------------
00646 //                                                            from to iterator
00647 //
00648 
00649 
00650 rgrl_match_set_from_to_iterator::
00651 rgrl_match_set_from_to_iterator()
00652 {
00653 };
00654 
00655 
00656 rgrl_match_set_from_to_iterator&
00657 rgrl_match_set_from_to_iterator::
00658 operator++()
00659 {
00660   ++itr_;
00661   return *this;
00662 }
00663 
00664 rgrl_match_set_from_to_iterator
00665 rgrl_match_set_from_to_iterator::
00666 operator+(int RHS)
00667 {
00668   itr_ += RHS;
00669   return *this;
00670 }
00671 
00672 
00673 bool
00674 rgrl_match_set_from_to_iterator::
00675 operator==( const rgrl_match_set_from_to_iterator& other ) const
00676 {
00677   return this->itr_ == other.itr_;
00678 }
00679 
00680 
00681 bool
00682 rgrl_match_set_from_to_iterator::
00683 operator!=( const rgrl_match_set_from_to_iterator& other ) const
00684 {
00685   return this->itr_ != other.itr_;
00686 }
00687 
00688 
00689 rgrl_feature_sptr
00690 rgrl_match_set_from_to_iterator::
00691 to_feature() const
00692 {
00693   return itr_->to_feature;
00694 }
00695 
00696 
00697 double
00698 rgrl_match_set_from_to_iterator::
00699 geometric_weight() const
00700 {
00701   return itr_->geometric_weight;
00702 }
00703 
00704 
00705 double
00706 rgrl_match_set_from_to_iterator::
00707 signature_weight() const
00708 {
00709   return itr_->signature_weight;
00710 }
00711 
00712 
00713 double
00714 rgrl_match_set_from_to_iterator::
00715 cumulative_weight( ) const
00716 {
00717   return itr_->cumulative_weight;
00718 }
00719 
00720 
00721 void
00722 rgrl_match_set_from_to_iterator::
00723 set_geometric_weight( double geom_wgt )
00724 {
00725   itr_->geometric_weight = geom_wgt;
00726 }
00727 
00728 
00729 void
00730 rgrl_match_set_from_to_iterator::
00731 set_signature_weight( double sig_wgt )
00732 {
00733   itr_->signature_weight = sig_wgt;
00734 }
00735 
00736 
00737 void
00738 rgrl_match_set_from_to_iterator::
00739 set_cumulative_weight( double cum_wgt )
00740 {
00741   itr_->cumulative_weight = cum_wgt;
00742 }
00743 
00744 
00745 rgrl_match_set_from_to_iterator::
00746 rgrl_match_set_from_to_iterator( MatchInfoIter const& itr )
00747   : itr_( itr )
00748 {
00749 }
00750 
00751 
00752 // ---------------------------------------------------------------------------
00753 //                                                         const from iterator
00754 //
00755 
00756 rgrl_match_set_const_from_iterator::
00757 rgrl_match_set_const_from_iterator()
00758 {
00759 };
00760 
00761 rgrl_match_set_const_from_iterator::
00762 rgrl_match_set_const_from_iterator( rgrl_match_set_from_iterator const& from_iter )
00763   : match_set_( from_iter.match_set_ ),
00764     index_( from_iter.index_ )
00765 {
00766   
00767 }
00768 
00769 rgrl_match_set_const_from_iterator&
00770 rgrl_match_set_const_from_iterator::
00771 operator++()
00772 {
00773   ++this->index_;
00774   return *this;
00775 }
00776 
00777 rgrl_match_set_const_from_iterator
00778 rgrl_match_set_const_from_iterator::
00779 operator+(int RHS)
00780 {
00781   this->index_ += RHS;
00782   return *this;
00783 }
00784 
00785 bool
00786 rgrl_match_set_const_from_iterator::
00787 operator==( const rgrl_match_set_const_from_iterator& other ) const
00788 {
00789   return this->index_ == other.index_;
00790 }
00791 
00792 
00793 bool
00794 rgrl_match_set_const_from_iterator::
00795 operator!=( const rgrl_match_set_const_from_iterator& other ) const
00796 {
00797   return this->index_ != other.index_;
00798 }
00799 
00800 
00801 rgrl_match_set_const_from_iterator::to_iterator
00802 rgrl_match_set_const_from_iterator::
00803 begin() const
00804 {
00805   return to_iterator( this->match_set_->matches_and_weights_[this->index_].begin() );
00806 }
00807 
00808 
00809 rgrl_match_set_const_from_iterator::to_iterator
00810 rgrl_match_set_const_from_iterator::
00811 end() const
00812 {
00813   return to_iterator( this->match_set_->matches_and_weights_[this->index_].end() );
00814 }
00815 
00816 
00817 rgrl_match_set_const_from_iterator::size_type
00818 rgrl_match_set_const_from_iterator::
00819 size() const
00820 {
00821   return this->match_set_->matches_and_weights_[this->index_].size();
00822 }
00823 
00824 
00825 bool
00826 rgrl_match_set_const_from_iterator::
00827 empty() const
00828 {
00829   return this->size() == 0;
00830 }
00831 
00832 
00833 rgrl_feature_sptr const&
00834 rgrl_match_set_const_from_iterator::
00835 from_feature() const
00836 {
00837   return this->match_set_->from_features_[this->index_];
00838 }
00839 
00840 
00841 rgrl_feature_sptr const&
00842 rgrl_match_set_const_from_iterator::
00843 mapped_from_feature() const
00844 {
00845   return this->match_set_->xformed_from_features_[this->index_];
00846 }
00847 
00848 
00849 rgrl_match_set_const_from_iterator::
00850 rgrl_match_set_const_from_iterator( rgrl_match_set const* ms,
00851                                     vcl_vector< rgrl_feature_sptr >::size_type ind )
00852   : match_set_( ms ),
00853     index_( ind )
00854 {
00855 }
00856 
00857 
00858 // ---------------------------------------------------------------------------
00859 //                                                      const from to iterator
00860 //
00861 
00862 rgrl_match_set_const_from_to_iterator::
00863 rgrl_match_set_const_from_to_iterator()
00864 {
00865 };
00866 
00867 //: copy constructor
00868 //  it is used to convert from_to_iterator to const type
00869 rgrl_match_set_const_from_to_iterator::
00870 rgrl_match_set_const_from_to_iterator( rgrl_match_set_from_to_iterator const& to_iter )
00871   : itr_( to_iter.itr_ )
00872 {
00873 }
00874 rgrl_match_set_const_from_to_iterator&
00875 rgrl_match_set_const_from_to_iterator::
00876 operator++()
00877 {
00878   ++itr_;
00879   return *this;
00880 }
00881 
00882 rgrl_match_set_const_from_to_iterator
00883 rgrl_match_set_const_from_to_iterator::
00884 operator+(int RHS)
00885 {
00886   itr_ += RHS;
00887   return *this;
00888 }
00889 
00890 bool
00891 rgrl_match_set_const_from_to_iterator::
00892 operator==( const self_type& other ) const
00893 {
00894   return this->itr_ == other.itr_;
00895 }
00896 
00897 
00898 bool
00899 rgrl_match_set_const_from_to_iterator::
00900 operator!=( const self_type& other ) const
00901 {
00902   return this->itr_ != other.itr_;
00903 }
00904 
00905 
00906 rgrl_feature_sptr const&
00907 rgrl_match_set_const_from_to_iterator::
00908 to_feature() const
00909 {
00910   return itr_->to_feature;
00911 }
00912 
00913 
00914 double
00915 rgrl_match_set_const_from_to_iterator::
00916 geometric_weight() const
00917 {
00918   return itr_->geometric_weight;
00919 }
00920 
00921 
00922 double
00923 rgrl_match_set_const_from_to_iterator::
00924 signature_weight() const
00925 {
00926   return itr_->signature_weight;
00927 }
00928 
00929 
00930 double
00931 rgrl_match_set_const_from_to_iterator::
00932 cumulative_weight( ) const
00933 {
00934   return itr_->cumulative_weight;
00935 }
00936 
00937 
00938 rgrl_match_set_const_from_to_iterator::
00939 rgrl_match_set_const_from_to_iterator( MatchInfoIter const& itr )
00940   : itr_( itr )
00941 {
00942 }