contrib/rpl/rgrl/rgrl_feature_set.h
Go to the documentation of this file.
00001 #ifndef rgrl_feature_set_h_
00002 #define rgrl_feature_set_h_
00003 //:
00004 // \file
00005 // \brief Base class to represent and provide access in several ways to a set of registration features.
00006 // \author Chuck Stewart
00007 // \date 12 Nov 2002
00008 //
00009 // \verbatim
00010 //  Modifications
00011 //   Chuck Stewart - 8 Nov 2005 - added versions of nearest_feature and k_nearest_feature 
00012 //      based on point location alone 
00013 // \endverbatim
00014 
00015 #include <vcl_vector.h>
00016 #include <vcl_string.h>
00017 
00018 #include "rgrl_feature.h"
00019 #include "rgrl_object.h"
00020 
00021 class rgrl_feature_set_label;
00022 class rgrl_mask_box;
00023 
00024 #include "rgrl_feature_set_sptr.h"
00025 
00026 //: User-friendly label for the feature sets.
00027 //
00028 // The labels are used to refer to the feature sets in the context of
00029 // an rgrl_data_set.
00030 //
00031 // \sa rgrl_data_set
00032 //
00033 class rgrl_feature_set_label
00034 {
00035  public:
00036   //:
00037   rgrl_feature_set_label( const vcl_string& name = vcl_string() );
00038 
00039   //: return name
00040   vcl_string const& name() const
00041   { return name_; }
00042   
00043   //:
00044   bool operator==( rgrl_feature_set_label const& other ) const;
00045 
00046   //:
00047   bool operator!=( rgrl_feature_set_label const& other ) const;
00048 
00049   //:
00050   bool operator<( rgrl_feature_set_label const& other ) const;
00051 
00052  private:
00053   vcl_string name_;
00054 };
00055 
00056 //: Base class to represent and provide access in several ways to a set of registration features.
00057 //
00058 //  Each feature set represents features of one type and at one resolution.
00059 //
00060 class rgrl_feature_set
00061   : public rgrl_object
00062 {
00063  public:
00064   typedef vcl_vector<rgrl_feature_sptr>  feature_vector;
00065 
00066  public:
00067   rgrl_feature_set( feature_vector const& fea_vec, rgrl_feature_set_label const& label = rgrl_feature_set_label() );
00068 
00069   virtual ~rgrl_feature_set();
00070 
00071   //: set label
00072   void set_label( rgrl_feature_set_label const& label )
00073   { label_ = label; }
00074   
00075   //: get label
00076   rgrl_feature_set_label const& label() const
00077   { return label_; }
00078   
00079   //:  Return all the features
00080   //
00081   virtual
00082   feature_vector const&
00083   all_features( ) const
00084   { return fea_vec_; }
00085 
00086   //:  Return the features in a given ROI.
00087   //
00088   virtual
00089   void
00090   features_in_region( feature_vector& results, rgrl_mask_box const& roi ) const = 0;
00091 
00092   //:  Return the features in a given circle/sphere.
00093   //
00094   virtual
00095   void
00096   features_within_radius( feature_vector& results, vnl_vector<double> const& center, double radius ) const = 0;
00097 
00098   //: Return the nearest feature to the given location.
00099   //
00100   // This may be constructed from an underlying continuous
00101   // representation.
00102   //
00103   virtual
00104   rgrl_feature_sptr
00105   nearest_feature( const vnl_vector<double>& loc ) const = 0;
00106 
00107   //: Return the nearest feature to the given location.
00108   virtual
00109   rgrl_feature_sptr
00110   nearest_feature( rgrl_feature_sptr const& feature ) const = 0;
00111 
00112   //:  Return all features within a given distance of the given feature, one per segment (if segmented)
00113   //
00114   virtual
00115   void
00116   features_within_radius( feature_vector& results, rgrl_feature_sptr const& feature, double distance ) const = 0;
00117 
00118   //:  Return the k nearest features to the given location, one per segment (if segmented)
00119   //
00120   virtual
00121   void
00122   k_nearest_features( feature_vector& results, const vnl_vector<double>& feature_loc, unsigned int k ) const = 0;
00123 
00124   //:  Return the k nearest features, one per segment (if segmented)
00125   //
00126   virtual
00127   void
00128   k_nearest_features( feature_vector& results, rgrl_feature_sptr const& feature, unsigned int k ) const = 0;
00129 
00130   //:  Return the bounding box encloses the feature set
00131   virtual
00132   rgrl_mask_box
00133   bounding_box() const = 0;
00134   //:  Return the type of feature
00135   //
00136   virtual
00137   const vcl_type_info&
00138   type() const = 0;
00139 
00140   // Defines type-related functions
00141   rgrl_type_macro( rgrl_feature_set, rgrl_object );
00142 
00143  private:
00144   //disabled
00145   rgrl_feature_set( rgrl_feature_set const& other );
00146   rgrl_feature_set& operator=( rgrl_feature_set const& other );
00147 
00148  protected:
00149   rgrl_feature_set_label label_;
00150   feature_vector         fea_vec_;
00151 };
00152 
00153 
00154 
00155 #endif