Virtual Testbed
Ship dynamics simulator for extreme conditions
object.hh
1 #ifndef VTESTBED_GEOMETRY_OBJECT_HH
2 #define VTESTBED_GEOMETRY_OBJECT_HH
3 
4 #include <istream>
5 #include <ostream>
6 #include <vector>
7 
8 #include <blitz/array.h>
9 
10 #include <vtestbed/geometry/polyhedron.hh>
11 
12 namespace vtb {
13 
15  namespace obj {
16 
27  template <class T>
28  class Object {
29 
30  public:
32  using vertex_array = typename polyhedron_type::vertex_array;
33  using face_array = typename polyhedron_type::face_array;
34  using face_type = typename face_array::value_type;
35  using index_type = typename face_type::value_type;
36 
37  private:
38  polyhedron_type _polyhedron;
39 
40  public:
41 
42  Object() = default;
43  ~Object() = default;
44  Object(const Object&) = default;
45  Object& operator=(const Object&) = default;
46  Object(Object&&) = default;
47  Object& operator=(Object&&) = default;
48 
49  inline explicit
50  Object(const polyhedron_type& polyhedron):
51  _polyhedron(polyhedron) {}
52 
53  inline explicit
54  Object(polyhedron_type&& polyhedron):
55  _polyhedron(std::move(polyhedron)) {}
56 
57  inline void clear() { this->_polyhedron.clear(); }
58  void write(std::ostream& out) const;
59  void read(std::istream& in);
60 
61  inline const polyhedron_type& polyhedron() const { return this->_polyhedron; }
62  inline polyhedron_type& polyhedron() { return this->_polyhedron; }
63 
64  };
65 
66  template <class T>
67  inline std::ostream&
68  operator<<(std::ostream& out, const Object<T>& rhs) {
69  rhs.write(out);
70  return out;
71  }
72 
73  template <class T>
74  inline std::istream&
75  operator>>(std::istream& in, Object<T>& rhs) {
76  rhs.read(in);
77  return in;
78  }
79 
80  }
81 
82 }
83 
84 #endif // vim:filetype=cpp
OBJ importer/exporter.
Definition: object.hh:28
Main namespace.
Definition: convert.hh:9