core/vpgl/io/vpgl_io_local_rational_camera.txx
Go to the documentation of this file.
00001 #ifndef vpgl_io_local_rational_camera_txx_
00002 #define vpgl_io_local_rational_camera_txx_
00003 
00004 #include "vpgl_io_local_rational_camera.h"
00005 //:
00006 // \file
00007 #include <vpgl/vpgl_local_rational_camera.h>
00008 #include <vpgl/io/vpgl_io_rational_camera.h>
00009 #include <vnl/io/vnl_io_matrix_fixed.h>
00010 #include <vpgl/io/vpgl_io_lvcs.h>
00011 
00012 template <class T>
00013 void vsl_b_write(vsl_b_ostream & os, vpgl_local_rational_camera<T> const& camera)
00014 {
00015   if (!os) return;
00016   unsigned version = 1;
00017   vsl_b_write(os, version);
00018   // write rational camera parent
00019   vpgl_rational_camera<T> const& rat_cam = static_cast<vpgl_rational_camera<T> const& >(camera);
00020   vsl_b_write(os, rat_cam);
00021   vpgl_lvcs lvcs = camera.lvcs();
00022   vsl_b_write(os, lvcs);
00023 }
00024 
00025 //: Binary load camera from stream.
00026 template <class T>
00027 void vsl_b_read(vsl_b_istream & is, vpgl_local_rational_camera<T> &camera)
00028 {
00029   if (!is) return;
00030   short ver;
00031   vsl_b_read(is, ver);
00032   switch (ver)
00033   {
00034     case 1:
00035     {
00036       // read rational camera
00037       vpgl_rational_camera<T> rat_cam;
00038       vsl_b_read(is, rat_cam);
00039       vpgl_lvcs lvcs;
00040       // read lvcs
00041       vsl_b_read(is, lvcs);
00042       vpgl_local_rational_camera<T> lrat_cam(lvcs, rat_cam);
00043       camera = lrat_cam;
00044       break;
00045     }
00046     default:
00047       vcl_cerr << "I/O ERROR: vpgl_local_rational_camera::b_read(vsl_b_istream&)\n"
00048                << "           Unknown version number "<< ver << '\n';
00049       is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00050       return;
00051   }
00052 }
00053 
00054 //: Print human readable summary of object to a stream
00055 template <class T>
00056 void vsl_print_summary(vcl_ostream& os,const vpgl_local_rational_camera<T> & c)
00057 {
00058   os << c << '\n';
00059 }
00060 
00061 
00062 #define VPGL_IO_LOCAL_RATIONAL_CAMERA_INSTANTIATE(T) \
00063 template void vsl_b_write(vsl_b_ostream & os, vpgl_local_rational_camera<T > const& camera); \
00064 template void vsl_b_read(vsl_b_istream & is, vpgl_local_rational_camera<T > &camera); \
00065 template void vsl_print_summary(vcl_ostream& os,const vpgl_local_rational_camera<T > & b)
00066 
00067 #endif // vpgl_io_local_rational_camera_txx_