Go to the documentation of this file.00001
00002 #ifndef mbl_chord_h_
00003 #define mbl_chord_h_
00004
00005
00006
00007
00008
00009 #include <vsl/vsl_binary_io.h>
00010
00011
00012
00013 class mbl_chord
00014 {
00015 private:
00016 int start_x_;
00017 int end_x_;
00018 int y_;
00019 public:
00020
00021 mbl_chord() : start_x_(0),end_x_(-1),y_(0) {}
00022
00023
00024 mbl_chord(int start_x, int end_x, int y)
00025 : start_x_(start_x), end_x_(end_x), y_(y) {}
00026
00027
00028 int start_x() const { return start_x_; }
00029
00030
00031 int end_x() const { return end_x_; }
00032
00033
00034 int y() const { return y_; }
00035
00036
00037 int length() const { return 1+end_x_-start_x_; }
00038
00039
00040 inline void b_write(vsl_b_ostream& bfs) const;
00041
00042
00043 inline void b_read(vsl_b_istream& bfs);
00044
00045
00046 bool operator==(const mbl_chord& c) const;
00047 };
00048
00049
00050 inline void mbl_chord::b_write(vsl_b_ostream& bfs) const
00051 {
00052 vsl_b_write(bfs,start_x_);
00053 vsl_b_write(bfs,end_x_);
00054 vsl_b_write(bfs,y_);
00055 }
00056
00057
00058 inline void mbl_chord::b_read(vsl_b_istream& bfs)
00059 {
00060 vsl_b_read(bfs,start_x_);
00061 vsl_b_read(bfs,end_x_);
00062 vsl_b_read(bfs,y_);
00063 }
00064
00065 inline bool mbl_chord::operator==(const mbl_chord& c) const
00066 {
00067 return start_x_ ==c.start_x_ && end_x_==c.end_x_ && y_==c.y_;
00068 }
00069
00070
00071 inline vcl_ostream& operator<<(vcl_ostream& os, const mbl_chord& c)
00072 {
00073 return os<<"(["<<c.start_x()<<","<<c.end_x()<<"],"<<c.y()<<")";
00074 }
00075
00076
00077 inline void vsl_b_write(vsl_b_ostream& bfs, const mbl_chord& t)
00078 {
00079 t.b_write(bfs);
00080 }
00081
00082
00083 inline void vsl_b_read(vsl_b_istream& bfs, mbl_chord& t)
00084 {
00085 t.b_read(bfs);
00086 }
00087
00088
00089 inline void vsl_print_summary(vcl_ostream& os, const mbl_chord& t)
00090 {
00091 os<<t;
00092 }
00093
00094 #endif // mbl_chord_h_