Virtual Testbed
Ship dynamics simulator for extreme conditions
boat.hh
1 #ifndef VTESTBED_BSP_BOAT_HH
2 #define VTESTBED_BSP_BOAT_HH
3 
4 #include <iosfwd>
5 #include <string>
6 #include <vector>
7 
8 #include <vtestbed/geometry/rectangle.hh>
9 #include <vtestbed/geometry/types.hh>
10 
11 namespace vtb {
12 
14  namespace bsp {
15 
16  template <class T>
17  class Boat {
18 
19  private:
20  using vec3 = vtb::geometry::Vertex<T,3>;
21  using vec4 = vtb::geometry::Vertex<T,4>;
25 
26  private:
27  rectangle_type _bounds;
28  point_array_2d _control_points;
29  std::string _filename;
30 
31  public:
32  void clear();
33  void read(std::istream& in);
34  void gnuplot(std::ostream& out) const;
35 
36  inline void filename(const std::string& filename) { this->_filename = filename; }
37  inline const std::string& filename() const { return this->_filename; }
38  inline rectangle_type bounds() const { return this->_bounds; }
39  inline T draught() const { return -this->_bounds.min()(2); }
40  inline vec3 dimensions() const { return this->_bounds.extent(); }
41  inline const point_array_2d& control_points() const { return this->_control_points; }
42 
43  private:
44  rectangle_type calc_bounding_box() const;
45 
46  };
47 
48  template <class T>
49  inline std::istream&
50  operator>>(std::istream& in, Boat<T>& rhs) {
51  rhs.read(in);
52  return in;
53  }
54 
55  }
56 
57 }
58 
59 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9