contrib/mul/mfpf/mfpf_pose_set.h
Go to the documentation of this file.
00001 #ifndef mfpf_pose_set_h_
00002 #define mfpf_pose_set_h_
00003 //:
00004 // \file
00005 // \brief Container for set of poses and associated fit values
00006 // \author Tim Cootes
00007 
00008 #include <mfpf/mfpf_pose.h>
00009 #include <vsl/vsl_vector_io.h>
00010 #include <vcl_iostream.h>
00011 #include <vcl_cstdlib.h>
00012 
00013 struct mfpf_pose_set
00014 {
00015   //: List of poses
00016   vcl_vector<mfpf_pose> poses;
00017 
00018   //: List of associated fits
00019   vcl_vector<double> fits;
00020 };
00021 
00022 inline void vsl_b_write(vsl_b_ostream& bfs,
00023                         const mfpf_pose_set& p)
00024 {
00025   vsl_b_write(bfs,short(1));  // Version number
00026   vsl_b_write(bfs,p.poses);
00027   vsl_b_write(bfs,p.fits);
00028 }
00029 
00030 inline void vsl_b_read(vsl_b_istream& bfs, mfpf_pose_set& p)
00031 {
00032   short version;
00033   vsl_b_read(bfs,version);
00034   switch (version)
00035   {
00036     case (1):
00037       vsl_b_read(bfs,p.poses);
00038       vsl_b_read(bfs,p.fits);
00039       break;
00040     default:
00041       vcl_cerr << "vsl_b_read(bfs,mfpf_pose_set): "
00042                << "Unexpected version number " << version << vcl_endl;
00043       vcl_abort();
00044   }
00045 }
00046 
00047 //: Write vector of objects to stream
00048 inline void vsl_b_write(vsl_b_ostream& bfs,
00049                         const vcl_vector<mfpf_pose_set>& p)
00050 {
00051   vsl_b_write(bfs,short(1));  // Version number
00052   vsl_b_write(bfs,unsigned(p.size()));
00053   for (unsigned i=0;i<p.size();++i)
00054     vsl_b_write(bfs,p[i]);
00055 }
00056 
00057 //: Read in vector of feature points from stream
00058 inline void vsl_b_read(vsl_b_istream& bfs,
00059                        vcl_vector<mfpf_pose_set>& p)
00060 {
00061   short version;
00062   vsl_b_read(bfs,version);
00063   unsigned n;
00064   switch (version)
00065   {
00066     case (1):
00067       vsl_b_read(bfs,n);
00068       p.resize(n);
00069       for (unsigned i=0;i<n;++i) vsl_b_read(bfs,p[i]);
00070       break;
00071     default:
00072       vcl_cerr << "vsl_b_read(bfs,vcl_vector<mfpf_pose_set>): "
00073                << "Unexpected version number " << version << vcl_endl;
00074       vcl_abort();
00075   }
00076 }
00077 
00078 #endif // mfpf_pose_set_h_
00079