KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
segment_pair.h
Go to the documentation of this file.
1 /* $Id: edge.h 11995 2012-03-29 20:19:58Z ksimek $ */
2 /* =========================================================================== *
3  |
4  | Copyright (c) 1994-2010 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== */
19 
20 #ifndef KJB_CPP_SEGMENT_PAIR_H
21 #define KJB_CPP_SEGMENT_PAIR_H
22 
23 #include <l/l_incl.h>
24 #include <edge/line_segment.h>
25 #include <i_cpp/i_image.h>
26 #include <string>
27 
28 namespace kjb
29 {
30 
32 {
33 public:
34  Segment_pair(const Line_segment & is1, const Line_segment & is2) : ls1(is1), ls2(is2)
35  {
36 
37  }
38 
39  Segment_pair(const Segment_pair & src) : ls1(src.ls1), ls2(src.ls2)
40  {
41 
42  }
43 
45  {
46  ls1 = src.ls1;
47  ls2 = src.ls2;
48  return (*this);
49  }
50 
52  {
53 
54  }
55 
56  const Line_segment & get_segment1() const
57  {
58  return ls1;
59  }
60 
61  const Line_segment & get_segment2() const
62  {
63  return ls2;
64  }
65 
66  void draw(Image & img, double ir = 255.0, double ig = 0.0, double ib = 0.0) const
67  {
68  ls1.draw(img, ir, ig, ib);
69  ls2.draw(img, ir, ig, ib);
70  }
71 
72  void draw_extremities(Image & img, double ir = 255.0, double ig = 0.0, double ib = 0.0) const
73  {
74  Vector v1 = get_extremity_1();
75  Vector v2 = get_extremity_2();
76  img(v1(1), v1(0), 0) = 255.0;
77  img(v1(1), v1(0), 1) = 0.0;
78  img(v1(1), v1(0), 2) = 0.0;
79  img(v2(1), v2(0), 0) = 255.0;
80  img(v2(1), v2(0), 1) = 0.0;
81  img(v2(1), v2(0), 2) = 0.0;
82  }
83 
84  const Vector & get_extremity_1() const
85  {
86  if(ls1.get_start_y() > ls1.get_end_y())
87  {
88  return ls1.get_start();
89  }
90  return ls1.get_end();
91  }
92 
93  const Vector & get_extremity_2() const
94  {
95  if(ls2.get_start_y() > ls2.get_end_y())
96  {
97  return ls2.get_start();
98  }
99  return ls2.get_end();
100  }
101 
102 
103 
104 private:
105  Line_segment ls1;
106  Line_segment ls2;
107 
108  int lowest;
109 
110 }; // namespace kjb
111 }
112 #endif
const Vector & get_extremity_2() const
Definition: segment_pair.h:93
double get_end_y() const
Returns the y-coordinate of the rightmost point of the segment.
Definition: gr_line_segment.h:174
const Line_segment & get_segment2() const
Definition: segment_pair.h:61
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
double get_start_y() const
Returns the y-coordinate of the leftmost point of the segment.
Definition: gr_line_segment.h:159
const Vector & get_extremity_1() const
Definition: segment_pair.h:84
void draw(kjb::Image &img, double ir, double ig, double ib, double width=1.0) const
Draws this line segment.
Definition: gr_line_segment.cpp:423
const Line_segment & get_segment1() const
Definition: segment_pair.h:56
const kjb::Vector & get_end() const
Returns the rightmost point of the segment.
Definition: gr_line_segment.h:180
const kjb::Vector & get_start() const
Returns the leftmost point of the segment.
Definition: gr_line_segment.h:165
void draw(Image &img, double ir=255.0, double ig=0.0, double ib=0.0) const
Definition: segment_pair.h:66
void draw_extremities(Image &img, double ir=255.0, double ig=0.0, double ib=0.0) const
Definition: segment_pair.h:72
Segment_pair(const Segment_pair &src)
Definition: segment_pair.h:39
~Segment_pair()
Definition: segment_pair.h:51
Code for a wrapper class around the C struct KJB_Image.
Wrapped version of the C struct KJB_image.
Definition: i_image.h:76
Segment_pair(const Line_segment &is1, const Line_segment &is2)
Definition: segment_pair.h:34
Class to manipulate a line segment The class is parametrized in terms the position of the centre...
Definition: gr_line_segment.h:62
Definition: segment_pair.h:31
Segment_pair & operator=(const Segment_pair &src)
Definition: segment_pair.h:44