contrib/oxl/mvl/ClosestImagePointFinder.h
Go to the documentation of this file.
00001 // This is oxl/mvl/ClosestImagePointFinder.h
00002 #ifndef ClosestImagePointFinder_h_
00003 #define ClosestImagePointFinder_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief HomgInterestPointSet closest points
00010 //
00011 //    ClosestImagePointFinder allows fast access to closest-point
00012 //    operations on a HomgInterestPointSet.
00013 //
00014 // \author  Andrew W. Fitzgibbon, Oxford RRG, 21 Jan 97
00015 //
00016 // \verbatim
00017 //  Modifications
00018 //   22 Jun 2003 - Peter Vanroose - added vgl_homg_point_2d interface
00019 // \endverbatim
00020 //-----------------------------------------------------------------------------
00021 
00022 #include <vcl_vector.h>
00023 #include <vnl/vnl_vector.h>
00024 #include <vgl/vgl_fwd.h>
00025 
00026 class HomgInterestPointSet;
00027 class vcl_multimap_double_int;
00028 class HomgPoint2D;
00029 
00030 class ClosestImagePointFinder
00031 {
00032  public:
00033   // Constructors/Destructors--------------------------------------------------
00034 
00035   ClosestImagePointFinder(const HomgInterestPointSet& corners);
00036   ClosestImagePointFinder(vcl_vector<vgl_homg_point_2d<double> > const& corners);
00037   ClosestImagePointFinder(const vcl_vector<HomgPoint2D>& corners);
00038   ~ClosestImagePointFinder();
00039 
00040   // ClosestImagePointFinder(const ClosestImagePointFinder& that); - use default
00041   // ClosestImagePointFinder& operator=(const ClosestImagePointFinder& that); - use default
00042 
00043   // Operations----------------------------------------------------------------
00044   void get_all_within_search_region(double cx, double cy, double w, double h, vcl_vector<int>* out_indices);
00045   void get_all_within_search_region(vgl_box_2d<double> const& region, vcl_vector<int>* out_indices);
00046 
00047   int get_closest_within_region(double cx, double cy, double w, double h, int* out_index = 0);
00048   int get_closest_within_distance(double cx, double cy, double r, int* out_index = 0);
00049 
00050   // Data Access---------------------------------------------------------------
00051   double get_last_squared_distance() const { return last_d2_; }
00052   int get_last_num_candidates() const { return last_inrange_; }
00053   int get_last_match_index() const { return last_index_; }
00054   double get_last_x() const { return px_[last_index_]; }
00055   double get_last_y() const { return py_[last_index_]; }
00056 
00057  protected:
00058   // Data Members--------------------------------------------------------------
00059 
00060   int get_closest_within_region(double cx, double cy, double w, double h, int* out_index, double mindist_sq);
00061 
00062   vnl_vector<double> px_;
00063   vnl_vector<double> py_;
00064   vcl_multimap_double_int* y2i_;
00065   double last_d2_;
00066   int last_inrange_;
00067   int last_index_;
00068 };
00069 
00070 #endif // ClosestImagePointFinder_h_