//---------------------------------------------------------------------------
#pragma hdrstop
#include <math.h>


#include "StandartProfil.h"
#include "Get_param_sect_func.h"
#include "ListConst.h"
#include "ProcExt.h"


bool Compare_group(int n_group, int type_profil);


//--------------------------------------------------
// Установить тип профиля
TStandartProfil::TStandartProfil(void)
{
   Index = -1;
}
//--------------------------------------------------
// Установить тип профиля
void  TStandartProfil::SetProfil(int index)
{
   int i, j, rc;

   double Tu_U[11][14] = TU_U;
   AnsiString Name_Tu_U[17] = NAME_TU_U;
   AnsiString Name_Tavr_Tu_U[17] = NAME_TAVR_TU_U;

   double Tu_B[28][14] = TU_B;
   AnsiString Name_Tu_B[28] = NAME_TU_B;
   AnsiString Name_Tavr_Tu_B[28] = NAME_TAVR_TU_B;

   double Tu_Sh[4][14] = TU_Sh;
   AnsiString Name_Tu_Sh[4] = NAME_TU_Sh;
   AnsiString Name_Tavr_Tu_Sh[4] = NAME_TAVR_TU_Sh;

   double Tu_D[5][14] = TU_D;
   AnsiString Name_Tu_D[5] = NAME_TU_D;
   AnsiString Name_Tavr_Tu_D[5] = NAME_TAVR_TU_D;

   double Tu_K[17][14] = TU_K;
   AnsiString Name_Tu_K[17] = NAME_TU_K;
   AnsiString Name_Tavr_Tu_K[17] = NAME_TAVR_TU_K;

   double Tu_S[3][14] = TU_S;
   AnsiString Name_Tu_S[3] = NAME_TU_S;
   AnsiString Name_Tavr_Tu_S[3] = NAME_TAVR_TU_S;

   // Старый швеллер
   double Channel[18][16] = CHANNEL_SECT;
   double Channel_Sector[18][8] = CHANNEL_SECTOR;
   AnsiString Name_Channel[18] = NAME_CHANNEL;

   double Gost_G57837DB[N_GOST_G57837DB][14] = GOST_G57837DB;
   AnsiString Name_Gost_G57837DB[N_GOST_G57837DB] = NAME_GOST_G57837DB;
   AnsiString Name_Tavr_DBT[N_GOST_G57837DB] = NAME_TAVR_DBT;

   double Gost_G57837_K[N_GOST_G57837_K][14] = GOST_G57837_K;
   AnsiString Name_Gost_G57837_K[N_GOST_G57837_K] = NAME_GOST_G57837_K;
   AnsiString Name_Tavr_KT[N_GOST_G57837_K] = NAME_TAVR_KT;

   double Gost_G57837_B[N_GOST_G57837_B][14] = GOST_G57837_B;
   AnsiString Name_Gost_G57837_B[N_GOST_G57837_B] = NAME_GOST_G57837_B;
   AnsiString Name_Tavr_BT[N_GOST_G57837_B] = NAME_TAVR_BT;

   double Gost_G57837Sh[N_GOST_G57837Sh][14] = GOST_G57837Sh;
   AnsiString Name_Gost_G57837Sh[N_GOST_G57837Sh] = NAME_GOST_G57837Sh;
   AnsiString Name_Tavr_ShT[N_GOST_G57837Sh] = NAME_TAVR_ShT;

   double Gost_G57837_S[N_GOST_G57837_S][14] = GOST_G57837_S;
   AnsiString Name_Gost_G57837_S[N_GOST_G57837_S] = NAME_GOST_G57837_S;
   AnsiString Name_Tavr_ST[N_GOST_G57837_S] = NAME_TAVR_ST;

   double Gost_G57837DK[N_GOST_G57837DK][14] = GOST_G57837DK;
   AnsiString Name_Gost_G57837DK[N_GOST_G57837DK] = NAME_GOST_G57837DK;
   AnsiString Name_Tavr_DKT[N_GOST_G57837DK] = NAME_TAVR_DKT;

   double Channel_Paral[][16] = CHANNEL_PARAL;
   AnsiString Name_Channel_Paral[] = NAME_CHANNEL_PARAL;

   double Channel_Slope[][16] = CHANNEL_SLOPE;
   AnsiString Name_Channel_Slope[] = NAME_CHANNEL_SLOPE;

   n_Profil = 0;

   Index = index;

   for (i=0; i<100; i++) {
	 for (j=0; j<16; j++) {
		Gost_Profil[i][j] = 0;
	 }
	 for (j=0; j<8; j++) {
		   Gost_SectorProfil[i][j] = 0;
	 }
   }
   bool flag_unit = true;  // флаг изменения единиц измерения
   switch (index) {
   case typeTU_U:   // Двутавры по ТУ

	 n_Profil = N_TU_U;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tu_U[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_U[i][j];
	   }
	 }
   break;
   case typeTU_B:

	 n_Profil = N_TU_B;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tu_B[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_B[i][j];
	   }
	 }
   break;
   case typeTU_Sh:

	 n_Profil = N_TU_Sh;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tu_Sh[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_Sh[i][j];
	   }
	 }
   break;
   case typeTU_D:

	 n_Profil = N_TU_D;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tu_D[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_D[i][j];
	   }
	 }
   break;
   case typeTU_K:

	 n_Profil = N_TU_K;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tu_K[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_K[i][j];
	   }
	 }
   break;
   case typeTU_S:

	 n_Profil = N_TU_S;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tu_S[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_S[i][j];
	   }
	 }
   break;
   case typeCHANNEL:
	 n_Profil = N_CHANNEL_SECT;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Channel[i];
	   for (j=0; j<16; j++) {
		   Gost_Profil[i][j] = Channel[i][j];
	   }
	   for (j=0; j<8; j++) {
		   Gost_SectorProfil[i][j] = Channel_Sector[i][j];
	   }
	 }
   break;
   case typeCHANNEL_PARAL:
	 n_Profil = N_CHANNEL_PARAL;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Channel_Paral[i];
	   for (j=0; j<16; j++) {
		   Gost_Profil[i][j] = Channel_Paral[i][j];
	   }
	 }
   // Преобразование см в мм
	 for (i=0; i<n_Profil; i++) {
	   Gost_Profil[i][parAREA_CHANNEL] *= 100;
	   Gost_Profil[i][parIZZ_CHANNEL] *= 10000;
	   Gost_Profil[i][parIZZ_CHANNEL+1] *= 1000;
	   Gost_Profil[i][parIZZ_CHANNEL+2] *= 10;
	   Gost_Profil[i][parIZZ_CHANNEL+3] *= 1000;
	   Gost_Profil[i][parIZZ_CHANNEL+4] *= 10000;
	   Gost_Profil[i][parIZZ_CHANNEL+5] *= 1000;
	   Gost_Profil[i][parIZZ_CHANNEL+6] *= 10;
	   Gost_Profil[i][parIZZ_CHANNEL+7] *= 10;
	 }                                               
	 flag_unit = false;
   break;
   case typeCHANNEL_SLOPE:
	 n_Profil = N_CHANNEL_SLOPE;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Channel_Slope[i];
	   for (j=0; j<16; j++) {
		   Gost_Profil[i][j] = Channel_Slope[i][j];
	   }
	 }
   // Преобразование см в мм
	 for (i=0; i<n_Profil; i++) {
	   Gost_Profil[i][parAREA_CHANNEL] *= 100;
	   Gost_Profil[i][parIZZ_CHANNEL] *= 10000;
	   Gost_Profil[i][parIZZ_CHANNEL+1] *= 1000;
	   Gost_Profil[i][parIZZ_CHANNEL+2] *= 10;
	   Gost_Profil[i][parIZZ_CHANNEL+3] *= 1000;
	   Gost_Profil[i][parIZZ_CHANNEL+4] *= 10000;
	   Gost_Profil[i][parIZZ_CHANNEL+5] *= 1000;
	   Gost_Profil[i][parIZZ_CHANNEL+6] *= 10;
	   Gost_Profil[i][parIZZ_CHANNEL+7] *= 10;
	 }
	 flag_unit = false;
   break;
   case typeGOST_G57837_B:
	  n_Profil = N_GOST_G57837_B;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Gost_G57837_B[i];
	   for (j=0; j<14; j++) {
		 Gost_Profil[i][j] = Gost_G57837_B[i][j];
	   }
	 }
   break;
   case typeGOST_G57837Sh:
	  n_Profil = N_GOST_G57837Sh;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Gost_G57837Sh[i];
	   for (j=0; j<14; j++) {
		 Gost_Profil[i][j] = Gost_G57837Sh[i][j];
	   }
	 }
   break;
   case typeGOST_G57837_K:
	  n_Profil = N_GOST_G57837_K;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Gost_G57837_K[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837_K[i][j];
	   }
	 }
   break;
   case typeGOST_G57837DB:   // Дополнительные балочные
	  n_Profil = N_GOST_G57837DB;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Gost_G57837DB[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837DB[i][j];
	   }
	 }
   break;
   case typeGOST_G57837_S:
	 n_Profil = N_GOST_G57837_S;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Gost_G57837_S[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837_S[i][j];
	   }
	 }
  break;
   case typeGOST_G57837DK:
	 n_Profil = N_GOST_G57837DK;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Gost_G57837DK[i];
	   for (j=0; j<14; j++) {
		  Gost_Profil[i][j] = Gost_G57837DK[i][j];
	   }
	 }
   break;
   // Тавры
   case typeTAVR_BT:
	 n_Profil = N_GOST_G57837_B;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_BT[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837_B[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_ST:
	 n_Profil = N_GOST_G57837_S;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_ST[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837_S[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_DBT:
	  n_Profil = N_GOST_G57837DB;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_DBT[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837DB[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_DKT:
	 n_Profil = N_GOST_G57837DK;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_DKT[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837DK[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_KT:
	 n_Profil = N_GOST_G57837_K;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_KT[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837_K[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_ShT:
	 n_Profil = N_GOST_G57837Sh;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_ShT[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Gost_G57837Sh[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_TU_UT:   // Двутавры по ТУ

	 n_Profil = N_TU_U;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tu_U[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_U[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_TU_BT:

	 n_Profil = N_TU_B;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_Tu_B[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_B[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_TU_ShT:

	 n_Profil = N_TU_Sh;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_Tu_Sh[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_Sh[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_TU_DT:

	 n_Profil = N_TU_D;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_Tu_D[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_D[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_TU_KT:

	 n_Profil = N_TU_K;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_Tu_K[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_K[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   case typeTAVR_TU_ST:

	 n_Profil = N_TU_S;
	 for (i=0; i<n_Profil; i++) {
	   Name_Profil[i] = Name_Tavr_Tu_S[i];
	   for (j=0; j<14; j++) {
		   Gost_Profil[i][j] = Tu_S[i][j];
	   }
	 }
	 flag_unit = false;
	 Convert_To_Tavr();
   break;
   default:
	 #ifdef EMBRAC
	 i = Application->MessageBox((L"Ошибочный тип профиля двутавра "+IntToStr(index)).c_str(), L"SetProfil", MB_OK | MB_ICONERROR);
	 #else
	 i = Application->MessageBox(("Ошибочный тип профиля двутавра "+IntToStr(index)).c_str(), "SetProfil", MB_OK | MB_ICONERROR);
	 #endif
	 n_Profil = 0;
	 return;
   }
   // Проверка единиц измерения радиусов инерции
   double i_mult;
   double i_test = sqrt(Gost_Profil[0][6]/Gost_Profil[0][4]);
   if (i_test/Gost_Profil[0][9] > 9.0)
	 i_mult = 10.0;
   else
	 i_mult = 1.0;
   if (flag_unit) {
   // Преобразование см в мм
	 for (i=0; i<n_Profil; i++) {
	   Gost_Profil[i][4] *= 100;
	   Gost_Profil[i][6] *= 10000;
	   Gost_Profil[i][7] *= 1000;
	   Gost_Profil[i][8] *= 1000;
	   Gost_Profil[i][9] *= i_mult;
	   Gost_Profil[i][10] *= 10000;
	   Gost_Profil[i][11] *= 1000;
	   Gost_Profil[i][12] *= i_mult;
	 }
	 for (i=0; i<n_Profil; i++) {
	   Gost_SectorProfil[i][0] *= 10;
	   Gost_SectorProfil[i][1] *= 1e6;
	   Gost_SectorProfil[i][2] *= 100;
	   Gost_SectorProfil[i][3] *= 100;
	   Gost_SectorProfil[i][4] *= 1000;
	   Gost_SectorProfil[i][5] *= 1000;
	   Gost_SectorProfil[i][6] *= 10000;
	   Gost_SectorProfil[i][7] *= 10;
	 }
   }

}
//--------------------------------------------------
// Преобразовать параметры двутавра в параметры тавра
void  TStandartProfil::Convert_To_Tavr() {
	 double h, tf, b, tw, r;
	 double Aw, Af, Ar, At, yw, yf, yr, yct;
	 double Iy0, Iyd, Iy;
	 int i;
   // Проверка единиц измерения радиусов инерции
	 double i_mult;
	 double i_test = sqrt(Gost_Profil[0][6]/Gost_Profil[0][4]);
	 if (i_test/Gost_Profil[0][9] > 9.0)
	   i_mult = 10.0;
	 else
	   i_mult = 1.0;
// Преобразование см в мм
	 for (i=0; i<n_Profil; i++) {
	   Gost_Profil[i][4] *= 100;
	   Gost_Profil[i][6] *= 10000;
	   Gost_Profil[i][7] *= 1000;
	   Gost_Profil[i][8] *= 1000;
	   Gost_Profil[i][9] *= i_mult;
	   Gost_Profil[i][10] *= 10000;
	   Gost_Profil[i][11] *= 1000;
	   Gost_Profil[i][12] *= i_mult;
	   /* тест
	   h = 388.6;
	   b = 300;
	   tw = 9.5;
	   tf = 14.2;
	   At = 12400/2;
	   Iy0 = 348500000/2; r = 22;
	   */

	   h = Gost_Profil[i][0]; // высота стенки двутавра
	   tf = Gost_Profil[i][3]; // толщина полки двутавра
	   tw = Gost_Profil[i][2]; // толщина стенки двутавра
	   b = Gost_Profil[i][1]; // ширина полки двутавра
	   r = Gost_Profil[i][13]; // радиус стенки двутавра
	   Iy0 = 0.5*Gost_Profil[i][6]; // половина момента инерции двутавра

	   Aw = tw*(h/2 - tf);  // площадь половины стенки
	   Af = tf*b;
	   Ar = r*r - PI_*r*r/4;

	   yw = 0.5*(h/2 - tf) + tf;
	   yf = 0.5*tf;
	   yr = r - r*2/(3*(4 - PI_)) + tf;

	   At = Aw + Af + 2*Ar;
	   yct = (Aw*yw + Af*yf + 2*Ar*yr)/At;

	   Iyd = At*(h/2 - yct)*(h/2 - yct);

	   Iy = Iy0 - Iyd;
	 // ДВУТАВР: 0- h, 1-b, 2-s, 3-t, 4-A, 5-P, 6-Iy, 7-Wy, 8-Sy, 9-iy, 10-Iz, 11-Wz, 12-iz, 13-R

	   Gost_Profil[i][0] *= 0.5;
	   Gost_Profil[i][4] *= 0.5;
	   Gost_Profil[i][5] *= 0.5;
	   Gost_Profil[i][10] *= 0.5;

	   Gost_Profil[i][6] = Iy;
	   Gost_Profil[i][7] = Iy/yct;
	   Gost_Profil[i][9] = sqrt(Iy/Gost_Profil[i][4]);
	   Gost_Profil[i][14] = yct;
	   Gost_Profil[i][8] = Gost_Profil[i][4]*(yct - tf);   // Статический момент для стенки
	 }
}
//--------------------------------------------------
// Установить тип профиля трубы
void  TStandartProfil::SetProfil_Tube(int index)
// index - тип профиля трубы или уголка
{
   int i, j, k, rc;
   int n_p, n_p1, n_p2, n_p3;
   double h0, b0;


   double Square_Tube[155][8] = SQUARE_PROF;
   double Square_Tube_N[128][11] = SQUARE_PROF_N;
   double Square_Tube1_N[109][11] = SQUARE_PROF1_N;


   double Rect_Tube[118][11] = RECT_PROF;
   double Rect_Tube1[136][11] = RECT_PROF1;
   double Rect_Tube2[170][11] = RECT_PROF2;
   // Всего 624
   double Rect_Tube_N[186][15] = RECT_PROF_N;

   double Rect_Tube1_N[174][15] = RECT_PROF1_N;

   double Rect_Tube2_N[166][15] = RECT_PROF2_N;

   double Rect_Tube3_N[98][15] = RECT_PROF3_N;
   // Всего 318
   double Circ_Tube[152][8] = CIRC_PROF;
   double Circ_Tube1[166][8] = CIRC_PROF1;

   double Ugol_ravnop[][17] = CORNER_EQU_PROF;
   double Ugol_noravnop[][20] = CORNER_NOEQU_PROF;

   double Ugol_ravnop_gnut[][15] = CORNER_EQU_BEND;
   double Ugol_noravnop_gnut[][21] = CORNER_NOEQU_BEND;

   double Channel_bent[][16] = CHANNEL_BEND;


   n_Profil = 0;

   Index = index;

   for (i=0; i<700; i++) {
	 for (j=0; j<30; j++) {
        Tube_Profil[i][j] = 0;
     }
   }
   Type_profil_tube = index;

   switch (index) {
   case typeRECT:   // Прямоугольное сечение

	 n_p = N_RECT_PROF_N;
	 for (i=0; i<n_p; i++) {
	   for (j=0; j<15; j++) {
		   Tube_Profil[i][j] = Rect_Tube_N[i][j];
	   }
	 }
	 n_p1 = N_RECT_PROF1_N;
     for (i=0; i<n_p1; i++) {
       for (j=0; j<15; j++) {
		   Tube_Profil[i+n_p][j] = Rect_Tube1_N[i][j];
       }
     }
	 n_p2 = N_RECT_PROF2_N;
	 for (i=0; i<n_p2; i++) {
	   for (j=0; j<15; j++) {
		   Tube_Profil[i+n_p+n_p1][j] = Rect_Tube2_N[i][j];
	   }
	 }
	 n_p3 = N_RECT_PROF3_N;
	 for (i=0; i<n_p3; i++) {
	   for (j=0; j<15; j++) {
		   Tube_Profil[i+n_p+n_p1+n_p2][j] = Rect_Tube3_N[i][j];
	   }
	 }
	 n_Profil_Tube = n_p + n_p1 + n_p2 + n_p3;
	 for (i=0; i<n_Profil_Tube; i++) {
	   Tube_Profil[i][6] *= 100;
	   Tube_Profil[i][8] *= 10000;
	   Tube_Profil[i][9] *= 1000;
	   Tube_Profil[i][10] *= 10;
	   Tube_Profil[i][11] *= 10000;
	   Tube_Profil[i][12] *= 1000;
	   Tube_Profil[i][13] *= 10;
	 }
	 Index_thick_tube = 2;
	 h0 = b0 = 0;
	 k = 0;
	 for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] || b0 != Tube_Profil[i][1]) {
		 h0 = Tube_Profil[i][0];
		 b0 = Tube_Profil[i][1];
		 Name_Profil[k] = FloatToStr(h0)+"*"+FloatToStr(b0);
		 k++;
	   }
	 }
	 n_Profil = k;

   break;
   case typeSQUARE:    // Квадратное сечение
	 n_p = N_SQUARE_PROF_N;
     for (i=0; i<n_p; i++) {
       for (j=0; j<11; j++) {
           Tube_Profil[i][j] = Square_Tube_N[i][j];
       }
     }
     n_p1 = N_SQUARE_PROF1_N;
	 for (i=0; i<n_p1; i++) {
       for (j=0; j<11; j++) {
		   Tube_Profil[i+n_p][j] = Square_Tube1_N[i][j];
       }
     }
	 n_Profil_Tube = n_p + n_p1;
     for (i=0; i<n_Profil_Tube; i++) {
       Tube_Profil[i][5] *= 100;
       Tube_Profil[i][7] *= 10000;
       Tube_Profil[i][8] *= 1000;
       Tube_Profil[i][9] *= 10;
	 }
	 Index_thick_tube = 2;
	 h0 = b0 = 0;
     k = 0;
     for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] || b0 != Tube_Profil[i][1]) {
		 h0 = Tube_Profil[i][0];
         b0 = Tube_Profil[i][1];
		 Name_Profil[k] = FloatToStr(h0)+"*"+FloatToStr(b0);
         k++;
	   }
     }
	 n_Profil = k;

   break;
   case typeCIRC:    // Круглое сечение
	 n_p = N_CIRC_PROF;
	 for (i=0; i<n_p; i++) {
	   for (j=0; j<8; j++) {
		   Tube_Profil[i][j] = Circ_Tube[i][j];
	   }
	 }
	 n_p1 = N_CIRC_PROF1;
	 for (i=0; i<n_p1; i++) {
	   for (j=0; j<8; j++) {
		   Tube_Profil[i+n_p][j] = Circ_Tube1[i][j];
	   }
	 }
	 n_Profil_Tube = n_p + n_p1;
	 for (i=0; i<n_Profil_Tube; i++) {
	   Tube_Profil[i][2] *= 100;
	   Tube_Profil[i][4] *= 10000;
	   Tube_Profil[i][5] *= 1000;
	   Tube_Profil[i][6] *= 10;
	 }
	 Index_thick_tube = 1;
	 h0 = 0;
	 k = 0;
	 for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] ) {
		 h0 = Tube_Profil[i][0];
		 Name_Profil[k] = FloatToStr(h0);
		 k++;
	   }
	 }
	 n_Profil = k;
   break;
   case typeCORNER_EQU:    // Уголок равнополочный
	 n_p = N_CORNER_EQU_PROF;
	 for (i=0; i<n_p; i++) {
	   for (j=0; j<17; j++) {
		   Tube_Profil[i][j] = Ugol_ravnop[i][j];
	   }
	 }
	 n_Profil_Tube = n_p;
	 for (i=0; i<n_Profil_Tube; i++) {
	   Tube_Profil[i][0] *= 10;
	   Tube_Profil[i][5] *= 100;
	   Tube_Profil[i][6] *= 10000;
	   Tube_Profil[i][7] *= 1000;
	   Tube_Profil[i][8] *= 10;
	   Tube_Profil[i][9] *= 10000;
	   Tube_Profil[i][10] *= 1000;
	   Tube_Profil[i][11] *= 10000;
	   Tube_Profil[i][12] *= 1000;
	   Tube_Profil[i][13] *= 10;
	   Tube_Profil[i][14] *= 10000;
	   Tube_Profil[i][15] *= 10;
	 }
	 Index_thick_tube = 2;
	 h0 = 0;
	 k = 0;
	 for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] ) {
		 h0 = Tube_Profil[i][0];
		 Name_Profil[k] = FloatToStr(h0)+"*"+FloatToStr(h0);
		 k++;
	   }
	 }
	 n_Profil = k;
   break;
   case typeCORNER_EQU_B:    // Уголок гнутый равнополочный
	 n_p = N_CORNER_EQU_BEND;
	 for (i=0; i<n_p; i++) {
	   for (j=0; j<15; j++) {
		   Tube_Profil[i][j] = Ugol_ravnop_gnut[i][j];
	   }
	 }
	 n_Profil_Tube = n_p;
	 for (i=0; i<n_Profil_Tube; i++) {
	   Tube_Profil[i][5] *= 100;
	   Tube_Profil[i][6] *= 10000;
	   Tube_Profil[i][7] *= 10;
	   Tube_Profil[i][8] *= 10000;
	   Tube_Profil[i][9] *= 10;
	   Tube_Profil[i][10] *= 10000;
	   Tube_Profil[i][11] *= 10;
	   Tube_Profil[i][12] *= 10000;
	   Tube_Profil[i][13] *= 10;
	 }
	 Index_thick_tube = 2;   // индекс в массиве данных, по которому находится толщина трубы или уголка
	 h0 = 0;
	 k = 0;
	 for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] ) {
		 h0 = Tube_Profil[i][0];
		 Name_Profil[k] = FloatToStr(h0)+"*"+FloatToStr(h0);
		 k++;
	   }
	 }
	 n_Profil = k;
   break;
   case typeCORNER_NOEQU:    // Уголок неравнополочный
	 n_p = N_CORNER_NOEQU_PROF;
	 for (i=0; i<n_p; i++) {
	   for (j=0; j<20; j++) {
		   Tube_Profil[i][j] = Ugol_noravnop[i][j];
	   }
	 }
	 n_Profil_Tube = n_p;
	 for (i=0; i<n_Profil_Tube; i++) {
	   Tube_Profil[i][5] *= 100;
	   Tube_Profil[i][6] *= 10000;
	   Tube_Profil[i][7] *= 1000;
	   Tube_Profil[i][8] *= 10;
	   Tube_Profil[i][9] *= 10000;
	   Tube_Profil[i][10] *= 1000;
	   Tube_Profil[i][11] *= 10;
	   Tube_Profil[i][12] *= 10000;
	   Tube_Profil[i][13] *= 1000;
	   Tube_Profil[i][14] *= 10;
	   Tube_Profil[i][17] *= 10000;
	 }
	 Index_thick_tube = 2;
	 h0 = 0;
	 b0 = 0;
	 k = 0;
	 for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] || b0 != Tube_Profil[i][1] ) {
		 h0 = Tube_Profil[i][0];
		 b0 = Tube_Profil[i][1];
		 Name_Profil[k] = FloatToStr(h0)+"*"+FloatToStr(b0);
		 k++;
	   }
	 }
	 n_Profil = k;
   break;
   case typeCORNER_NOEQU_B:    // Уголок гнутый неравнополочный
	 n_p = N_CORNER_NOEQU_BEND;
	 for (i=0; i<n_p; i++) {
	   for (j=0; j<21; j++) {
		   Tube_Profil[i][j] = Ugol_noravnop_gnut[i][j];
	   }
	 }
	 n_Profil_Tube = n_p;
	 for (i=0; i<n_Profil_Tube; i++) {
	   Tube_Profil[i][6] *= 100;
	   Tube_Profil[i][7] *= 10000;
	   Tube_Profil[i][8] *= 10;
	   Tube_Profil[i][9] *= 10000;
	   Tube_Profil[i][10] *= 10;
	   Tube_Profil[i][11] *= 10000;
	   Tube_Profil[i][12] *= 10;
	   Tube_Profil[i][13] *= 10000;
	   Tube_Profil[i][14] *= 10;
	   Tube_Profil[i][16] *= 10000;
	   Tube_Profil[i][17] *= 10;
	   Tube_Profil[i][19] *= 10;
	 }
	 Index_thick_tube = 2;
	 h0 = 0;
	 b0 = 0;
	 k = 0;
	 for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] || b0 != Tube_Profil[i][1] ) {
		 h0 = Tube_Profil[i][0];
		 b0 = Tube_Profil[i][1];
		 Name_Profil[k] = FloatToStr(h0)+"*"+FloatToStr(b0);
		 k++;
	   }
	 }
	 n_Profil = k;
   break;
   case typeCHANNEL_BEND:    // Швеллер гнутый
	 n_p = N_CHANNEL_BEND;
	 for (i=0; i<n_p; i++) {
	   for (j=0; j<16; j++) {
		   Tube_Profil[i][j] = Channel_bent[i][j];
	   }
	 }
	 n_Profil_Tube = n_p;
	 for (i=0; i<n_Profil_Tube; i++) {
	   Tube_Profil[i][6] *= 100;
	   Tube_Profil[i][7] *= 10000;
	   Tube_Profil[i][8] *= 1000;
	   Tube_Profil[i][9] *= 10;
	   Tube_Profil[i][10] *= 1000;
	   Tube_Profil[i][11] *= 10000;
	   Tube_Profil[i][12] *= 1000;
	   Tube_Profil[i][13] *= 10;
	   Tube_Profil[i][14] *= 10;
	 }
	 Index_thick_tube = 2;
	 h0 = 0;
	 b0 = 0;
	 k = 0;
	 for (i=0; i<n_Profil_Tube; i++) {
	   if (h0 != Tube_Profil[i][0] || b0 != Tube_Profil[i][1] ) {
		 h0 = Tube_Profil[i][0];
		 b0 = Tube_Profil[i][1];
		 Name_Profil[k] = FloatToStr(h0)+"*"+FloatToStr(b0);
		 k++;
	   }
	 }
	 n_Profil = k;
   break;
   default:
	 #ifdef EMBRAC
	 i = Application->MessageBox((L"Ошибочный тип стандартного профиля трубы: "+IntToStr(index)).c_str(), L"SetProfil_Tube", MB_OK | MB_ICONERROR);
	 #else
  	 i = Application->MessageBox(("Ошибочный тип стандартного профиля трубы: "+IntToStr(index)).c_str(), "SetProfil_Tube", MB_OK | MB_ICONERROR);
	 #endif
	 n_Profil = 0;
     return;
   }

}
//----------------------------------------------------------------------
// Получить вектор имен профилей и длину вектора
AnsiString* TStandartProfil::GetVectorNameProfil(int *n_profil) {
   *n_profil = n_Profil;
   return Name_Profil;
}
//----------------------------------------------------------------------
// Получить вектор параметров профиля двутавра, швеллера или тавра по его номеру
double* TStandartProfil::GetVectorParamProfil(int n_profil) {
   return Gost_Profil[n_profil];
}
//----------------------------------------------------------------------
// Получить вектор секториальных параметров профиля швеллера по его номеру
double* TStandartProfil::GetVectorSectorParamProfil(int n_profil) {
   return Gost_SectorProfil[n_profil];
}
//----------------------------------------------------------------------
// Получить вектор параметров профиля трубы по порядковому номеру профиля
double* TStandartProfil::GetVectorParamProfil_TubeNum(int number_prof) {
   int n_profil, n_thick;
   int rc = GetGroup_a_Profil_Tube(number_prof, &n_profil, &n_thick);
   return GetVectorParamProfil_Tube(n_profil, n_thick);
}
//------------------------------------------------------------------------------------------------
// Получить вектор параметров профиля трубы по номеру группы (h*b) и номеру внутри группы (t)
double* TStandartProfil::GetVectorParamProfil_Tube(int n_profil, int n_thick) {
   int i;
   AnsiString NameProf0;
   double h0, b0;

   for (i=0; i<n_Profil_Tube; i++) {
      h0 = Tube_Profil[i][0];
      b0 = Tube_Profil[i][1];
      if (Type_profil_tube!=typeCIRC)
        NameProf0 = FloatToStr(h0)+"*"+FloatToStr(b0);
      else
        NameProf0 = FloatToStr(h0);
	  if (NameProf0==Name_Profil[n_profil])
         break;
   }
   if (i+n_thick >= n_Profil_Tube)
      return NULL;
   else
      return Tube_Profil[i+n_thick];
}
//----------------------------------------------------------------------
// Получить номер профиля трубы по номеру группы (h*b) и номеру внутри группы (t)
int TStandartProfil::GetNumberProfil_Tube(int n_group, int n_profil) {
   int i;
   AnsiString NameProf0;
   double h0, b0;

   for (i=0; i<n_Profil_Tube; i++) {
      h0 = Tube_Profil[i][0];
	  b0 = Tube_Profil[i][1];
      if (Type_profil_tube!=typeCIRC)
        NameProf0 = FloatToStr(h0)+"*"+FloatToStr(b0);
      else
        NameProf0 = FloatToStr(h0);

	  if (NameProf0==Name_Profil[n_group])
         break;
   }
   if (i + n_profil >= n_Profil_Tube)
	  return n_Profil_Tube-1;
   else
	  return i+n_profil;
}
//----------------------------------------------------------------------
// Получить количество профилей трубы
int TStandartProfil::GetNumberAllProfil_Tube() {
   return n_Profil_Tube;
}
//----------------------------------------------------------------------
// Получить  номер группы (h*b) и номер внутри группы (t) по порядковому номеру профиля трубы
int TStandartProfil::GetGroup_a_Profil_Tube(int Number, int *n_profil, int *n_thick) {
   int i;
   AnsiString NameProf0, NameProfil_cur;
   double h0, b0;

   if (Type_profil_tube!=typeCIRC)
     NameProf0 = FloatToStr(Tube_Profil[Number][0])+"*"+FloatToStr(Tube_Profil[Number][1]);
   else
	 NameProf0 = FloatToStr(Tube_Profil[Number][0]);

   for (i=0; i<n_Profil; i++) {
     if (NameProf0==Name_Profil[i])
         break;
   }
   if (i>= n_Profil)
      return 1;
   *n_profil = i;

   for (i=0; i<n_Profil_Tube; i++) {
     if (Type_profil_tube!=typeCIRC)
       NameProfil_cur = FloatToStr(Tube_Profil[i][0])+"*"+FloatToStr(Tube_Profil[i][1]);
     else
       NameProfil_cur = FloatToStr(Tube_Profil[i][0]);

     if (NameProf0==NameProfil_cur)
         break;
   }
   if (i>= n_Profil_Tube)
      return 1;
   *n_thick = Number - i;
   return 0;
}
//----------------------------------------------------------------------
// Получить вектор толщин профиля трубы по номеру группы (h*b) и их количество
double* TStandartProfil::GetVectorParamThickness_Tube(int n_profil, int *num_thick) {
   int i, k;
   AnsiString NameProf0;
   double h0, b0;

   for (i=0; i<n_Profil_Tube; i++) {
      h0 = Tube_Profil[i][0];
      b0 = Tube_Profil[i][1];
	  if (Type_profil_tube!=typeCIRC)
        NameProf0 = FloatToStr(h0)+"*"+FloatToStr(b0);
      else
        NameProf0 = FloatToStr(h0);
      if (NameProf0==Name_Profil[n_profil])
         break;
   }
   if (i >= n_Profil_Tube)
      return NULL;
   k=0;
   for (; i<n_Profil_Tube; i++) {
      h0 = Tube_Profil[i][0];
      b0 = Tube_Profil[i][1];
      if (Type_profil_tube!=typeCIRC)
        NameProf0 = FloatToStr(h0)+"*"+FloatToStr(b0);
      else
        NameProf0 = FloatToStr(h0);

      if (NameProf0!=Name_Profil[n_profil])
         break;
	  Thickness[k] = Tube_Profil[i][Index_thick_tube];
      k++;
   }
   *num_thick = k;
   return Thickness;
}
//----------------------------------------------------------------------
// Заполнить структуру параметров сечения двутавра или тавра по его номеру
int TStandartProfil::SetParamProfil(SECT_DVUTAVR* sect, int n_profil) {
   if (n_profil >= n_Profil || n_profil <0)
      return 1;
   sect->n_group = Index;
   sect->n_profil = n_profil;
   if (Index <= typeGOST_G57837DK) {   // Двутавры
	 sect->type_profil = DVUTAVR;
	 sect->h = Gost_Profil[n_profil][0] - 2*Gost_Profil[n_profil][3];
   }
   if (Index >= typeTAVR_BT && Index <=  typeTAVR_DKT) {    // Тавры
	 sect->type_profil = TAVR;
	 sect->h = Gost_Profil[n_profil][0] - Gost_Profil[n_profil][3];
   }
   sect->index_perfor = 0;
   sect->b = Gost_Profil[n_profil][2];
   sect->b1 = Gost_Profil[n_profil][1];
   sect->b2 = Gost_Profil[n_profil][1];
   sect->h1 = Gost_Profil[n_profil][3];
   sect->h2 = Gost_Profil[n_profil][3];
   sect->flag_concl = true;
   return 0;
}
//----------------------------------------------------------------------
// Заполнить структуру параметров сечения швеллера по его номеру
int TStandartProfil::SetParamProfil_Channel(SECT_CHANNEL* sect_channel, int n_profil, int index_slope) {
   if (n_profil >= n_Profil || n_profil <0)
      return 1;
   sect_channel->n_group = Index;
   sect_channel->n_profil = n_profil;
   sect_channel->type_profil = CHANNEL;
   sect_channel->h = Gost_Profil[n_profil][0] - 2*Gost_Profil[n_profil][3];
   sect_channel->b = Gost_Profil[n_profil][2];
   sect_channel->b1 = Gost_Profil[n_profil][1];
   sect_channel->b2 = Gost_Profil[n_profil][1];
   sect_channel->h1 = Gost_Profil[n_profil][3];
   sect_channel->h2 = Gost_Profil[n_profil][3];
   sect_channel->z0 = Gost_Profil[n_profil][15];
   sect_channel->Rad = Gost_Profil[n_profil][parRAD_CHANNEL];         
   sect_channel->rad = Gost_Profil[n_profil][parRAD_CHANNEL+1];
   sect_channel->index_bend = 0;
   sect_channel->index_slope = index_slope;
   sect_channel->flag_concl = true;
   return 0;
}
//----------------------------------------------------------------------
// Заполнить структуру параметров сечения трубы или уголка по номеру
int TStandartProfil::SetParamProfil_Tube(COMMON_SECT* sect_comm, int type_sect, int Number, int index_orient) {
   int n_profil, n_thick, rc;

   if (Number >= n_Profil_Tube || Number <0)
      return 1;
   rc = GetGroup_a_Profil_Tube(Number, &n_profil, &n_thick);
   if (rc >0)
	 return rc;
   switch (type_sect) {
   case typeSQUARE:
	 sect_comm->square.n_group = n_profil;
	 sect_comm->square.n_profil = n_thick;
	 sect_comm->square.index_orient = 0;
	 sect_comm->square.side = Tube_Profil[Number][0];
	 sect_comm->square.thickness = Tube_Profil[Number][2];
	 sect_comm->square.b1 = 0;
	 sect_comm->square.h1 = 0;
	 sect_comm->square.b2 = 0;
	 sect_comm->square.h2 = 0;
	 sect_comm->square.rad = Tube_Profil[Number][3];
	 sect_comm->square.t_red = Tube_Profil[Number][10];
         sect_comm->square.type_profil = typeSQUARE;
	 sect_comm->square.flag_concl = true;
   break;
   case typeRECT:
	 sect_comm->rect.n_group = n_profil;
	 sect_comm->rect.n_profil = n_thick;
	 sect_comm->rect.index_orient = index_orient;
	 if (index_orient == 0) {
	   sect_comm->rect.h = Tube_Profil[Number][0];
	   sect_comm->rect.b = Tube_Profil[Number][1];
	 }
	 else {
	   sect_comm->rect.h = Tube_Profil[Number][1];
	   sect_comm->rect.b = Tube_Profil[Number][0];
	 }
	 sect_comm->rect.b1 = Tube_Profil[Number][2];
	 sect_comm->rect.h1 = Tube_Profil[Number][2];
	 sect_comm->rect.b2 = 0;
	 sect_comm->rect.h2 = 0;
	 sect_comm->rect.rad = Tube_Profil[Number][3];
	 sect_comm->rect.t_red = Tube_Profil[Number][14];
         sect_comm->rect.type_profil = typeRECT;
	 sect_comm->rect.flag_concl = true;
   break;
   case typeCIRC:
	 sect_comm->circ.n_group = n_profil;
	 sect_comm->circ.n_profil = n_thick;
	 sect_comm->circ.index_orient = 0;
	 sect_comm->circ.diameter = Tube_Profil[Number][0];
	 sect_comm->square.thickness = Tube_Profil[Number][1];
	 sect_comm->circ.b1 = 0;
	 sect_comm->circ.h1 = 0;
	 sect_comm->circ.b2 = 0;
	 sect_comm->circ.h2 = 0;
	 sect_comm->circ.t_red = Tube_Profil[Number][7];;
         sect_comm->circ.type_profil = typeCIRC;
	 sect_comm->circ.flag_concl = true;
   break;
   case typeCORNER_EQU:
		sect_comm->corner_two.bx = Tube_Profil[Number][parHSECT_COR];
		sect_comm->corner_two.by = Tube_Profil[Number][parHSECT_COR];
		sect_comm->corner_two.t = Tube_Profil[Number][parT_COR];
		sect_comm->corner_two.x0 = sect_comm->corner_two.y0 = Tube_Profil[Number][parX0_COR];
		sect_comm->corner_two.Rad = Tube_Profil[Number][parRb_COR];
		sect_comm->corner_two.rad = Tube_Profil[Number][parRm_COR];
		sect_comm->corner_two.index_orient = 0;
		sect_comm->corner_two.index_equ = 0;
		sect_comm->corner_two.index_bend = 0;
		if (sect_comm->corner_two.index_top != 2)
		  sect_comm->corner_two.fG = sect_comm->corner_two.t;
		else
		  sect_comm->corner_two.fG = 0;  // Одинарный уголок
		sect_comm->corner_two.b2 = 0;
				sect_comm->corner_two.type_profil = typeCORNER_EQU;
		sect_comm->corner_two.flag_concl=true;
         	sect_comm->corner_two.n_group = n_profil;
	        sect_comm->corner_two.n_profil = n_thick;
   break;
   case typeCORNER_NOEQU:
	   if (index_orient == 0) {
		  sect_comm->corner_two.bx = Tube_Profil[Number][parBSECT_COR];
		  sect_comm->corner_two.by = Tube_Profil[Number][parHSECT_COR];
		  sect_comm->corner_two.x0 = Tube_Profil[Number][parX0_CORN];
		  sect_comm->corner_two.y0 = Tube_Profil[Number][parY0_CORN];
	   }
	   else {
		  sect_comm->corner_two.by = Tube_Profil[Number][parBSECT_COR];
		  sect_comm->corner_two.bx = Tube_Profil[Number][parHSECT_COR];
		  sect_comm->corner_two.y0 = Tube_Profil[Number][parX0_CORN];
		  sect_comm->corner_two.x0 = Tube_Profil[Number][parY0_CORN];
	   }
		sect_comm->corner_two.t = Tube_Profil[Number][parT_COR];
		sect_comm->corner_two.Rad = Tube_Profil[Number][parRb_COR];
		sect_comm->corner_two.rad = Tube_Profil[Number][parRm_COR];
		sect_comm->corner_two.index_orient = index_orient;
		sect_comm->corner_two.index_equ = 1;
		sect_comm->corner_two.index_bend = 0;
		if (sect_comm->corner_two.index_top != 2)
		  sect_comm->corner_two.fG = sect_comm->corner_two.t;
		else
		  sect_comm->corner_two.fG = 0;  // Одинарный уголок
		sect_comm->corner_two.b2 = 0;
                sect_comm->corner_two.type_profil = typeCORNER_NOEQU;
		sect_comm->corner_two.flag_concl=true;
         	sect_comm->corner_two.n_group = n_profil;
			sect_comm->corner_two.n_profil = n_thick;
   break;
   case typeCORNER_EQU_B:
		sect_comm->corner_two.bx = Tube_Profil[Number][parHSECT_COR];
		sect_comm->corner_two.by = Tube_Profil[Number][parHSECT_COR];
		sect_comm->corner_two.t = Tube_Profil[Number][parT_COR];
		sect_comm->corner_two.x0 = sect_comm->corner_two.y0 = Tube_Profil[Number][parX0_COR_B];
		sect_comm->corner_two.Rad = Tube_Profil[Number][parRb_COR];
		sect_comm->corner_two.rad = 0;
		sect_comm->corner_two.index_orient = 0;
		sect_comm->corner_two.index_equ = 0;
		sect_comm->corner_two.index_bend = 1;
		if (sect_comm->corner_two.index_top != 2)
		  sect_comm->corner_two.fG = sect_comm->corner_two.t;
		else
		  sect_comm->corner_two.fG = 0;  // Одинарный уголок
		sect_comm->corner_two.b2 = 0;
                sect_comm->corner_two.type_profil = typeCORNER_EQU_B;
		sect_comm->corner_two.flag_concl=true;
         	sect_comm->corner_two.n_group = n_profil;
			sect_comm->corner_two.n_profil = n_thick;
   break;
   case typeCORNER_NOEQU_B:
	   if (index_orient == 0) {
		  sect_comm->corner_two.bx = Tube_Profil[Number][parBSECT_COR];
		  sect_comm->corner_two.by = Tube_Profil[Number][parHSECT_COR];
		  sect_comm->corner_two.x0 = Tube_Profil[Number][parY0_CORN_B];  // parY0_CORN_B соответствует x0
		  sect_comm->corner_two.y0 = Tube_Profil[Number][parX0_CORN_B];
	   }
	   else {
		  sect_comm->corner_two.by = Tube_Profil[Number][parBSECT_COR];
		  sect_comm->corner_two.bx = Tube_Profil[Number][parHSECT_COR];
		  sect_comm->corner_two.y0 = Tube_Profil[Number][parY0_CORN_B];
		  sect_comm->corner_two.x0 = Tube_Profil[Number][parX0_CORN_B];
	   }
		sect_comm->corner_two.t = Tube_Profil[Number][parT_COR];
		sect_comm->corner_two.Rad = Tube_Profil[Number][parRb_COR];
		sect_comm->corner_two.rad = 0;
		sect_comm->corner_two.index_orient = index_orient;
		sect_comm->corner_two.index_equ = 1;
		sect_comm->corner_two.index_bend = 1;
		if (sect_comm->corner_two.index_top != 2)
		  sect_comm->corner_two.fG = sect_comm->corner_two.t;
		else
		  sect_comm->corner_two.fG = 0;  // Одинарный уголок
		sect_comm->corner_two.b2 = 0;
                sect_comm->corner_two.type_profil = typeCORNER_NOEQU_B;
		sect_comm->corner_two.flag_concl=true;
         	sect_comm->corner_two.n_group = n_profil;
	        sect_comm->corner_two.n_profil = n_thick;
   break;
   case typeCHANNEL_BEND:
		sect_comm->channel.h1 = sect_comm->channel.h2 = sect_comm->channel.b = Tube_Profil[Number][parTW];
		sect_comm->channel.b1 = sect_comm->channel.b2 = Tube_Profil[Number][parBF];
		sect_comm->channel.h = Tube_Profil[Number][parHSECT] - 2*sect_comm->channel.h1;
		sect_comm->channel.z0 = Tube_Profil[Number][parZ0_CHANNEL_B];
		sect_comm->channel.index_bend = 1;
		sect_comm->channel.index_slope = 0;
		sect_comm->channel.Rad = Tube_Profil[Number][parRAD_CHANNEL_B];
		sect_comm->channel.rad = 0;
		sect_comm->channel.fG = 0;
                sect_comm->channel.type_profil = typeCHANNEL_BEND;
		sect_comm->channel.flag_concl=true;
         	sect_comm->channel.n_group = n_profil;
	        sect_comm->channel.n_profil = n_thick;
   break;
   default:
	 #ifdef EMBRAC
	 rc=Application->MessageBox(L"Программная ошибка в StandartProfil->SetParamProfil_Tube: неизвестный профиль", L" ", MB_OK | MB_ICONERROR);
	 #else
	 rc=Application->MessageBox("Программная ошибка в StandartProfil->SetParamProfil_Tube: неизвестный профиль", " ", MB_OK | MB_ICONERROR);
	 #endif
	 return rc;
   }
   return 0;
}
//------------------------------------------------------------------------
// Провека совпадения стандартных сечений
void Check_StandartProfil(SECT_DVUTAVR* sect1, SECT_DVUTAVR* sect2, AnsiString text) {
	   int i;
	   if (sect1->n_group != sect2->n_group ||
           sect1->n_profil != sect2->n_profil) {
	 #ifdef EMBRAC
		   i = Application->MessageBox((L"На конструктивном элементе заданы разные стандартные сечения. Принимается сечение по "+text).c_str(),
		   L"", MB_OK | MB_ICONWARNING);
	 #else
		   i = Application->MessageBox(("На конструктивном элементе заданы разные стандартные сечения. Принимается сечение по "+text).c_str(),
		   "", MB_OK | MB_ICONWARNING);
	 #endif
           sect2->n_group = sect1->n_group;
           sect2->n_profil = sect1->n_profil;
           sect2->h = sect1->h;
           sect2->b = sect1->b;
		   sect2->h1 = sect1->h1;
           sect2->b1 = sect1->b1;
           sect2->h2 = sect1->h2;
           sect2->b2 = sect1->b2;
       }
}
//------------------------------------------------------------------
// Сравнение типов профилей двутавра, швеллера и тавра
bool Compare_group(int n_group, int type_profil) {
  if (n_group <=typeTU_S || n_group == type_profil)
    return true;
  if (n_group >=typeGOST_G57837_B && n_group <=typeGOST_G57837_S &&
     (type_profil >=typeGOST_G57837_B && type_profil <=typeGOST_G57837_S) ||
      n_group == type_profil)
	return true;
  if (n_group >= typeTAVR_KT && n_group <= typeTAVR_ShT &&
	 (type_profil >= typeTAVR_BT && type_profil <= typeTAVR_DKT) ||
      n_group == type_profil)
	return true;
  return false;
}
//---------------------------------------------------------------------------
// Сменить или установить тип профиля двутавра для сечения
void  Set_TypeProfil(SECT_DVUTAVR* sect, int index_profil, int type_profil) {
   TStandartProfil StandartProfil;

   if (sect->n_group >= 0 && index_profil == 0) {
       sect->n_group = -1;
       return;
   }
   if ((sect->n_group < 0 || !Compare_group(sect->n_group, type_profil)) && index_profil ==1 ) {
     // Установить тип стандартного сечения
	 StandartProfil.SetProfil(type_profil);
	 sect->n_group = type_profil;
     sect->n_profil = StandartProfil.Get_NumberProfil(sect, 0);
     int rc = StandartProfil.SetParamProfil(sect, sect->n_profil);
     return;
   }
}
//---------------------------------------------------------------------------
// Сменить или установить тип профиля двутавра или трубы для сечения
void  Set_TypeProfil_Com(int type_sect, SECT_DVUTAVR* sect, int index_profil, int type_profil) {
   TStandartProfil StandartProfil;
   COMMON_SECT sect_com;
   double h, t;

   if (sect->n_group >= 0 && index_profil == 0) {
       sect->n_group = -1;
       return;
   }
   if (type_sect == DVUTAVR || type_sect == CHANNEL || type_sect == TAVR) {
     if ((sect->n_group < 0 || !Compare_group(sect->n_group, type_profil)) && index_profil ==1 ) {
       // Установить тип стандартного сечения
       StandartProfil.SetProfil(type_profil);
       sect->n_profil = StandartProfil.Get_NumberProfil(sect, 0);
       sect->n_group = type_profil;
       int rc = StandartProfil.SetParamProfil(sect, sect->n_profil);
     }
     return;
   }
   if (type_sect == SQUARE_TUBE || type_sect == RECT_TUBE || type_sect == CIRCULAR_TUBE || type_sect == CORNER_TWO) {
     memcpy(&sect_com.dvutavr, sect, sizeof(SECT_DVUTAVR));
     switch (type_sect) {
     case SQUARE_TUBE:
         type_profil = typeSQUARE;
         h = sect_com.square.side;
         t = sect_com.square.thickness;
         sect_com.rect.b = h;
         sect_com.rect.h = h;
         sect_com.rect.b1 = t;
         sect_com.rect.h1 = t;
         type_sect = RECT_TUBE;
     break;
     case RECT_TUBE:
         type_profil = typeRECT;
     break;
     case CIRCULAR_TUBE:
         type_profil = typeCIRC;
     break;
     case CORNER_TWO:
         type_profil = sect_com.corner_two.type_profil;
     break;
     default:
         type_profil = sect_com.dvutavr.type_profil;
     }
	   //if ((sect->n_group < 0 || sect->n_group != type_profil) && index_profil ==1) {
     if (sect->n_group < 0 && index_profil ==1) {
	   // Установить тип стандартного сечения
         StandartProfil.SetProfil_Tube(type_profil);
         // Ближайший номер сечения по ширине, высоте, и толщине
         int Number = StandartProfil.Get_NumberProfil_Tube(type_sect, &sect_com, 0);

         // Заполнить структуру параметров сечения трубы по его номеру
	 int rc = StandartProfil.SetParamProfil_Tube(&sect_com, type_profil, Number, 0);
         if (rc>0)
            return;
         memcpy(sect, &sect_com.dvutavr, sizeof(SECT_DVUTAVR));
     }
     return;
   }
   if (type_sect == typeGNU_CH || type_sect == typeGNU_C || type_sect == typeGNU_Z || type_sect == typeGNU_ZC || type_sect == typeGNU_SIGMA) {
      t = 0; //sect->n_group = -1;
   }
}
//---------------------------------------------------------------------------
// Преобразовать type_sect (из Data_Gen.h) в type_profil
int  Convert_type_sect(COMMON_SECT* sect_comm, int type_sect) {


   switch (type_sect) {
   case DVUTAVR:
   case CHANNEL:
   case TAVR:
      return type_sect;
   case SQUARE_TUBE:
      return typeSQUARE;
   case RECT_TUBE:
      return typeRECT;
   case CIRCULAR_TUBE:
      return typeCIRC;
   case CORNER_TWO:
      sect_comm->corner_two.type_profil;
   default:
      return sect_comm->dvutavr.type_profil;
   }
}
//---------------------------------------------------------------------------
// Установить начальный тип профиля двутавра (при этом должен установиться стандартный профиль и для других типов)
void    Set_TypeProfilInit(SECT_DVUTAVR* sect, int index_profil, int type_profil) {
   TStandartProfil StandartProfil;

   if (index_profil == 0) {
       sect->n_group = -1;
       return;
   }
   if (index_profil ==1 ) {
	 // Установить тип стандартного сечения
     StandartProfil.SetProfil(type_profil);
     sect->n_profil = StandartProfil.Get_NumberProfil(sect, 0);
     sect->n_group = type_profil;
     int rc = StandartProfil.SetParamProfil(sect, sect->n_profil);
     return;
   }
}
//------------------------------------------------------------------------
// Получить номер профиля двутавра, ближайший по параметру 0-по высоте, 4-по площади, 6-по моменту инерции
int TStandartProfil::Get_NumberProfil(SECT_DVUTAVR* section, int index) {
	   int i;
	   double Wz, param, delta;
	   int iS;
	   GEOM_PARAM_SECT param_sect;

	   if (!section->flag_concl)
		 return 0;

	   Get_param_sect(section, &param_sect);
	   if (param_sect.Hsect == 0 || param_sect.Ar==0)
		 return 0;
	   delta = 1e12;
	   iS = 0;
	   for (i=0; i<n_Profil; i++) {
		 param = Gost_Profil[i][index];
		 switch(index) {
		 case 0:
		  if (delta > (ABS(param_sect.Hsect - param))) {
			delta = ABS(param_sect.Hsect - param);
			iS = i;
		  }
		 break;
		 case 1:
		  if (delta > (ABS(section->b1 - param))) {
			delta = ABS(section->b1 - param);
			iS = i;
		  }
		 break;
		 case 2:
		  if (delta > (ABS(section->b - param))) {
			delta = ABS(section->b - param);
			iS = i;
		  }
		 break;
		 case 3:
		  if (delta > (ABS(section->h1 - param))) {
			delta = ABS(section->h1 - param);
			iS = i;
		  }
		 break;
		 case 4:
		  if ((param - param_sect.Ar > 0 || (ABS(param - param_sect.Ar)) < 1e-6) && delta > (ABS(param - param_sect.Ar))) {
			delta = param - param_sect.Ar;
			iS = i;
		  }
		 break;
		 case 6:
		  if (param - param_sect.Izz >=0 && delta > param - param_sect.Izz) {
			delta = param - param_sect.Izz;
			iS = i;
		  }
		 break;
		 case 7:
		  Wz = param_sect.Izz/param_sect.Zct;
		  if (param - Wz >=0 && delta > param - Wz) {
			delta = param - Wz;
			iS = i;
		  }
		 break;
		 default:
		   iS = 0;
		 }
	   }
	   return iS;
}
//------------------------------------------------------------------------
// Получить номер профиля, ближайший по параметру index для двутавра и тавра
int TStandartProfil::Get_NumberProfil_Com(int type_sect, COMMON_SECT* sect_com, int index) {
	   int i;
	   double Wz, param, delta;
	   int iS;
	   GEOM_PARAM_SECT param_sect;

	   if (!sect_com->dvutavr.flag_concl)
		 return 0;

	   Get_param_sect_comm(type_sect, sect_com, &param_sect);
	   if (param_sect.Hsect == 0 || param_sect.Ar==0)
		 return 0;
	   delta = 1e12;
	   iS = 0;
	   for (i=0; i<n_Profil; i++) {
		 param = Gost_Profil[i][index];
		 switch(index) {
		 case 0:
		  if (delta > (ABS(param_sect.Hsect - param))) {
			delta = ABS(param_sect.Hsect - param);
			iS = i;
		  }
		 break;
		 case 1:
		  if (delta > (ABS(sect_com->dvutavr.b1 - param))) {
			delta = ABS(sect_com->dvutavr.b1 - param);
			iS = i;
		  }
		 break;
		 case 2:
		  if (delta > (ABS(sect_com->dvutavr.b - param))) {
			delta = ABS(sect_com->dvutavr.b - param);
			iS = i;
		  }
		 break;
		 case 3:
		  if (delta > (ABS(sect_com->dvutavr.h1 - param))) {
			delta = ABS(sect_com->dvutavr.h1 - param);
			iS = i;
		  }
		 break;
		 case 4:
		  if ((param - param_sect.Ar > 0 || (ABS(param - param_sect.Ar)) < 1e-6) && delta > (ABS(param - param_sect.Ar))) {
			delta = param - param_sect.Ar;
			iS = i;
		  }
		 break;
		 case 6:
		  if (param - param_sect.Izz >=0 && delta > param - param_sect.Izz) {
			delta = param - param_sect.Izz;
			iS = i;
		  }
		 break;
		 case 7:
		  Wz = param_sect.Izz/param_sect.Zct;
		  if (param - Wz >=0 && delta > param - Wz) {
			delta = param - Wz;
			iS = i;
		  }
		 break;
		 default:
		   iS = 0;
		 }
	   }
	   return iS;
}
//------------------------------------------------------------------------
// Получить номер профиля, ближайший по параметру 0-по высоте, 4-по площади, 6-по моменту инерции для швеллера
int TStandartProfil::Get_NumberProfil_Channel(int type_sect, COMMON_SECT* sect_com, int index) {
	   int i;
	   double Wz, param, delta;
	   int iS;
	   GEOM_PARAM_SECT param_sect;

	   if (!sect_com->channel.flag_concl)
		 return 0;

	   Get_param_sect_comm(type_sect, sect_com, &param_sect);
	   if (param_sect.Hsect == 0 || param_sect.Ar==0)
		 return 0;
	   delta = 1e12;
	   iS = 0;
	   for (i=0; i<n_Profil; i++) {
		 param = Gost_Profil[i][index];
		 switch(index) {
		 case 0:
		  if (delta > (ABS(param_sect.Hsect - param))) {
			delta = ABS(param_sect.Hsect - param);
			iS = i;
		  }
		 break;
		 case 1:
		  if (delta > (ABS(sect_com->dvutavr.b1 - param))) {
			delta = ABS(sect_com->dvutavr.b1 - param);
			iS = i;
		  }
		 break;
		 case 2:
		  if (delta > (ABS(sect_com->dvutavr.b - param))) {
			delta = ABS(sect_com->dvutavr.b - param);
			iS = i;
		  }
		 break;
		 case 3:
		  if (delta > (ABS(sect_com->dvutavr.h1 - param))) {
			delta = ABS(sect_com->dvutavr.h1 - param);
			iS = i;
		  }
		 break;
		 case 6:
		  if ((param - param_sect.Ar > 0 || (ABS(param - param_sect.Ar)) < 1e-6) && delta > (ABS(param - param_sect.Ar))) {
			delta = param - param_sect.Ar;
			iS = i;
		  }
		 break;
		 case 8:
		  if (param - param_sect.Izz >=0 && delta > param - param_sect.Izz) {
			delta = param - param_sect.Izz;
			iS = i;
		  }
		 break;
		 case 9:
		  Wz = param_sect.Izz/param_sect.Zct;
		  if (param - Wz >=0 && delta > param - Wz) {
			delta = param - Wz;
			iS = i;
		  }
		 break;
		 default:
		   iS = 0;
		 }
	   }
	   return iS;
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Получить номер профиля трубы, ближайший по параметру 0-по высоте, ширине и толщине, 4-по площади, 6-по моменту инерции
int TStandartProfil::Get_NumberProfil_Tube(int type_sect, COMMON_SECT* sect_com, int index) {
	 int i;
	 double Wz, param, delta;
	 int iS;
	 GEOM_PARAM_SECT param_sect;

	 if (!sect_com->rect.flag_concl)
	   return 0;

	 Get_param_sect_comm(type_sect, sect_com, &param_sect);
	 if (param_sect.Hsect == 0 || param_sect.Ar==0)
       return 0;
     delta = 1e12;
     iS = 0;
     if (index==0) {
       if (type_sect==SQUARE_TUBE) {
         for (i=0; i<n_Profil_Tube; i++) {
           if (Tube_Profil[i][0] > sect_com->square.side &&
              Tube_Profil[i][2] > sect_com->square.thickness) {
			break;
           }
         }
       }
	   if (type_sect==RECT_TUBE) {
         for (i=0; i<n_Profil_Tube; i++) {
           if (Tube_Profil[i][0] > sect_com->rect.b && Tube_Profil[i][1] > sect_com->rect.h &&
              Tube_Profil[i][2] > sect_com->rect.b1 && Tube_Profil[i][3] > sect_com->rect.h1) {
            break;
           }
		 }
       }
	   if (type_sect==CIRCULAR_TUBE) {
         for (i=0; i<n_Profil_Tube; i++) {
           if (Tube_Profil[i][0] > sect_com->circ.diameter &&
              Tube_Profil[i][1] > sect_com->circ.thickness) {
            break;
           }
         }
       }
       return (MAX(0, i-1));
     }
     else {
       int i_new;
       int index_square[10] = {0, 1, 2, 3, 5, 6, 7, 8, 9, 10};
       int index_rect[10] =   {0, 1, 2, 3, 6, 7, 8, 9, 10, 11};
       int index_circ[10] =   {0, 1, 1, 1, 2, 3, 4, 5, 6, 7};
       switch(type_sect) {
       case SQUARE_TUBE:
        i_new = index_square[index];
       break;
       case RECT_TUBE:
        i_new = index_rect[index];
	   break;
       case CIRCULAR_TUBE:
        i_new = index_circ[index];
	   break;
       }

       for (i=0; i<n_Profil; i++) {
         param = Tube_Profil[i][i_new];
		 switch(index) {
         case 4:
          if (param - param_sect.Ar >0 && delta > param - param_sect.Ar) {
            delta = param - param_sect.Ar;
            iS = i;
          }
         break;
         case 6:
          if (param - param_sect.Izz >0 && delta > param - param_sect.Izz) {
            delta = param - param_sect.Izz;
            iS = i;
          }
         break;
         case 7:
          Wz = param_sect.Izz/param_sect.Zct;
          if (param - Wz >0 && delta > param - Wz) {
            delta = param - Wz;
            iS = i;
          }
         break;
         default:
		   iS = 0;
         }
       }
       return iS;
     }
}
//---------------------------------------------------------------------------------------------------------
// Получить номер профиля, ближайший по заданному параметру 0-по высоте, 4-по площади, 6-по моменту инерции
int TStandartProfil::Get_NumberProfil_param(double param, int index) {
       int i;

       for (i=0; i<n_Profil; i++) {
         if (Gost_Profil[i][index] - param >=0 )
            break;
       }
       if (i==n_Profil)
         return -1;
       else
         return i;
}//---------------------------------------------------------------------------------------------------------
// Получить номер профиля, ближайший по заданному параметру 0-по высоте, 4-по площади, 6-по моменту инерции
// тонкая настройка
int TStandartProfil::Get_NumberProfil_param_tube(double param, int index) {
       int i;

       double delta = 1e6;
       int i_delta = -1;
       for (i=0; i<n_Profil_Tube; i++) {           
         if (Tube_Profil[i][index] - param >=0 &&  Tube_Profil[i][index] - param < delta) {
            delta = Tube_Profil[i][index] - param;
            i_delta = i;                                //Tube_Profil[0][9]
         }
       }
       return i_delta;          
}
//---------------------------------------------------------------------------------------------------------
// Получить номер профиля двутавра, ближайший по заданному параметру 0-по высоте, 4-по площади, 6-по моменту инерции
int TStandartProfil::Choice_Profil_param(SECT_DVUTAVR* sect, double Ar, double ix, double W,
                                         double h_sect, double tw, double tf, double bf, bool flag_message) {

       int i;
       SetProfil(sect->n_group);

       int iAr = Get_NumberProfil_param(Ar, parAREA);
	   int iix = Get_NumberProfil_param(ix, parIRADZ);
       int iW = Get_NumberProfil_param(W, parWZ);
       int ih = Get_NumberProfil_param(h_sect, parHSECT);
       int itw = Get_NumberProfil_param(tw, parTW);
       int itf = Get_NumberProfil_param(tf, parTF);
       int ibf = Get_NumberProfil_param(bf, parBF);
       int n_max = -1;
       double par_max = 0;
	   AnsiString text_max;
       if (iAr >0 && iAr > n_max) {
         n_max = iAr;
         text_max = "площадь поперечного сечения";
         par_max = Round(iAr, 0);
       }
       if (ix >0 && iix > n_max) {
         n_max = iix;
         text_max = "радиус инерции";
         par_max = Round(ix, 0);
       }
       if (W>0 && iW > n_max) {
         n_max = iW;
         text_max = "момент сопротивления изгибу";
         par_max = Round(W, 0);
       }

       if (h_sect>0 && ih > n_max) {
         n_max = ih;
         text_max = "высота сечения";
         par_max = Round(h_sect, 0);
	   }
       if (tw>0 && itw > n_max) {
         n_max = itw;
         text_max = "толщина стенки";
         par_max = Round(tw, 1);
       }
       if (tf>0 && itf > n_max) {
         n_max = itf;
		 text_max = "толщина полки";
         par_max = Round(tf, 1);
       }
       if (bf>0 && ibf > n_max) {
         n_max = ibf;
         text_max = "ширина полки";
         par_max = Round(bf, 0);
       }
       int n_min = 1000;
       double par_min = 0;
       AnsiString text_min ;
       if (iAr>0 && iAr < n_min) {
         n_min = iAr;
         text_min = "площадь поперечного сечения";
         par_min = Round(iAr, 0);
       }
       if (ix>0 && iix < n_min) {
         n_min = iix;
         text_min = "радиус инерции";
         par_min = Round(ix, 0);
       }
	   if (W>0 && iW < n_min) {
         n_min = iW;
         text_min = "момент сопротивления изгибу";
         par_min = Round(W, 0);
       }
       if (h_sect>0 && ih < n_min) {
         n_min = ih;
         text_min = "высота сечения";
		 par_min = Round(h_sect, 0);
       }
       if (tw>0 && itw < n_min) {
         n_min = itw;
         text_min = "толщина стенки";
         par_min = Round(tw, 0);

       }
       if (tf>0 && itf < n_min) {
         n_min = itf;
         text_min = "толщина полки";
         par_min = Round(tf, 0);
       }
       if (bf>0 && ibf < n_min) {
         n_min = ibf;
         text_min = "ширина полки";
         par_min = Round(bf, 0);
       }
	   if (n_min == -1) {
		 #ifdef EMBRAC
		 i = Application->MessageBox((L"Раздел сортамента не содержит сечения требуемого размера, критический параметр: "+
									  text_min+" = "+FloatToStr(par_min)).c_str(),L"",
									  MB_OK | MB_ICONERROR);
		 #else
		 i = Application->MessageBox(("Раздел сортамента не содержит сечения требуемого размера, критический параметр: "+
									  text_min+" = "+FloatToStr(par_min)).c_str(),"",
									  MB_OK | MB_ICONERROR);
		 #endif
		 return 1;
	   }
       // Заполнить структуру параметров сечения по его номеру
       int rc = SetParamProfil(sect, n_max);
       if (rc>0)
          return rc;
	   if (n_max - n_min > 1 && flag_message) {
		 #ifdef EMBRAC
		 i=Application->MessageBox((L"Сечение принято по критическому параметру ("+text_max+
								   "), номер сечения по наименее критическому параметру ("+
								   text_min+") меньше на "+IntToStr(n_max - n_min)+" пункта").c_str(),L"",
								   MB_OK | MB_ICONWARNING);
		 #else
		 i=Application->MessageBox(("Сечение принято по критическому параметру ("+text_max+
								   "), номер сечения по наименее критическому параметру ("+
								   text_min+") меньше на "+IntToStr(n_max - n_min)+" пункта").c_str(),"",
								   MB_OK | MB_ICONWARNING);
		 #endif
	   }
     return 0;
}

#pragma package(smart_init)
