1 #ifndef VTESTBED_DB_HULL_HH 2 #define VTESTBED_DB_HULL_HH 7 #include <sqlitex/forward.hh> 9 #include <vtestbed/core/mass.hh> 10 #include <vtestbed/core/types.hh> 11 #include <vtestbed/db/entity.hh> 12 #include <vtestbed/db/ship_hull_transformation.hh> 13 #include <vtestbed/geometry/polyhedron.hh> 23 using vec3 = vtb::core::Vector3<T>;
26 using time_point = clock::time_point;
27 using duration = clock::duration;
28 using color_type = vec3;
43 time_point _created{duration::zero()};
44 time_point _modified{duration::zero()};
45 color_type _color{T{0.184}, T{0.513}, T{0.8}};
49 using Entity::filename;
55 Hull& operator=(
const Hull&) =
default;
57 inline const std::string& author()
const {
return this->_author; }
58 inline const std::string& organisation()
const {
return this->_organisation; }
59 inline void author(
const std::string& rhs) { this->_author = rhs; }
60 inline void organisation(
const std::string& rhs) { this->_organisation = rhs; }
65 return this->current_polyhedron();
70 this->current_polyhedron() = rhs;
75 this->current_polyhedron() = std::move(rhs);
78 inline const vec3& scale()
const {
return this->_scale; }
79 inline void scale(
const vec3& rhs) { this->_scale = rhs; }
82 inline T
length()
const {
return this->_length; }
85 inline T
beam()
const {
return this->_beam; }
88 inline T
depth()
const {
return this->_depth; }
91 inline T
draught()
const {
return this->_draught; }
92 inline void draught(T rhs) { this->_draught = rhs; }
95 dimensions(T x, T y, T z) {
102 dimensions(
const vec3& v) {
103 this->_length = v(0);
108 inline const transformation_array&
109 transformations()
const {
110 return this->_transforms;
113 inline const time_point& created()
const {
return this->_created; }
114 inline const time_point& modified()
const {
return this->_modified; }
115 inline void created(
const time_point& rhs) { this->_created = rhs; }
116 inline void modified(
const time_point& rhs) { this->_modified = rhs; }
118 inline const color_type&
119 color() const noexcept {
124 color(
const color_type& rhs) {
129 color(T r, T g, T b) {
136 file_name_for_export()
const;
138 bool has_valid_id(sqlite::connection* db)
const;
139 bool original(sqlite::connection* db)
const;
140 void insert(sqlite::connection* db);
141 void copy(sqlite::connection* db);
142 void select(sqlite::connection* db);
143 void update(sqlite::connection* db);
144 void save(sqlite::connection* db);
146 void import_original();
147 void select_blobs(sqlite::connection* db);
148 void update_blobs(sqlite::connection* db);
149 void save_blobs(sqlite::connection* db);
150 void remove(sqlite::connection* db);
160 void transform(
const transformation_type& rhs);
161 void clear_transforms();
162 inline void undo() { this->_transforms.undo(); }
163 inline void redo() { this->_transforms.redo(); }
166 friend sqlite::statement&
167 operator>>(sqlite::statement& in, Hull<X>& rhs);
170 all(sqlite::connection* db);
181 current_polyhedron()
const {
182 return this->_polyhedrons[this->_transforms.index()];
186 current_polyhedron() {
187 auto& gs = this->_polyhedrons;
188 if (gs.empty()) { gs.emplace_back(); }
189 return gs[this->_transforms.index()];
193 original_polyhedron()
const {
194 return this->_polyhedrons.front();
201 operator>>(sqlite::statement& in, Hull<T>& rhs);
205 swap(Hull<T>& lhs, Hull<T>& rhs) {
213 #endif // vim:filetype=cpp
T draught() const
Get vertical the distance between the waterline and the bottom of the hull.
T length() const
Get overall hull length in metres.
T depth() const
Get overall hull height in metres.
T beam() const
Get overall hull width in metres.