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