00001 // This is core/vgl/vgl_ellipse_scan_iterator.h 00002 #ifndef vgl_ellipse_scan_iterator_h_ 00003 #define vgl_ellipse_scan_iterator_h_ 00004 //: 00005 // \file 00006 // \author Amitha Perera 00007 // \date 31 August 2001 00008 // \verbatim 00009 // Modifications 00010 // Nov.2003 - Peter Vanroose - made class vgl_ellipse_scan_iterator templated 00011 // \endverbatim 00012 00013 #include <vgl/vgl_region_scan_iterator.h> 00014 00015 //: Scan convert an ellipse 00016 // The ellipse is parameterised by (\a xc, \a yc) (the centre), by \a 00017 // a and \a b (the radii along the principle axes) and by \a theta, 00018 // the rotation of the main axis (in radians) about the centre of the 00019 // ellipse w.r.t\. the horizontal direction (X-axis). 00020 // 00021 // Scan lines are horizontal lines intersecting the ellipse interior. 00022 // For a convex region like an ellipse, such a scan line is fully determined 00023 // by the two end points (startx(),scany()) and (endx(),scany()). 00024 // 00025 template <class T> 00026 class vgl_ellipse_scan_iterator : public vgl_region_scan_iterator 00027 { 00028 public: 00029 //: Constructor 00030 // The ellipse is parameterised by (\a xc, \a yc) (the centre), by \a 00031 // rx and \a ry (the radii along the principle axes) and by \a theta, 00032 // the rotation of the main axis (in radians) about the centre of the 00033 // ellipse w.r.t\. the horizontal direction (X-axis). 00034 vgl_ellipse_scan_iterator( T xc, T yc, T rx, T ry, T theta ); 00035 00036 //: Destructor 00037 virtual ~vgl_ellipse_scan_iterator(); 00038 00039 //: Resets the scan iterator to before the first scan line 00040 // After calling this function, next() needs to be called before 00041 // startx() and endx() form a valid scan line. 00042 virtual void reset(); 00043 00044 //: Tries to moves to the next scan line. 00045 // Returns false if there are no more scan lines. 00046 virtual bool next(); 00047 00048 //: y-coordinate of the current scan line. 00049 virtual int scany() const { return y_; } 00050 00051 //: Returns starting x-value of the current scan line. 00052 virtual int startx() const { return start_x_; } 00053 00054 //: Returns ending x-value of the current scan line. 00055 virtual int endx() const { return end_x_; } 00056 00057 private: 00058 //: Parameters of the ellipse being scan converted. 00059 // Centre, squared radii, and angle of rotation about the centre. 00060 T xc_, yc_, rx_, ry_, theta_; 00061 00062 //: Current scan line 00063 int y_; 00064 00065 //: Final scan line 00066 int min_y_; 00067 00068 //: Start of current scan line 00069 int start_x_; 00070 00071 //: End of current scan line 00072 int end_x_; 00073 }; 00074 00075 #define VGL_ELLIPSE_SCAN_ITERATOR_INSTANTIATE(T) extern "please include <vgl/vgl_ellipse_scan_iterator.txx> instead" 00076 00077 #endif // vgl_ellipse_scan_iterator_h_