vgl_ellipse_scan_iterator.h
Go to the documentation of this file.
1 // This is core/vgl/vgl_ellipse_scan_iterator.h
2 #ifndef vgl_ellipse_scan_iterator_h_
3 #define vgl_ellipse_scan_iterator_h_
4 //:
5 // \file
6 // \author Amitha Perera
7 // \date 31 August 2001
8 // \verbatim
9 // Modifications
10 // Nov.2003 - Peter Vanroose - made class vgl_ellipse_scan_iterator templated
11 // \endverbatim
12 
14 
15 //: Scan convert an ellipse
16 // The ellipse is parameterised by (\a xc, \a yc) (the centre), by \a
17 // a and \a b (the radii along the principle axes) and by \a theta,
18 // the rotation of the main axis (in radians) about the centre of the
19 // ellipse w.r.t\. the horizontal direction (X-axis).
20 //
21 // Scan lines are horizontal lines intersecting the ellipse interior.
22 // For a convex region like an ellipse, such a scan line is fully determined
23 // by the two end points (startx(),scany()) and (endx(),scany()).
24 //
25 template <class T>
27 {
28  public:
29  //: Constructor
30  // The ellipse is parameterised by (\a xc, \a yc) (the centre), by \a
31  // rx and \a ry (the radii along the principle axes) and by \a theta,
32  // the rotation of the main axis (in radians) about the centre of the
33  // ellipse w.r.t\. the horizontal direction (X-axis).
34  vgl_ellipse_scan_iterator( T xc, T yc, T rx, T ry, T theta );
35 
36  //: Destructor
37  ~vgl_ellipse_scan_iterator() override;
38 
39  //: Resets the scan iterator to before the first scan line
40  // After calling this function, next() needs to be called before
41  // startx() and endx() form a valid scan line.
42  void reset() override;
43 
44  //: Tries to moves to the next scan line.
45  // Returns false if there are no more scan lines.
46  bool next() override;
47 
48  //: y-coordinate of the current scan line.
49  int scany() const override { return y_; }
50 
51  //: Returns starting x-value of the current scan line.
52  int startx() const override { return start_x_; }
53 
54  //: Returns ending x-value of the current scan line.
55  int endx() const override { return end_x_; }
56 
57  private:
58  //: Parameters of the ellipse being scan converted.
59  // Centre, squared radii, and angle of rotation about the centre.
60  T xc_, yc_, rx_, ry_, theta_;
61 
62  //: Current scan line
63  int y_;
64 
65  //: Final scan line
66  int min_y_;
67 
68  //: Start of current scan line
69  int start_x_;
70 
71  //: End of current scan line
72  int end_x_;
73 };
74 
75 #define VGL_ELLIPSE_SCAN_ITERATOR_INSTANTIATE(T) extern "please include <vgl/vgl_ellipse_scan_iterator.hxx> instead"
76 
77 #endif // vgl_ellipse_scan_iterator_h_
vgl_ellipse_scan_iterator(T xc, T yc, T rx, T ry, T theta)
Constructor.
int endx() const override
Returns ending x-value of the current scan line.
int startx() const override
Returns starting x-value of the current scan line.
~vgl_ellipse_scan_iterator() override
Destructor.
int start_x_
Start of current scan line.
void reset() override
Resets the scan iterator to before the first scan line.
T xc_
Parameters of the ellipse being scan converted.
int end_x_
End of current scan line.
int scany() const override
y-coordinate of the current scan line.
Abstract base class for iterating over the pixels in a region of an image.
bool next() override
Tries to moves to the next scan line.