Go to the documentation of this file.00001 #ifndef vpgl_io_affine_camera_txx_
00002 #define vpgl_io_affine_camera_txx_
00003
00004
00005 #include "vpgl_io_affine_camera.h"
00006
00007 #include <vpgl/vpgl_affine_camera.h>
00008 #include <vnl/io/vnl_io_matrix_fixed.h>
00009
00010 template <class T>
00011 void vsl_b_write(vsl_b_ostream & os, vpgl_affine_camera<T> const& camera)
00012 {
00013 if (!os) return;
00014 unsigned version = 1;
00015 vsl_b_write(os, version);
00016 vsl_b_write(os, camera.get_matrix());
00017 vsl_b_write(os, camera.viewing_distance());
00018 }
00019
00020
00021 template <class T>
00022 void vsl_b_read(vsl_b_istream & is, vpgl_affine_camera<T> &camera)
00023 {
00024 if (!is) return;
00025 short ver;
00026 vsl_b_read(is, ver);
00027 vnl_matrix_fixed<T,3,4> Pnew;
00028 switch (ver)
00029 {
00030 case 1:
00031 vsl_b_read(is, Pnew);
00032 camera.set_matrix(Pnew);
00033 T view_dist;
00034 vsl_b_read(is, view_dist);
00035 camera.set_viewing_distance(view_dist);
00036 break;
00037 default:
00038 vcl_cerr << "I/O ERROR: vpgl_affine_camera::b_read(vsl_b_istream&)\n"
00039 << " Unknown version number "<< ver << '\n';
00040 is.is().clear(vcl_ios::badbit);
00041 return;
00042 }
00043 }
00044
00045
00046 template <class T>
00047 void vsl_print_summary(vcl_ostream& os,const vpgl_affine_camera<T> & c)
00048 {
00049 os << c << '\n';
00050 }
00051
00052
00053 #define VPGL_IO_AFFINE_CAMERA_INSTANTIATE(T) \
00054 template void vsl_b_write(vsl_b_ostream & os, vpgl_affine_camera<T > const& camera); \
00055 template void vsl_b_read(vsl_b_istream & is, vpgl_affine_camera<T > &camera); \
00056 template void vsl_print_summary(vcl_ostream& os,const vpgl_affine_camera<T > & b)
00057
00058 #endif // vpgl_io_affine_camera_txx_