vgl_io_homg_plane_3d.hxx
Go to the documentation of this file.
1 // This is core/vgl/io/vgl_io_homg_plane_3d.hxx
2 #ifndef vgl_io_homg_plane_3d_hxx_
3 #define vgl_io_homg_plane_3d_hxx_
4 //:
5 // \file
6 
7 #include <iostream>
8 #include "vgl_io_homg_plane_3d.h"
9 #include <vsl/vsl_binary_io.h>
10 
11 //============================================================================
12 //: Binary save self to stream.
13 template<class T>
14 void vsl_b_write(vsl_b_ostream &os, const vgl_homg_plane_3d<T> & p)
15 {
16  constexpr short io_version_no = 1;
17  vsl_b_write(os, io_version_no);
18  vsl_b_write(os, p.nx());
19  vsl_b_write(os, p.ny());
20  vsl_b_write(os, p.nz());
21  vsl_b_write(os, p.d());
22 }
23 
24 //============================================================================
25 //: Binary load self from stream.
26 template<class T>
27 void vsl_b_read(vsl_b_istream &is, vgl_homg_plane_3d<T> & p)
28 {
29  if (!is) return;
30 
31  short v;
32  vsl_b_read(is, v);
33  switch (v)
34  {
35  case 1:
36  T x,y,z,d;
37  vsl_b_read(is, x);
38  vsl_b_read(is, y);
39  vsl_b_read(is, z);
40  vsl_b_read(is, d);
41  p.set(x,y,z,d);
42  break;
43 
44  default:
45  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_homg_plane_3d<T>&)\n"
46  << " Unknown version number "<< v << '\n';
47  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
48  return;
49  }
50 }
51 
52 
53 //============================================================================
54 //: Output a human readable summary to the stream
55 template<class T>
56 void vsl_print_summary(std::ostream& os,const vgl_homg_plane_3d<T> & p)
57 {
58  os<<"( x,y,z="<< p.nx()<<','<<p.ny()<<','<<p.nz()<< " d=" << p.d() << ')';
59 }
60 
61 #define VGL_IO_HOMG_PLANE_3D_INSTANTIATE(T) \
62 template void vsl_print_summary(std::ostream &, const vgl_homg_plane_3d<T > &); \
63 template void vsl_b_read(vsl_b_istream &, vgl_homg_plane_3d<T > &); \
64 template void vsl_b_write(vsl_b_ostream &, const vgl_homg_plane_3d<T > &)
65 
66 #endif // vgl_io_homg_plane_3d_hxx_
void vsl_print_summary(std::ostream &os, const vgl_homg_plane_3d< T > &p)
Output a human readable summary to the stream.
void vsl_b_read(vsl_b_istream &is, vgl_homg_plane_3d< T > &p)
Binary load self from stream.
Type d() const
Return homogeneous scaling coefficient.
#define v
Definition: vgl_vector_2d.h:74
void set(Type ta, Type tb, Type tc, Type td)
Set equation a*x+b*y+c*z+d*w=0.
void vsl_b_write(vsl_b_ostream &os, const vgl_homg_plane_3d< T > &p)
Binary save self to stream.