vgl_io_line_3d_2_points.hxx
Go to the documentation of this file.
1 // This is core/vgl/io/vgl_io_line_3d_2_points.hxx
2 #ifndef vgl_io_line_3d_2_points_hxx_
3 #define vgl_io_line_3d_2_points_hxx_
4 //:
5 // \file
6 // \author Peter Vanroose
7 // \date 24 Oct 2002
8 
9 #include <iostream>
11 #include <vgl/io/vgl_io_point_3d.h>
12 
13 //============================================================================
14 //: Binary save self to stream.
15 template<class T>
16 void vsl_b_write(vsl_b_ostream& os, vgl_line_3d_2_points<T> const& p)
17 {
18  constexpr short io_version_no = 1;
19  vsl_b_write(os, io_version_no);
20  vsl_b_write(os, p.point1());
21  vsl_b_write(os, p.point2());
22 }
23 
24 //============================================================================
25 //: Binary load self from stream.
26 template<class T>
27 void vsl_b_read(vsl_b_istream &is, vgl_line_3d_2_points<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  {
37  vgl_point_3d<T> p1,p2; vsl_b_read(is,p1); vsl_b_read(is,p2); p.set(p1,p2);
38  return;
39  }
40 
41  default:
42  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_line_3d_2_points<T>&)\n"
43  << " Unknown version number "<< v << '\n';
44  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
45  return;
46  }
47 }
48 
49 
50 //============================================================================
51 //: Output a human readable summary to the stream
52 template<class T>
53 void vsl_print_summary(std::ostream& os, vgl_line_3d_2_points<T> const& p)
54 {
55  os<<'('; vsl_print_summary(os,p.point1());
56  os<<','; vsl_print_summary(os,p.point2());
57  os<<')';
58 }
59 
60 #define VGL_IO_LINE_3D_2_POINTS_INSTANTIATE(T) \
61 template void vsl_print_summary(std::ostream&, vgl_line_3d_2_points<T > const&);\
62 template void vsl_b_read(vsl_b_istream&, vgl_line_3d_2_points<T > &); \
63 template void vsl_b_write(vsl_b_ostream&, vgl_line_3d_2_points<T > const&)
64 
65 #endif // vgl_io_line_3d_2_points_hxx_
void set(vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2)
Assignment.
void vsl_b_write(vsl_b_ostream &os, vgl_line_3d_2_points< T > const &p)
Binary save self to stream.
A class to hold a non-homogeneous representation of a 3D line.
Definition: vgl_fwd.h:17
#define v
Definition: vgl_vector_2d.h:74
vgl_point_3d< Type > point1() const
Return the first point representing this line.
void vsl_print_summary(std::ostream &os, vgl_line_3d_2_points< T > const &p)
Output a human readable summary to the stream.
vgl_point_3d< Type > point2() const
Return the second point representing this line.
void vsl_b_read(vsl_b_istream &is, vgl_line_3d_2_points< T > &p)
Binary load self from stream.