00001 #ifndef mfpf_region_about_pt_h_ 00002 #define mfpf_region_about_pt_h_ 00003 //: 00004 // \file 00005 // \brief Region centred on a single point, pose defined by other pts 00006 // \author Tim Cootes 00007 00008 #include <mfpf/mfpf_region_definer.h> 00009 #include <vcl_iosfwd.h> 00010 00011 //: Region centred on a single point, pose defined by other pts 00012 // Region defined by three points, p0=pts[i0], p1, p2. 00013 // The region is centred on p0. 00014 // Bounding box of region is aligned with the vector (p2-p1), 00015 // and its width and height are defined relative to |p2-p1| 00016 // 00017 // Parameters in text file: 00018 // \verbatim 00019 // { i0: 5 i1: 31 i2: 37 rel_wi: 0.5 rel_wj: 0.2 form: box } 00020 // \endverbatim 00021 class mfpf_region_about_pt : public mfpf_region_definer 00022 { 00023 private: 00024 //: Original index of point on which region is centred 00025 unsigned i0_orig_; 00026 //: Index of point on which region is centred 00027 unsigned i0_; 00028 //: Index of first point defining reference frame 00029 unsigned i1_; 00030 //: Index of second point defining reference frame 00031 unsigned i2_; 00032 00033 //: Width of ROI, relative to |p2-p1| 00034 double rel_wi_; 00035 00036 //: Height of ROI, relative to |p2-p1| 00037 double rel_wj_; 00038 00039 //: Width of ROI in world coords 00040 double wi_; 00041 00042 //: Height of ROI in world coords 00043 double wj_; 00044 00045 //: Name of form of shape ("box","ellipse") 00046 vcl_string form_; 00047 00048 public: 00049 00050 //: Dflt ctor 00051 mfpf_region_about_pt(); 00052 00053 //: Destructor 00054 virtual ~mfpf_region_about_pt(); 00055 00056 //: Returns true as the region is centred on an input point 00057 virtual bool is_centred_on_pt() const; 00058 00059 //: Returns index of reference point on which the region is centred 00060 virtual unsigned ref_point_index() const; 00061 00062 //: Returns original index of reference point on which the region is centred 00063 virtual unsigned orig_ref_point_index() const; 00064 00065 //: Replace each point index i with new_index[i] 00066 // Allows for re-numbering of the points used. 00067 // Returns true if successful. 00068 virtual bool replace_index(const vcl_vector<unsigned>& new_index); 00069 00070 //: Index of point on which region is centred 00071 unsigned i0() const { return i0_; } 00072 00073 //: Index of first point defining reference frame 00074 unsigned i1() const { return i1_; } 00075 00076 //: Index of second point defining reference frame 00077 unsigned i2() const { return i2_; } 00078 00079 //: Width of ROI, relative to |p2-p1| 00080 double rel_wi() const { return rel_wi_; } 00081 00082 //: Height of ROI, relative to |p2-p1| 00083 double rel_wj() const { return rel_wj_; } 00084 00085 //: Width of ROI in world coords 00086 double wi() const { return wi_; } 00087 00088 //: Height of ROI in world coords 00089 double wj() const { return wj_; } 00090 00091 //: Name of form of shape ("box","ellipse") 00092 vcl_string form() const { return form_; } 00093 00094 //: Returns reference point for region, pts[i0()] 00095 virtual vgl_point_2d<double> get_ref_point( 00096 const vcl_vector<vgl_point_2d<double> >& pts) const; 00097 00098 //: Defines a region centred on a point 00099 virtual mfpf_region_form set_up( 00100 const vcl_vector<vgl_point_2d<double> >& pts); 00101 00102 //: Defines a region centred on a point 00103 // The aspect ratio of the region will be the same as that 00104 // from the last call to set_up. 00105 virtual mfpf_region_form get_region( 00106 const vcl_vector<vgl_point_2d<double> >& pts) const; 00107 00108 //: Initialise from a stream 00109 virtual bool set_from_stream(vcl_istream &is); 00110 00111 //: Version number for I/O 00112 short version_no() const; 00113 00114 //: Name of the class 00115 virtual vcl_string is_a() const; 00116 00117 //: Create a copy on the heap and return base class pointer 00118 virtual mfpf_region_definer* clone() const; 00119 00120 //: Print class to os 00121 virtual void print_summary(vcl_ostream& os) const; 00122 00123 //: Save class to binary file stream 00124 virtual void b_write(vsl_b_ostream& bfs) const; 00125 00126 //: Load class from binary file stream 00127 virtual void b_read(vsl_b_istream& bfs); 00128 }; 00129 00130 #endif