CONFIG LIB  1.5
Configuration Files Library (by TGG 2020)
panel.cpp
1 /*********************************************************************/
2 /* */
3 /* Panukl package - (C) TGG 2002 */
4 /* Config files library - (C) TGG 2015 */
5 /* */
6 /*********************************************************************/
7 /* Warszawa, 2011 */
8 /*********************************************************************/
9 /* */
10 /* File: panel.cpp */
11 /* */
12 /* Author: T.Grabowski */
13 /* */
14 /* Contents - PANEL class */
15 /* */
16 /* Last update: 6.04.2020 */
17 /* */
18 /*********************************************************************/
19 /* */
20 
21 #include "panel.h"
22 
23 PANEL::PANEL( void )
24 {
25  Clear();
26 }
27 
29 {
30  Clear();
31  PutTo( vP1, vP2, vP3, vP4 );
32 }
33 
34 PANEL::~PANEL( void )
35 {
36  Clear();
37 }
38 
39 void PANEL::Clear( void )
40 {
41  P1 = VECTOR_3__E0();
42  P2 = VECTOR_3__E0();
43  P3 = VECTOR_3__E0();
44  P4 = VECTOR_3__E0();
45  PP[0] = &P1;
46  PP[1] = &P2;
47  PP[2] = &P3;
48  PP[3] = &P4;
49  strcpy(ElSet, "");
50  Type = 0;
51  Pc = VECTOR_3__E0();
52  IdP1 = IdP2 = IdP3 = IdP4 = IdP5 = IdP6 = IdP7 = IdP8 = 0;
53 }
54 
56 {
57  P1 = vP1;
58  P2 = vP2;
59  P3 = vP3;
60  P4 = vP4;
61  Center();
62 }
63 
65 {
66  PutTo( vP1, vP2, vP3, vP4 );
67  P1.y *= -1.;
68  P2.y *= -1.;
69  P3.y *= -1.;
70  P4.y *= -1.;
71  Center();
72 }
73 
75 {
76  PutTo( vP1, vP2, vP3, vP4 );
77  P1.y = 0.;
78  P2.y = 0.;
79  P3.y = 0.;
80  P4.y = 0.;
81  Center();
82 }
83 
84 void PANEL::Mirror( void )
85 {
86  VECTOR_3D P;
87  P = P1; P1 = P4; P4 = P;
88  P = P2; P2 = P3; P3 = P;
89  P1.y *= -1.;
90  P2.y *= -1.;
91  P3.y *= -1.;
92  P4.y *= -1.;
93  Center();
94 }
95 
96 double PANEL::S( void )
97 {
98  double SS2 = ((P1-P2)%(P3-P2)).Len();
99  SS2 += ((P1-P4)%(P3-P4)).Len();
100  if( SS2 < fabs(1.e-9) )SS2 = 0.;
101  return 0.5 * SS2;
102 }
103 
104 void PANEL::Center( void )
105 {
106  Pc = 0.25*(P1 + P2 + P3 + P4);
107 }
108 
109 void PANEL::Vout( FILE *ff )
110 {
111  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P1.x, P1.y, P1.z );
112  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P2.x, P2.y, P2.z );
113  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P3.x, P3.y, P3.z );
114  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P4.x, P4.y, P4.z );
115 }
116 
117 void PANEL::Iout( FILE *ff )
118 {
119  fprintf( ff, "%d %d %d %d", IdP1, IdP2, IdP3, IdP4 );
120 }
121 
122 void PANEL::VoutR( FILE *ff )
123 {
124  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P4.x, -P4.y, P4.z );
125  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P3.x, -P3.y, P3.z );
126  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P2.x, -P2.y, P2.z );
127  fprintf( ff, "% 12.7f % 12.7f % 12.7f", P1.x, -P1.y, P1.z );
128 }
129 
130 void PANEL::ELset(const char *WingFus, char *Struct, int StructNr)
131 {
132  sprintf(ElSet, "%s_%s_%i", WingFus, Struct, StructNr);
133 }
134 
136 {
137  if(IdP1 != IdP2)
138  {
139  if(IdP1 != IdP4)
140  {
141  if(IdP2 != IdP3)
142  {
143  if(IdP3 != IdP4)
144  {
145  Type = 0; // quadrilateral panel
146  }
147  else Type = 4; // triangle P3=P4 -> P4 to remove
148  }
149  else Type = 3; // triangle P2=P3 -> P3 to remove
150  }
151  else Type = 4; // triangle P1=P4 -> P4 to remove
152  }
153  else Type = 2; // triangle P1=P2 -> P2 to remove
154 }
PANEL::ELset
void ELset(const char *WingFus, char *Struct, int StructNr)
sets panel info for FEM analysis to string ELSet
Definition: panel.cpp:130
PANEL::PutTo_0
void PutTo_0(VECTOR_3D vP1, VECTOR_3D vP2, VECTOR_3D vP3, VECTOR_3D vP4)
sets the corners (ccordinates) and changes the coordinate to zero
Definition: panel.cpp:74
VECTOR_3D::z
double z
z coordinate
Definition: vector3d.h:38
PANEL::ElSet
char ElSet[256]
info for FEM analysis
Definition: panel.h:42
PANEL::S
double S(void)
returns the panel area
Definition: panel.cpp:96
PANEL::P4
VECTOR_3D P4
the coordinates of the 4th corner of the panel
Definition: panel.h:59
PANEL::PutTo_n
void PutTo_n(VECTOR_3D vP1, VECTOR_3D vP2, VECTOR_3D vP3, VECTOR_3D vP4)
sets the corners (ccordinates) and changes the sign of y coordinate
Definition: panel.cpp:64
PANEL::VoutR
void VoutR(FILE *ff)
prints corners mirror (with respect to xz plane) coordinates to stream ff
Definition: panel.cpp:122
PANEL::IdP4
int IdP4
No. of the 4th corner of the panel.
Definition: panel.h:49
PANEL::IdP7
int IdP7
No. of the mid-point of the 3rd side of the panel.
Definition: panel.h:53
VECTOR_3D::x
double x
x coordinate
Definition: vector3d.h:38
PANEL::IdP8
int IdP8
No. of the mid-point of the 4th side of the panel.
Definition: panel.h:54
PANEL::P1
VECTOR_3D P1
the coordinates of the 1st corner of the panel
Definition: panel.h:56
PANEL::IdP2
int IdP2
No. of the 2nd corner of the panel.
Definition: panel.h:47
VECTOR_3__E0
VECTOR_3D VECTOR_3__E0(void)
returns vector (0,0,0)
Definition: vector3d.cpp:360
VECTOR_3D
Vector 3D class - vector manipulation.
Definition: vector3d.h:34
PANEL::IdP5
int IdP5
No. of the mid-point of the 1st side of the panel.
Definition: panel.h:51
PANEL::IdP1
int IdP1
No. of the 1st corner of the panel.
Definition: panel.h:46
PANEL::CheckType
void CheckType(void)
checks the type of panel
Definition: panel.cpp:135
PANEL::P2
VECTOR_3D P2
the coordinates of the 2nd corner of the panel
Definition: panel.h:57
PANEL::IdP6
int IdP6
No. of the mid-point of the 2nd side of the panel.
Definition: panel.h:52
PANEL::IdP3
int IdP3
No. of the 3rd corner of the panel.
Definition: panel.h:48
PANEL::Clear
void Clear(void)
clears and assignes pointers to corners
Definition: panel.cpp:39
PANEL::Vout
void Vout(FILE *ff)
prints corners coordinates to stream ff
Definition: panel.cpp:109
PANEL::PP
VECTOR_3D * PP[4]
pointers to four corners (VECTOR_3D) of the panel
Definition: panel.h:63
PANEL::Type
int Type
type of panel: 0 - rectangle; 2, 3, 4 - triangle ( corner no. Type is doubled )
Definition: panel.h:44
PANEL::Center
void Center(void)
calculates the coordinates (Pc) of the central point of the panel
Definition: panel.cpp:104
PANEL::PutTo
void PutTo(VECTOR_3D vP1, VECTOR_3D vP2, VECTOR_3D vP3, VECTOR_3D vP4)
sets the corners (coordinates)
Definition: panel.cpp:55
PANEL::Mirror
void Mirror(void)
makes a mirror with respect to xz plane, saves the order (CW or CCW) of corners
Definition: panel.cpp:84
PANEL::Pc
VECTOR_3D Pc
the coordinates of the central point of the panel
Definition: panel.h:61
PANEL::P3
VECTOR_3D P3
the coordinates of the 3rd corner of the panel
Definition: panel.h:58
PANEL::Iout
void Iout(FILE *ff)
prints corners numbers to stream ff
Definition: panel.cpp:117
panel.h
PANEL::PANEL
PANEL(void)
default constructor
Definition: panel.cpp:23
VECTOR_3D::y
double y
y coordinate
Definition: vector3d.h:38