Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vifa_imp_line.h

Go to the documentation of this file.
00001 // This is gel/vifa/vifa_imp_line.h
00002 #ifndef _VIFA_IMP_LINE_H_
00003 #define _VIFA_IMP_LINE_H_
00004 //-----------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \brief Implicit line segment.
00008 //
00009 // The vifa_imp_line class provides an implicit line segment for computing
00010 // attributes for the edges of intensity faces.  A subclass of the core class
00011 // vgl_line_segment_2d, additional API's for axis projection and parametric
00012 // evaluation are provided.
00013 //
00014 // \author Mike Petersen, June 2003
00015 //
00016 //-----------------------------------------------------------------------------
00017 
00018 #include <vbl/vbl_ref_count.h>
00019 #include <vgl/vgl_vector_2d.h>
00020 #include <vgl/vgl_line_segment_2d.h>
00021 
00022 template <class Type>
00023 class vifa_imp_line : public vbl_ref_count, public vgl_line_segment_2d<Type>
00024 {
00025  protected:
00026   //: X-axis span of line segment
00027   double dx_;
00028 
00029   //: Y-axis span of line segment
00030   double dy_;
00031 
00032  public:
00033   //: Default constructor - does not initialize
00034   inline vifa_imp_line(void) {}
00035 
00036   // copy constructor - compiler-provided one sets ref_count to nonzero which is wrong -PVr
00037   vifa_imp_line(vifa_imp_line const& l)
00038     : vbl_ref_count(), vgl_line_segment_2d<Type>(l), dx_(l.dx_), dy_(l.dy_) {}
00039 
00040   //: Line segment constructor
00041   vifa_imp_line(vgl_point_2d<Type> const& p1,
00042                 vgl_point_2d<Type> const& p2);
00043 
00044   //: Direction/midpoint constructor
00045   vifa_imp_line(vgl_vector_2d<Type> d,
00046                 vgl_point_2d<Type>  m);
00047 
00048   //: Implicit coefficient constructor
00049   vifa_imp_line(Type a, Type b, Type c);
00050 
00051   //: Test if a value is near 0.0
00052   inline bool near_zero(double x) const { return x < 1e-6; }
00053 
00054   //: Compute unit projection along X-axis
00055   double get_dir_x(void);
00056 
00057   //: Compute unit projection along Y-axis
00058   double get_dir_y(void);
00059 
00060   //: Compute length of line segment
00061   double length(void);
00062 
00063   //: Assignment
00064   void set_points(vgl_point_2d<Type> const& p1,
00065                   vgl_point_2d<Type> const& p2);
00066 
00067   //: Project a 2D point onto the line
00068   void project_2d_pt(const Type& p,
00069                      const Type& q,
00070                      Type&       x,
00071                      Type&       y) const;
00072 
00073   vgl_point_2d<Type> project_2d_pt(const vgl_point_2d<Type>& t) const;
00074 
00075   //: Find parametric t-value for a given point relative to line segment.
00076   double find_t(const vgl_point_2d<Type>& p);
00077 
00078   //: Find point on line (defined by line segment) for a parametric t-value.
00079   vgl_point_2d<Type> find_at_t(double t);
00080 };
00081 
00082 #endif // _VIFA_IMP_LINE_H_

Generated on Thu Jan 10 14:47:30 2008 for contrib/gel/vifa by  doxygen 1.4.4