1 // This is gel/vifa/vifa_coll_lines.h 2 #ifndef VIFA_COLL_LINES 3 #define VIFA_COLL_LINES 4 5 //----------------------------------------------------------------------------- 6 //: 7 // \file 8 // \brief Store information about collinear lines 9 // 10 // \author Roddy Collins, from DDB in TargetJr 11 // 12 // \verbatim 13 // Modifications: 14 // MPP Mar 2003, Ported to VXL 15 // \endverbatim 16 //----------------------------------------------------------------------------- 17 18 #include <iostream> 19 #include <vector> 20 #ifdef _MSC_VER 21 # include <vcl_msvc_warnings.h> 22 #endif 23 #include <vbl/vbl_smart_ptr.h> 24 #include <vgl/vgl_point_2d.h> 25 #include <vtol/vtol_edge.h> 26 #include <vtol/vtol_edge_2d.h> 27 #include <vifa/vifa_coll_lines_params.h> 28 #include <vifa/vifa_typedefs.h> 29 30 31 class vifa_coll_lines : public vifa_coll_lines_params 32 { 33 private: 34 bool discard_flag_; 35 static int serial_num_; 36 int id_; 37 imp_line_sptr hypothesized_line_; 38 edge_2d_list contributors_; 39 double projected_length_cutoff_; 40 double endpt_distance_; 41 42 public: 43 vifa_coll_lines(const vtol_edge_2d_sptr& e, 44 double angle_cutoff_deg = 5.0, 45 double endpt_distance = 3.0, 46 bool src_from_discard = false 47 ); 48 ~vifa_coll_lines() override; 49 50 bool get_discard_flag() const; 51 int get_id() const; 52 double get_measure(const vtol_edge_2d& e) const; 53 double get_projected_length(const vtol_edge_2d& e) const; 54 55 edge_2d_list &get_contributors(); 56 57 // Caller must delete returned face_list when done 58 face_list *get_contributor_faces(); 59 60 static void lms_fit(const std::vector<double>& x, 61 const std::vector<double>& y, 62 double& A, 63 double& B, 64 double& C 65 ); 66 67 void add_and_update(const vtol_edge_2d_sptr& e); 68 double spanning_length(); 69 double spanning_length(vgl_point_2d<double>& p1, 70 vgl_point_2d<double>& p2 71 ); 72 double support_length(); 73 bool contains(const vtol_edge& e); 74 75 private: 76 static double get_projected_length(const vtol_edge_2d& e, 77 const imp_line& hyp_line, 78 double& v1_dist, 79 double& v2_dist 80 ); 81 static double get_midpt_dist(const vtol_edge_2d& e, 82 const imp_line& hyp_line 83 ); 84 double get_measure(const vtol_edge_2d& e, 85 const imp_line& hyp_line 86 ) const; 87 88 void fit_line(); 89 }; 90 91 typedef vbl_smart_ptr<vifa_coll_lines> vifa_coll_lines_sptr; 92 93 typedef std::vector<vifa_coll_lines_sptr> coll_list; 94 typedef std::vector<vifa_coll_lines_sptr>::iterator coll_iterator; 95 96 97 #endif // VIFA_COLL_LINES 98