1 // This is gel/vdgl/vdgl_interpolator.h
2 #ifndef vdgl_interpolator_h_
3 #define vdgl_interpolator_h_
4 //:
5 // \file
6 // \brief Represents a 2D interpolator for a vdgl_edgel_chain
7 // \author Geoff Cross
8 //
9 // introduced new method get_tangent_angle, which is based on the actual
10 // curve geometry.  The old method get_theta strictly refers to the
11 // stored gradient directions and shouldn't be used for geometric operations.
12 // In this regard, curvature is not a valid computation of geometric curvature
13 // and should be changed.  Currently it is the rate of change of gradient direction
14 //
15 // \verbatim
16 //  Modifications
17 //   01-dec-2003 J.L. Mundy
18 //   10-sep-2004 Peter Vanroose Added copy ctor with explicit vbl_ref_count init
19 // \endverbatim
20 
21 #include <vdgl/vdgl_interpolator_sptr.h>
22 #include <vul/vul_timestamp.h>
23 #include <vbl/vbl_ref_count.h>
24 #include <vdgl/vdgl_edgel_chain_sptr.h>
25 #include <vsol/vsol_point_2d_sptr.h>
26 
27 class vdgl_interpolator : public vul_timestamp,
28                           public vbl_ref_count
29 {
30    // PUBLIC INTERFACE----------------------------------------------------------
31  public:
32 
33   // Constructors/Destructors--------------------------------------------------
34 
vdgl_interpolator(vdgl_edgel_chain_sptr chain)35   vdgl_interpolator(vdgl_edgel_chain_sptr chain) : chain_(chain) {}
36 
vdgl_interpolator(vdgl_interpolator const & x)37   vdgl_interpolator(vdgl_interpolator const& x)
38     : vul_timestamp(), vbl_ref_count(), chain_(x.chain_) {}
39 
40   // Operators----------------------------------------------------------------
41 
42   //: order of interpolation 1=linear, 2 = quadratic, 3 = cubic, ..etc.
43   virtual short order() const = 0;
44   //: interpolation 0th degree
45   virtual double get_x(double index)= 0;
46   virtual double get_y(double index)= 0;
47 
48   //: interpolation 1st degree
49   virtual double get_grad(double index) = 0;
50   virtual double get_theta(double index)= 0;
51   virtual double get_tangent_angle(double index)= 0;
52 
53   //: interpolation 2nd degree
54   virtual double get_curvature(double index)= 0;
55 
56   //: integral
57   virtual double get_length()= 0;
58 
59   //: bounding box
60   virtual double get_min_x()= 0;
61   virtual double get_max_x()= 0;
62   virtual double get_min_y()= 0;
63   virtual double get_max_y()= 0;
64 
65   //: find closest point on the curve to the input point
66   virtual vsol_point_2d_sptr closest_point_on_curve ( vsol_point_2d_sptr p ) = 0;
67   virtual double distance_curve_to_point ( vsol_point_2d_sptr p );
68 
69   // Data Access---------------------------------------------------------------
70 
get_edgel_chain()71   vdgl_edgel_chain_sptr get_edgel_chain() const { return chain_; }
72 
73   // INTERNALS-----------------------------------------------------------------
74  protected:
75   // Data Members--------------------------------------------------------------
76 
77   vdgl_edgel_chain_sptr chain_;
78 };
79 
80 #endif // vdgl_interpolator_h_
81