Go to the documentation of this file.00001 #ifndef mfpf_region_form_h_
00002 #define mfpf_region_form_h_
00003
00004
00005
00006
00007
00008 #include <mfpf/mfpf_pose.h>
00009 #include <vcl_iostream.h>
00010 #include <vcl_cstdlib.h>
00011
00012
00013
00014
00015
00016
00017 struct mfpf_region_form
00018 {
00019
00020 mfpf_pose pose_;
00021
00022
00023 double wi_;
00024
00025 double wj_;
00026
00027
00028 vcl_string form_;
00029
00030 public:
00031
00032
00033 mfpf_region_form(const mfpf_pose& p, vcl_string form,
00034 double wi, double wj)
00035 : pose_(p),wi_(wi),wj_(wj),form_(form) {}
00036
00037
00038 mfpf_region_form() {}
00039
00040
00041 mfpf_pose& pose() { return pose_; }
00042
00043
00044 double& wi() { return wi_; }
00045
00046 double& wj() { return wj_; }
00047
00048
00049 vcl_string& form() { return form_; }
00050
00051
00052 const mfpf_pose& pose() const { return pose_; }
00053
00054
00055 double wi() const { return wi_; }
00056
00057 double wj() const { return wj_; }
00058
00059
00060 const vcl_string& form() const { return form_; }
00061 };
00062
00063 inline vcl_ostream& operator<<(vcl_ostream& os,
00064 const mfpf_region_form& p)
00065 {
00066 os<<p.form()<<" wi: "<<p.wi()<<" wj: "<<p.wj()<<' '<<p.pose();
00067 return os;
00068 }
00069
00070
00071 inline void vsl_b_write(vsl_b_ostream& bfs,
00072 const mfpf_region_form& p)
00073 {
00074 vsl_b_write(bfs,short(1));
00075 vsl_b_write(bfs,p.pose());
00076 vsl_b_write(bfs,p.form());
00077 vsl_b_write(bfs,p.wi());
00078 vsl_b_write(bfs,p.wj());
00079 }
00080
00081 inline void vsl_b_read(vsl_b_istream& bfs, mfpf_region_form& p)
00082 {
00083 short version;
00084 vsl_b_read(bfs,version);
00085 switch (version)
00086 {
00087 case 1:
00088 vsl_b_read(bfs,p.pose());
00089 vsl_b_read(bfs,p.form());
00090 vsl_b_read(bfs,p.wi());
00091 vsl_b_read(bfs,p.wj());
00092 break;
00093 default:
00094 vcl_cerr << "vsl_b_read(bfs,mfpf_region_form): "
00095 << "Unexpected version number " << version << vcl_endl;
00096 vcl_abort();
00097 }
00098 }
00099
00100
00101 inline void vsl_b_write(vsl_b_ostream& bfs,
00102 const vcl_vector<mfpf_region_form>& p)
00103 {
00104 vsl_b_write(bfs,short(1));
00105 vsl_b_write(bfs,unsigned(p.size()));
00106 for (unsigned i=0;i<p.size();++i)
00107 vsl_b_write(bfs,p[i]);
00108 }
00109
00110
00111 inline void vsl_b_read(vsl_b_istream& bfs,
00112 vcl_vector<mfpf_region_form>& p)
00113 {
00114 short version;
00115 vsl_b_read(bfs,version);
00116 unsigned n;
00117 switch (version)
00118 {
00119 case 1:
00120 vsl_b_read(bfs,n);
00121 p.resize(n);
00122 for (unsigned i=0;i<n;++i) vsl_b_read(bfs,p[i]);
00123 break;
00124 default:
00125 vcl_cerr << "vsl_b_read(bfs,vcl_vector<mfpf_region_form>): "
00126 << "Unexpected version number " << version << vcl_endl;
00127 vcl_abort();
00128 }
00129 }
00130
00131 #endif // mfpf_region_form_h_