contrib/brl/bbas/bdgl/bdgl_curve_algs.h
Go to the documentation of this file.
00001 #ifndef bdgl_curve_algs_h_
00002 #define bdgl_curve_algs_h_
00003 //-----------------------------------------------------------------------------
00004 //:
00005 // \file
00006 // \author J.L. Mundy
00007 // \brief vdgl_digital_curve algorithms
00008 //
00009 // \verbatim
00010 //  Modifications
00011 //   Initial version November 25, 2002
00012 // \endverbatim
00013 //
00014 //-----------------------------------------------------------------------------
00015 #include "dll.h"
00016 #include <vgl/vgl_line_2d.h>
00017 #include <vgl/vgl_point_2d.h>
00018 #include <vdgl/vdgl_edgel_chain_sptr.h>
00019 #include <vdgl/vdgl_digital_curve_sptr.h>
00020 
00021 class bdgl_curve_algs
00022 {
00023  public:
00024   static BDGL_DLL_DATA const double tol;
00025   static BDGL_DLL_DATA const double max_edgel_sep;
00026   static BDGL_DLL_DATA const double synthetic;
00027   ~bdgl_curve_algs();
00028 
00029   //:Finds the index on a digital curve closest to the given point
00030   static int closest_point(vdgl_edgel_chain_sptr const& ec,
00031                            const double x, const double y);
00032 
00033   //:Finds the index on a digital curve closest to the given point
00034   static double closest_point(vdgl_digital_curve_sptr const& dc,
00035                               const double x, const double y);
00036 
00037   //:Finds the x-y coordinates on a digital curve closest to the given point
00038   static bool closest_point(vdgl_digital_curve_sptr const& dc,
00039                             const double x, const double y,
00040                             double& xc, double& yc);
00041 
00042   //:Finds location on a digital curve closest to the given point at index
00043   static  bool closest_point_near(vdgl_edgel_chain_sptr const& ec,
00044                                   const int index,
00045                                   const double x, const double y,
00046                                   double & xc, double & yc);
00047 
00048   //: Finds the end of the edgel chain closest to the given point
00049   static int closest_end(vdgl_edgel_chain_sptr const & ec,
00050                          const double x, const double y);
00051 
00052   //:Reverses the edgel chain
00053   static vdgl_digital_curve_sptr reverse(vdgl_digital_curve_sptr const& dc);
00054 
00055   //:Intersect the bounding box of the digital curve with the line as a test
00056   static bool intersect_bounding_box(vdgl_digital_curve_sptr const& dc,
00057                                      vgl_line_2d<double> & line);
00058 
00059   //:Intersect the curve with an infinite line, return the index values
00060   // This is a recursive implementation for faster computation
00061   static bool intersect_line_fast(vdgl_digital_curve_sptr const& dc,
00062                                   vgl_line_2d<double> & line,
00063                                   vcl_vector<double>& indices);
00064 
00065   //:Intersect the curve with an infinite line, return the points
00066   // This is a recursive implementation for faster computation
00067   static bool intersect_line_fast(vdgl_digital_curve_sptr const& dc,
00068                                   vgl_line_2d<double> & line,
00069                                   vcl_vector<vgl_point_2d<double> >& pts);
00070 
00071   //:Intersect the curve with an infinite line, return the index values
00072   static bool intersect_line(vdgl_digital_curve_sptr const& dc,
00073                              vgl_line_2d<double> & line,
00074                              vcl_vector<double>& indices);
00075 
00076   //:Intersect the curve with an infinite line, return the points
00077   static bool intersect_line(vdgl_digital_curve_sptr const& dc,
00078                              vgl_line_2d<double> & line,
00079                              vcl_vector<vgl_point_2d<double> >& pts);
00080 
00081   //:Intersect a curve with a line and match the reference edgel point
00082   static bool match_intersection(vdgl_digital_curve_sptr const& dc,
00083                                  vgl_line_2d<double>& line,
00084                                  vgl_point_2d<double> const& ref_point,
00085                                  double ref_gradient_angle,
00086                                  vgl_point_2d<double>& point);
00087 
00088   //:Generate points along a digital straight line
00089   static  bool line_gen(float xs, float ys, float xe, float ye,
00090                         bool& init, bool& done,
00091                         float& x, float& y);
00092 
00093   //:Add edgels to an edgel chain along a digital straight line
00094   static int add_straight_edgels(vdgl_edgel_chain_sptr const& ec,
00095                                  const double x, const double y,
00096                                  bool debug = false);
00097 
00098   static void
00099     smooth_curve(vcl_vector<vgl_point_2d<double> >& curve,double sigma=1.0);
00100 
00101   static vdgl_digital_curve_sptr
00102     create_digital_curves(vcl_vector<vgl_point_2d<double> > & curve);
00103 
00104  private:
00105   bdgl_curve_algs();
00106 };
00107 
00108 #endif