contrib/mul/msm/msm_pose_maker.h
Go to the documentation of this file.
00001 #ifndef msm_pose_maker_h_
00002 #define msm_pose_maker_h_
00003 //:
00004 // \file
00005 // \author Tim Cootes
00006 // \brief Compute a direction at each point, usually normal to curve
00007 
00008 #include <msm/msm_points.h>
00009 #include <msm/msm_curve.h>
00010 #include <vgl/vgl_vector_2d.h>
00011 #include <vcl_iosfwd.h>
00012 
00013 //: Compute a direction at each point, usually normal to curve.
00014 //  Generates a unit direction vector for each point.
00015 //  Typically these are defined as normals to the curve passing
00016 //  through the point.
00017 //
00018 //  Define tangent at point i as line between end0_[i] and end1_[i].
00019 //  If end0_[i]==end1_[i] then use vector (1,0) in ref. frame.
00020 class msm_pose_maker
00021 {
00022  private:
00023   //: Define tangent at point i as line between end0_[i] and end1_[i]
00024   vcl_vector<unsigned> end0_;
00025 
00026   //: Define tangent at point i as line between end0_[i] and end1_[i]
00027   vcl_vector<unsigned> end1_;
00028 
00029  public:
00030   ~msm_pose_maker() {}
00031 
00032   //: Set up definitions of directions from the curves.
00033   //  Where multiple curves pass through a point, the direction
00034   //  is defined by the first in the list.
00035   void set_from_curves(unsigned n_points, const msm_curves& curves);
00036 
00037   //: Returns true if direction defined at point i
00038   bool defined(unsigned i) { return end0_[i]!=0 || end1_[i]!=0; }
00039 
00040   //: Compute a direction at each point, usually normal to curve.
00041   void create_vectors(const msm_points& points,
00042                       vcl_vector<vgl_vector_2d<double> >& dir) const;
00043 
00044   //: Print class to os
00045   void print_summary(vcl_ostream& os) const;
00046 
00047   //: Save class to binary file stream
00048   void b_write(vsl_b_ostream& bfs) const;
00049 
00050   //: Load class from binary file stream
00051   void b_read(vsl_b_istream& bfs);
00052 };
00053 
00054 //: Binary file stream output operator for class reference
00055 void vsl_b_write(vsl_b_ostream& bfs, const msm_pose_maker& b);
00056 
00057 //: Binary file stream input operator for class reference
00058 void vsl_b_read(vsl_b_istream& bfs, msm_pose_maker& b);
00059 
00060 //: Stream output operator for class reference
00061 vcl_ostream& operator<<(vcl_ostream& os,const msm_pose_maker& b);
00062 
00063 #endif // msm_pose_maker_h_