1 // This is oxl/mvl/LineSegSet.h
2 #ifndef LineSegSet_h_
3 #define LineSegSet_h_
4 //
5 // \author
6 //     Andrew W. Fitzgibbon, Oxford RRG, 19 Sep 96
7 //
8 //-----------------------------------------------------------------------------
9 
10 #include <vector>
11 #include <iostream>
12 #include <iosfwd>
13 #ifdef _MSC_VER
14 #  include <vcl_msvc_warnings.h>
15 #endif
16 #include <mvl/HomgLineSeg2D.h>
17 #include <mvl/HomgMetric.h>
18 
19 class ImageMetric;
20 
21 class LineSegSet
22 {
23   // Data Members--------------------------------------------------------------
24   std::vector<HomgLineSeg2D> hlines_;
25   HomgMetric conditioner_;
26 
27  public:
28   // Constructors/Destructors--------------------------------------------------
29 
30   LineSegSet();
31   LineSegSet(const HomgMetric& c, const std::vector<HomgLineSeg2D>& lines, bool is_conditioned = true);
32   LineSegSet(const char* filename, const HomgMetric& c = nullptr);
33   LineSegSet(const LineSegSet& that);
34  ~LineSegSet();
35 
36   LineSegSet& operator=(const LineSegSet& that);
37 
38   // Operations----------------------------------------------------------------
size()39   unsigned size() const { return hlines_.size(); }
40 
41   // Computations--------------------------------------------------------------
42   int pick_line_index(double x, double y);
43   HomgLineSeg2D* pick_line(double x, double y);
44 
45   // Data Access---------------------------------------------------------------
get_homg(int i)46         HomgLineSeg2D& get_homg(int i)       { return hlines_[i]; }
get_homg(int i)47   const HomgLineSeg2D& get_homg(int i) const { return hlines_[i]; }
48 
get_homg()49   std::vector<HomgLineSeg2D>& get_homg() { return hlines_; }
50 
51   int FindNearestLineIndex(double x, double y);
52 
53   // Data Control--------------------------------------------------------------
54   bool load_ascii(std::istream&, HomgMetric const& c);
55   bool save_ascii(std::ostream&) const;
56 
57   bool set_iuline(int i, void* l);
58 
59   void compute_homglines_from_rawlines(const HomgMetric& );
60 };
61 
62 #endif // LineSegSet_h_
63