Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

fhs_arc.h

Go to the documentation of this file.
00001 // This is mul/fhs/fhs_arc.h
00002 #ifndef fhs_arc_h_
00003 #define fhs_arc_h_
00004 //:
00005 // \file
00006 // \author Tim Cootes
00007 // \brief Link between one node and another
00008 
00009 #include <vsl/vsl_binary_io.h>
00010 #include <vcl_vector.h>
00011 
00012 //: Link between one node and another
00013 //  Indicates that position of node j, p(j) = p(i) + (N(dx,var_x),N(dy,var_y))
00014 //  where N(m,var) is a gaussian with mean m and variance var
00015 class fhs_arc
00016 {
00017 private:
00018   unsigned i_;
00019   unsigned j_;
00020   double dx_;
00021   double dy_;
00022   double var_x_;
00023   double var_y_;
00024 public:
00025     //: Default constructor
00026   fhs_arc()
00027     : i_(0),j_(0),dx_(0),dy_(0),var_x_(1.0),var_y_(1.0) {}
00028 
00029     //: Constructor
00030   fhs_arc(int i, int j, double dx, double dy, double var_x, double var_y)
00031     : i_(i),j_(j),dx_(dx),dy_(dy),var_x_(var_x),var_y_(var_y) {}
00032 
00033   //: Return arc from j to i (ie directions reversed)
00034   fhs_arc flipped() const
00035   { return fhs_arc(j(),i(),-dx(),-dy(),var_x(),var_y()); }
00036 
00037     //: Index of first node
00038   unsigned i() const { return i_; }
00039 
00040     //: Index of second node
00041   unsigned j() const { return j_; }
00042 
00043     //: Mean x offset of j() from i()
00044   double dx() const { return dx_; }
00045 
00046     //: Mean y offset of j() from i()
00047   double dy() const { return dy_; }
00048 
00049     //: Variance of x offset of j() from i()
00050   double var_x() const { return var_x_; }
00051 
00052     //: Variance of y offset of j() from i()
00053   double var_y() const { return var_y_; }
00054 
00055     //: Write to binary stream
00056   void b_write(vsl_b_ostream& bfs) const;
00057 
00058     //: Read from binary stream
00059   void b_read(vsl_b_istream& bfs);
00060 };
00061 
00062 //: Re-order list of arcs so that parents precede their children
00063 //  Assumes that there are n nodes (indexed 0..n-1),
00064 //  thus n-1 arcs defining a tree.
00065 //  On exit children[i] gives list of children of node i
00066 bool fhs_order_tree_from_root(const vcl_vector<fhs_arc>& arc0,
00067                          vcl_vector<fhs_arc>& new_arc,
00068                          vcl_vector<vcl_vector<unsigned> >& children,
00069                          unsigned new_root);
00070 
00071 
00072 //: Print
00073 vcl_ostream& operator<<(vcl_ostream& os, const fhs_arc& c);
00074 
00075 //: Print set
00076 vcl_ostream& operator<<(vcl_ostream& os, const vcl_vector<fhs_arc>& arc);
00077 
00078 //: Save
00079 inline void vsl_b_write(vsl_b_ostream& bfs, const fhs_arc& t)
00080 {
00081   t.b_write(bfs);
00082 }
00083 
00084 //: Load
00085 inline void vsl_b_read(vsl_b_istream& bfs, fhs_arc& t)
00086 {
00087   t.b_read(bfs);
00088 }
00089 
00090 //: Print
00091 void vsl_print_summary(vcl_ostream& os, const fhs_arc& t);
00092 
00093 #endif // fhs_arc_h_

Generated on Thu Jan 10 14:44:46 2008 for contrib/mul/fhs by  doxygen 1.4.4