CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
mass_data.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) JM 2020 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2020 */
7/*********************************************************************/
8/* */
9/* File: geom_data.h */
10/* */
11/* Author: J.Mieloszyk, modif. T.Grabowski */
12/* */
13/* Contents - data of basic geometry objects (class) */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include "mass_data.h"
21
22using namespace std;
23
24MASS_OBJECT_DATA::MASS_OBJECT_DATA( void ){ Clean (); }
25
26MASS_OBJECT_DATA::~MASS_OBJECT_DATA( void ){}
27
29{
30 Active = 1;
31
32 Name = "-";
33 Type = M_POINT;
34 Color = 3; // FL_YELLOW
35
36 Base.GetFrom(0., 0., 0.);
37 Tip.GetFrom (0., 0., 1.);
38 Side.GetFrom(1., 0., 0.);
39
40 R = 0.;
41 H = 0.;
42 a = 0.;
43 b = 0.;
44 c = 0.;
45 th = 0.;
46
47 m = 0.;
48 ro = 0.;
49 Vol = 0.;
50
52}
53
54int MASS_OBJECT_DATA::CheckData(bool CheckMassFlag)
55{
56 if(m == 0 && CheckMassFlag == 1) return 1;
57
58 //if(Base == Tip) return 2;
59 //if(Base == Side) return 3;
60 if(Tip == Side) return 4;
61
62 if(Type != M_POINT)
63 {
64 if(Type == SPHERE || Type == CYLINDER || Type == TUBE || Type == CONE || Type == DISC)
65 if(R == 0) return 5;
66
67 if(Type == TUBE)
68 {
69 if(r == 0) return 6;
70 if(r >= R) return 9;
71 }
72
73 if(Type == CYLINDER || Type == TUBE || Type == CONE)
74 if(H == 0) return 7;
75
76 if(Type == CUBOID)
77 if(a == 0 || b == 0 || c == 0) return 8;
78 }
79
80 VECTOR_3D v1 = Tip;// - Base;
81 v1.Normalize();
82 VECTOR_3D v2 = Side;// - Base;
83 v2.Normalize();
84 if(v1 == v2) return 10;
85
86 return 0;
87}
88
90{
91 //SELF
92 ks = Tip; // z - direction
93 ks.Normalize();
94
95 is = Side; // x - direction
96 is.Normalize();
97
98 if(is == ks)
99 {
100 clog << "is == ks !!!" << endl << endl;
101 return 1;
102 }
103
104 js = ks % is; //cross product of versors k & i, y - direction
105 js.Normalize();
106
107 //LOCAL
108 il.GetFrom(1, 0, 0);
109 jl.GetFrom(0, 1, 0);
110 kl.GetFrom(0, 0, 1);
111
112 //GLOBAL
113 ig = il;
114 jg = jl;
115 kg = kl;
116
117 return 0;
118}
119
120void MASS_OBJECT_DATA::Read(std::ifstream &in)
121{
122 int Id;
123 string sVal;
124
125 in >> Id >> Active >> Name >> sVal;
126
127 Type = M_POINT;
128 if(sVal.compare("M_POINT") == 0) Type = M_POINT;
129 else if(sVal.compare("SPHERE") == 0) Type = SPHERE;
130 else if(sVal.compare("CUBOID") == 0) Type = CUBOID;
131 else if(sVal.compare("CYLINDER") == 0) Type = CYLINDER;
132 else if(sVal.compare("TUBE") == 0) Type = TUBE;
133 else if(sVal.compare("CONE") == 0) Type = CONE;
134 else if(sVal.compare("DISC") == 0) Type = DISC;
135
136 in >> m >> ro >> Vol;
137
138 in >> CG_g.x >> CG_g.y >> CG_g.z;
139
140 in >> I_l.xx >> I_l.yy >> I_l.zz;
141 in >> I_l.xy >> I_l.yz >> I_l.zx;
142
143 I_l.yx = I_l.xy;
144 I_l.zy = I_l.yz;
145 I_l.xz = I_l.zx;
146
147 if(Type == M_POINT) //For arbitrary assigned moments of inertia (no rotation allowed!)
148 {
149 I_s.xx = I_l.xx;
150 I_s.yy = I_l.yy;
151 I_s.zz = I_l.zz;
152
153 I_s.yx = I_s.xy = I_l.xy;
154 I_s.zy = I_s.yz = I_l.yz;
155 I_s.xz = I_s.zx = I_l.zx;
156 }
157
158 in >> Base.x >> Base.y >> Base.z;
159 in >> Tip.x >> Tip.y >> Tip.z;
160 in >> Side.x >> Side.y >> Side.z;
161
162 in >> R >> r >> H >> a >> b >> c >> th;
163
164 in >> Color;
165}
166
167void MASS_OBJECT_DATA::Write(std::ofstream &out, int Id)
168{
169 out << setw(4) << std::left << Id;
170 out << setw(8) << std::left << Active;
171 out << setw(80) << std::left << Name;
172
173 if(Name.length() >= 80)
174 out << " ";
175
176 switch(Type)
177 {
178 case M_POINT : out << setw(12) << std::left << "POINT"; break;
179 case SPHERE : out << setw(12) << std::left << "SPHERE"; break;
180 case CUBOID : out << setw(12) << std::left << "CUBOID"; break;
181 case CYLINDER : out << setw(12) << std::left << "CYLINDER"; break;
182 case TUBE : out << setw(12) << std::left << "TUBE"; break;
183 case CONE : out << setw(12) << std::left << "CONE"; break;
184 case DISC : out << setw(12) << std::left << "DISC"; break;
185 }
186
187 out << setw(12) << std::left << m;
188 out << setw(12) << std::left << ro;
189 out << setw(12) << std::left << Vol;
190
191 out << setw(12) << std::left << CG_g.x;
192 out << setw(12) << std::left << CG_g.y;
193 out << setw(12) << std::left << CG_g.z;
194
195 out << setw(12) << std::left << I_l.xx;
196 out << setw(12) << std::left << I_l.yy;
197 out << setw(12) << std::left << I_l.zz;
198 out << setw(12) << std::left << I_l.xy;
199 out << setw(12) << std::left << I_l.yz;
200 out << setw(12) << std::left << I_l.zx;
201
202 out << setw(12) << std::left << Base.x;
203 out << setw(12) << std::left << Base.y;
204 out << setw(12) << std::left << Base.z;
205 out << setw(12) << std::left << Tip.x;
206 out << setw(12) << std::left << Tip.y;
207 out << setw(12) << std::left << Tip.z;
208 out << setw(12) << std::left << Side.x;
209 out << setw(12) << std::left << Side.y;
210 out << setw(12) << std::left << Side.z;
211
212 out << setw(12) << std::left << R;
213 out << setw(12) << std::left << r;
214 out << setw(12) << std::left << H;
215 out << setw(12) << std::left << a;
216 out << setw(12) << std::left << b;
217 out << setw(12) << std::left << c;
218 out << setw(12) << std::left << th;
219
220 out << setw(4) << std::left << Color << endl;
221}
222
VECTOR_3D Side
Direction component
Definition mass_data.h:65
double R
external radius [m]
Definition mass_data.h:78
void Clean(void)
cleans local variables
Definition mass_data.cpp:28
double th
hollow objects wallss thicknes [m]
Definition mass_data.h:84
GeomObjType Type
type of the object (see enum GeomObjType)
Definition mass_data.h:60
MATRIX_3x3 I_s
Inertia matrix in SELF CS.
Definition mass_data.h:71
VECTOR_3D Base
Base point.
Definition mass_data.h:63
int CoordinateSystems()
computes coordinate systems versors of the mass object
Definition mass_data.cpp:89
VECTOR_3D kl
LOCAL coordinate system (versors)
Definition mass_data.h:87
void Read(std::ifstream &in)
reads single mass object
VECTOR_3D CG_g
CG position in GLOBAL CS.
Definition mass_data.h:69
MATRIX_3x3 I_l
Inertia matrix in LOCAL CS.
Definition mass_data.h:72
double ro
density [kg/m^3]
Definition mass_data.h:75
void Write(std::ofstream &out, int Id)
writes single mass object
VECTOR_3D Tip
Direction component
Definition mass_data.h:64
std::string Name
name of the object
Definition mass_data.h:59
VECTOR_3D kg
GLOBAL coordinate system (versors)
Definition mass_data.h:88
double m
mass [kg]
Definition mass_data.h:74
int CheckData(bool CheckMassFlag)
checks integrity of data of the mass object
Definition mass_data.cpp:54
double c
edge (z) length [m]
Definition mass_data.h:83
double r
internal (tube) radius [m]
Definition mass_data.h:79
double H
height [m]
Definition mass_data.h:80
bool Active
object activity flag
Definition mass_data.h:57
double b
edge (y) length [m]
Definition mass_data.h:82
double a
edge (x) length [m]
Definition mass_data.h:81
double Vol
volume [m^3]
Definition mass_data.h:76
VECTOR_3D ks
SELF coordinate system (versors)
Definition mass_data.h:86
double yy
(1,1) element
Definition matr3d.h:48
double xx
(0,0) element
Definition matr3d.h:44
double zz
(2,2) element
Definition matr3d.h:52
double yz
(1,2) element
Definition matr3d.h:49
double zx
(2,0) element
Definition matr3d.h:50
double yx
(1,0) element
Definition matr3d.h:47
double xz
(0,2) element
Definition matr3d.h:46
double xy
(0,1) element
Definition matr3d.h:45
double zy
(2,1) element
Definition matr3d.h:51
Vector 3D class - vector manipulation.
Definition vector3d.h:34
double x
x coordinate
Definition vector3d.h:38
double z
z coordinate
Definition vector3d.h:38
void GetFrom(double xp, double yp, double zp)
sets coordinates from three variables
Definition vector3d.h:65
double Normalize(void)
normalizes the vector to unit - coordiantes are divided by the vector value, returnes the vector valu...
Definition vector3d.cpp:38
double y
y coordinate
Definition vector3d.h:38
mass objects data manipulation
@ TUBE
tube (height H, internal radius r, external radius R)
Definition mass_data.h:39
@ M_POINT
mass piont (particle)
Definition mass_data.h:35
@ CYLINDER
cylinder (height H, radius R)
Definition mass_data.h:38
@ DISC
thin disc (radius R)
Definition mass_data.h:41
@ CONE
cone (height H, base radius R)
Definition mass_data.h:40
@ SPHERE
sphere (radius R)
Definition mass_data.h:36
@ CUBOID
cuboid (the edges: a,b,c)
Definition mass_data.h:37