CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
conect_data.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2015 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2015 */
7/*********************************************************************/
8/* */
9/* File: conect_data.h */
10/* */
11/* Author: T.Grabowski */
12/* */
13/* Contents - CONNECT_DATA class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include "conect_data.h"
21
22using namespace std;
23
24CONNECT_DATA::CONNECT_DATA( void )
25{
26 TypeStr[0] = (char*)"Horizontal";
27 TypeStr[1] = (char*)"Vertical";
28 TypeStr[2] = (char*)"Parallel";
29}
30
31CONNECT_DATA::~CONNECT_DATA( void )
32{
33}
34
35int CONNECT_DATA::Read( FILE *t, int typ, int version )
36{
37 if( version == 2 )
38 {
39 iTyp = typ;
40 iActive = 1;
41 }
42 else
43 {
44 char sTyp[256];
45 ReadStr( t, sTyp );
46
47 if( CompareStrings( sTyp, TypeStr[CON_H]) == true )
48 iTyp = CON_H;
49 else if( CompareStrings( sTyp, TypeStr[CON_V]) == true )
50 iTyp = CON_V;
51 else if( CompareStrings( sTyp, TypeStr[CON_P]) == true )
52 iTyp = CON_P;
53 else
54 {
55 iTyp = -1;
56 return -1;
57 }
58 //fprintf(stdout,"Conn : type %s\n", sTyp);
59 }
60
61 char name[255];
62 ReadStr ( t, name ); // description
63 ConName = string( name );
64 if( version != 2 )fscanf ( t, "%d", &iActive );
65 fscanf ( t, "%d", &CP1 );
66 fscanf ( t, "%d", &CP2 );
67 fscanf ( t, "%d", &Czeb1 );
68 fscanf ( t, "%d", &Czeb2 );
69 fscanf ( t, "%d", &Cstart );
70 fscanf ( t, "%d", &Cend );
71 ReadPar ( t, "%d", &Csurf );
72
73 return 0;
74}
75
76int CONNECT_DATA::Write( ostream &fout )
77{
78 fout << TypeStr[iTyp] << endl;
79 fout << ConName << endl;
80 fout << iActive << " ";
81 fout << CP1 << " ";
82 fout << CP2 << " ";
83 fout << Czeb1 << " ";
84 fout << Czeb2 << " ";
85 fout << Cstart << " ";
86 fout << Cend << " ";
87 fout << Csurf << endl;
88 return 0;
89}
90
int Czeb1
number of wing 1 rib connected to wing 2
Definition conect_data.h:47
int Cend
number of wing 2 longeron connected to trailing point of wing 1
Definition conect_data.h:50
int Czeb2
number of wing 2 rib connected to wing 1
Definition conect_data.h:48
int CP2
number of the 2nd wing (horizontal in case of vertical connection)
Definition conect_data.h:46
int iActive
is connection section active ( 1- active, 2 - not active)
Definition conect_data.h:44
int iTyp
Type of connection ( horizontal, vertical, parallel )
Definition conect_data.h:43
std::string ConName
Name of connection.
Definition conect_data.h:54
int Csurf
surface of wing 2 which will be modified (0-bottom or exterior, 1-top or interior)
Definition conect_data.h:51
int CP1
number of the 1st wing (vertical in case of horizontal connection)
Definition conect_data.h:45
int Cstart
number of wing 2 longeron connected to leading point of wing 1
Definition conect_data.h:49
int Read(FILE *f, int typ, int version=2)
Read connection section (within MS2 file reading)
int Write(std::ostream &fout)
Write connection section (within MS2 file saving)
static int ReadStr(FILE *stream, char *Par)
Function to read the new line from FILE "stream" and to store it in table of char "Par"....
Definition iofun.cpp:163
static int ReadPar(FILE *stream, const char *Format, void *Par)
Function to read one variable. The type of variable depends on Format, compatible with stdio library.
Definition iofun.cpp:67
static bool CompareStrings(char *str1, char *str2)
Compares two strings (str1 and str2). Returns true if they match, false otherwise.
Definition iofun.cpp:270
@ CON_H
horizontal (e.g. T tail)
@ CON_V
vertical (e.g. winglets)
@ CON_P
parallel