vgl_io_conic.hxx
Go to the documentation of this file.
1 // This is core/vgl/io/vgl_io_conic.hxx
2 #ifndef vgl_io_conic_hxx_
3 #define vgl_io_conic_hxx_
4 //:
5 // \file
6 
7 #include <iostream>
8 #include "vgl_io_conic.h"
9 #include <vgl/vgl_conic.h>
10 #include <vsl/vsl_binary_io.h>
11 
12 //============================================================================
13 //: Binary save self to stream.
14 template<class T>
15 void vsl_b_write(vsl_b_ostream &os, vgl_conic<T> const& conic)
16 {
17  constexpr short io_version_no = 1;
18  vsl_b_write(os, io_version_no);
19  vsl_b_write(os, conic.a());
20  vsl_b_write(os, conic.b());
21  vsl_b_write(os, conic.c());
22  vsl_b_write(os, conic.d());
23  vsl_b_write(os, conic.e());
24  vsl_b_write(os, conic.f());
25 }
26 
27 //============================================================================
28 //: Binary load self from stream.
29 template<class T>
30 void vsl_b_read(vsl_b_istream &is, vgl_conic<T> & conic)
31 {
32  if (!is) return;
33 
34  short v;
35  vsl_b_read(is, v);
36  switch (v)
37  {
38  case 1: // I/O version 1
39  T a, b, c, d, e, f;
40  vsl_b_read(is, a);
41  vsl_b_read(is, b);
42  vsl_b_read(is, c);
43  vsl_b_read(is, d);
44  vsl_b_read(is, e);
45  vsl_b_read(is, f);
46  conic.set(a,b,c,d,e,f);
47  break;
48 
49  default:
50  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_conic<T>&)\n"
51  << " Unknown version number "<< v << '\n';
52  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
53  return;
54  }
55 }
56 
57 
58 //============================================================================
59 //: Output a human readable summary to the stream
60 template<class T>
61 void vsl_print_summary(std::ostream& os, vgl_conic<T> const& conic)
62 {
63  os<<conic;
64 }
65 
66 #undef VGL_IO_CONIC_INSTANTIATE
67 #define VGL_IO_CONIC_INSTANTIATE(T) \
68 template void vsl_print_summary(std::ostream &, vgl_conic<T > const&); \
69 template void vsl_b_read(vsl_b_istream &, vgl_conic<T > &); \
70 template void vsl_b_write(vsl_b_ostream &, vgl_conic<T > const&)
71 
72 #endif // vgl_io_conic_hxx_
A quadratic plane curve.
void vsl_b_read(vsl_b_istream &is, vgl_conic< T > &conic)
Binary load self from stream.
T f() const
Returns the coefficient of .
Definition: vgl_conic.h:135
void vsl_print_summary(std::ostream &os, vgl_conic< T > const &conic)
Output a human readable summary to the stream.
T a() const
Returns the coefficient of .
Definition: vgl_conic.h:120
#define v
Definition: vgl_vector_2d.h:74
T c() const
Returns the coefficient of .
Definition: vgl_conic.h:126
T e() const
Returns the coefficient of .
Definition: vgl_conic.h:132
void vsl_b_write(vsl_b_ostream &os, vgl_conic< T > const &conic)
Binary save self to stream.
A quadratic plane curve.
Definition: vgl_conic.h:70
T b() const
Returns the coefficient of .
Definition: vgl_conic.h:123
T d() const
Returns the coefficient of .
Definition: vgl_conic.h:129
void set(T a, T b, T c, T d, T e, T f)
set or reset the conic using polynomial coefficients.
Definition: vgl_conic.hxx:80