Marine systems simulation
HullData.h
1#ifndef CHullData_h__
2#define CHullData_h__
3
4#include <vector>
5#include <map>
6#include <assert.h>
7
8#include <Eigen/Eigen>
9
10#include "Section.h"
11
12namespace Ship{
14 {
15 public:
16 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
17 struct Point
18 {
19 Point( double _x,double _y, double _z )
20 {
21 x = _x;
22 y = _y;
23 z = _z;
24 }
25
26 Point( const Point &P )
27 {
28 x = P.x;
29 y = P.y;
30 z = P.z;
31 }
32
33 Point( )
34 {
35 x = 0;
36 y = 0;
37 z = 0;
38 }
39
40 double x;
41 double y;
42 double z;
43
44 double nx;
45 double ny;
46 double nz;
47
48 bool operator ==( const Point &rhs)
49 {
50 return (this->x == rhs.x) && (this->y == rhs.y) && (this->z == rhs.z);
51 }
52
53 static bool CompareDraught( const struct Point &lhs, const struct Point &rhs )
54 {
55 return lhs.z < rhs.z;
56 }
57 };
58
59
61 {
62 double Lpp;
63 double T;
64 double B;
65 double Sink;
66 double Trim;
67 double Disp;
68 double VCB;
69 double VCG;
70 double LCB;
71 double LCG;
72 double Cb;
73 double GMt;
74 double GMl;
75 };
76
77 struct HullFace
78 {
79 std::vector<Eigen::Vector3d> Vertices;
80 Eigen::Vector3d Normal;
81 Eigen::Vector3d Center;
82 Eigen::Vector3d BodyPressure;
83 Eigen::Vector3d NEDPressure;
84 double Pressure;
85 double Area;
86
87 };
88
90 {
91 std::vector<Eigen::Vector3d> Vertices;
92 std::vector<Eigen::Vector3d> Normals;
93 std::vector<Eigen::Vector3d> Color;
94 std::vector<int> VertexStation;
95 std::vector< HullFace > Faces;
96 };
97
98 HullData( std::string &fname );
99 virtual ~HullData() {}
100
101 void SetPosition( double n, double e, double d)
102 {
103 r(0) = n;
104 r(1) = e;
105 r(2) = d;
106 }
107
108 void SetPosition(const Eigen::Vector3d &vec )
109 {
110 SetPosition(vec(0),vec(1),vec(2));
111 }
112
113 void SetRotation( const Eigen::Quaterniond &q)
114 {
115 this->q = q;
116 }
117
118 void SetRotation( double w, double x, double y, double z)
119 {
120 q = Eigen::Quaterniond(w,x,y,z);
121 }
122
123 virtual void ReadHullGeometry( std::string& fname )=0;
124 virtual void ReadWaterLine( std::string& fname )=0;
125
126 void CalculateHullSectionData();
127
128 void AddStation( const std::vector<double> & x, const std::vector<double> & y,const std::vector<double> & z );
129 void GetStation( int StationNr, std::vector<Eigen::Vector3d> &Out);
130 double GetStationArea( int SectionNr );
131 double GetStationArea( int SectionNr, double T);
132 double GetStationDraught( int SectionNr, double T);
133 double GetStationMaxBredth(int SectionNr, double T);
134 double GetStationBredth( int SectionNr, double T);
135 unsigned int GetNumberOfStations();
136 int GetStationNr( double DistanceFromZeroStation );
137 double GetStationPosition( int SectionNr );
138 void GetStationLewisData(int SectionNr, double B, double T, double &LewisA1, double &LewisA3, double &LewisScaleFactor );
139 int GetStationSkegPoint( int SectionNr);
140
141 double GetStationInstentaneousDraught( int SecitonNr );
142 void GetVertexGlobalPosition( int vertex, Eigen::Vector3d &vertexpos );
143 //void MakeHull();
144 void MakeHull2();
145
146 void AddToHull( std::vector<Eigen::Vector3d> &side1, std::vector<Eigen::Vector3d> side2 , bool mirror = true);
147
148 void SetInterpolationParameters(double HullTop,double HullBottom,double VerticalStep,double HorizontalStep);
149
150 virtual double GetParam(std::string p );
151
152 struct MainDimensions Main;
153 struct HullGeometry Geomtery;
154
155 protected:
156
157 Eigen::Vector3d r;
158 Eigen::Quaterniond q;
159
160 double HullBottom;
161 double HullTop;
162 double HullVerticalStep;
163 double HullHorizontalStep;
164
165 static bool CompareSections( struct Section const &lhs, struct Section const &rhs );
166
167 std::vector< struct Section > Sections;
168 std::map<std::string,double> param;
169
170 };
171}
172#endif // CHullData_h__
Definition: HullData.h:14
Simple waypoint object.
Definition: CableAttach.h:16
Definition: HullData.h:78
Definition: HullData.h:90
Definition: HullData.h:61
Definition: HullData.h:18