//---------------------------------------------------------------------------
#include <vcl.h>
#include <math.h>

#pragma hdrstop

#include "Draw3D_beam.h"
//#include "Data_Gen.h"
#include "StandartProfil.h"
#include "ProcExt.h"
#include "ListConst.h"
#include "Point_dvutavr.h"
#include "pCanvas_func.h"
#include "Get_param_sect_func.h"
#include "message.h"




//---------------------------------------------------------------------------
#pragma package(smart_init)

extern bool flag_image;
static TStandartProfil StandartProfil;
static TArrow CoorAx;
static double X0, Y0;   // центр системы координат профиля в системе коррдинат экрана
static double Length;   // длина профиля

extern bool flag_image;
extern int  Page_Height;
extern int  Page_Width;
extern TMetafile * GrapMeta;
extern TFont     * TheFont;
extern TMetafileCanvas *pCanvas;


// рисование сварного двутавра в проекции
void Draw_dvutavr_weld_plane(TImage * Image_weld, SECT_DVUTAVR *sect) {
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert_rect[30];
  int zero, zero1, zero2;
  double zero_f, zero1_f, zero2_f;
  double scale_1, scale;
  int rc;


	double * ParamProfil;
	int shiftY = SHIFTY;
	int shiftX = SHIFTX;


	TRect NewRect = Rect(0, 0, Image_weld->Width,Image_weld->Height);
	Image_weld->Canvas->Pen->Color = clBlack;
	Image_weld->Canvas->Brush->Color = clWhite;
	Image_weld->Canvas->FillRect(NewRect);
	Image_weld->Canvas->Rectangle(0, 0, Image_weld->Width,Image_weld->Height);

	if (sect->b2==0 || sect->b1==0 || sect->h==0 || sect->h1==0 || sect->h2==0) {
	  return;
	}
	scale=(Image_weld->Width-20)/(1e0*sect->b2);
	scale_1=MIN(scale,(Image_weld->Width - 20)/(1e0*sect->b1));
	scale=MIN(scale_1,(Image_weld->Height- 20)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero_f = (Image_weld->Height - (sect->h + sect->h1 + sect->h2)*scale)/2;
	zero1_f=(Image_weld->Width - sect->b2*scale)/2;
	zero2_f=(Image_weld->Width - sect->b1*scale)/2;

	zero = zero_f;
	zero1 = zero1_f;
	zero2 = zero2_f;
	//  Точки двутавра

	Point_weld_dvutavr(zero, zero1, zero2, sect, scale, vertices1); // получить точки контура двутавра

	Image_weld->Canvas->Brush->Color = COLOR;
	//----------------------------------------------------------------

	//--------------------------------------------
	// Рисование двутавра
	Image_weld->Canvas->Brush->Color = clScrollBar;
	Image_weld->Canvas->Polygon(vertices1, 12);
	TPoint Vert0[2];
	Vert0[0] = vertices1[3];
	Vert0[1] = vertices1[10];
	Image_weld->Canvas->Polyline(Vert0, 1);
	Vert0[0] = vertices1[4];
	Vert0[1] = vertices1[9];
	Image_weld->Canvas->Polyline(Vert0, 1);

	Image_weld->Canvas->Brush->Style=bsClear;

	GEOM_PARAM_SECT param_sect;
	Get_param_sect(sect, &param_sect);

	Draw_axes_zero(Image_weld, vPLANE, (vertices1[0].x + vertices1[1].x)/2, vertices1[0].y + param_sect.Zp*scale);

}
//----------------------------------------------------------------------
// Рисование профиля двутавра длиной len_prof*heigth в проекции index_view
void Draw_dvutavr(TImage * Image_stand, SECT_DVUTAVR *sect, int index_view, float len_prof, int pole, bool flag_ax, bool flag_perfor,
				  double attit, double alfa, double length_0) {
  // если length_0>0 - она принимается в качестве длины балки
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert[30];
  int rc;
  double t_conv[4][4];
  double z_mod;
  double coor_1[30][3];
  double coor_2[30][3];
  double coor_1g[30][3];
  double coor_2g[30][3];
  bool Sign[3] = {true, false, true};
  //bool Sign[3] = {false, false, true};
  double X_shift, Y_shift, scale;
  int i;
  double h0;
  double k_att;
  double h1;
  double b_;
  double a_;
  double len_perfor;
  double * ParamProfil;
  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	pWidth = Image_stand->Width;
	pHeight = Image_stand->Height;
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }

	// установить вид и вычислить матрицу преобразования
	SetView_(t_conv, &z_mod, index_view, Sign, 2);

	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// Получить координаты переднего сечения двутавра
	Coor_stand_dvutavr(sect, ParamProfil[parRAD], coor_1);
    // Начало координат профиля - для рисования нагркзок
	X0 =(coor_1[0][0] + coor_1[1][0])/2;
	Y0 =(coor_1[5][1] + coor_1[6][1])/2;
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_1, 21, coor_1g);
	// Получить координаты заднего сечения двутавра
	if (length_0 == 0) {
	  if (!flag_perfor) {
		Length = sect->h*len_prof;
	  }
	  else {
		h0 = sect->h/attit + sect->h1 + sect->h2;
		k_att = attit/3;
		h1 = Round(k_att*h0, 0) - 1;
		b_ = Round(k_att*h0/tan(alfa/RADIAN), 0);
		a_ = Round(k_att*h0/sin(alfa/RADIAN), 0) + 2;
		len_perfor = 5*a_ + 4*b_;
	  //Length = sect->h*len_prof/attit;
		Length = len_perfor;
	  }
	}
	else {
	   Length = length_0*1000;
	   if (flag_perfor) {
			h0 = sect->h/attit + sect->h1 + sect->h2;
			k_att = attit/3;
			h1 = Round(k_att*h0, 0) - 1;
			b_ = Round(k_att*h0/tan(alfa/RADIAN), 0);
			a_ = Round(k_att*h0/sin(alfa/RADIAN), 0) + 2;
			len_perfor = 5*a_ + 4*b_;
	  //Length = sect->h*len_prof/attit;
			//Length = len_perfor;
	   }
	}

	for (i=0; i<21; i++) {
	  coor_2[i][0] = coor_1[i][0];
	  coor_2[i][1] = coor_1[i][1];
	  coor_2[i][2] = coor_1[i][2] + Length;
	}
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_2, 21, coor_2g);
	//--------------------------------------------------
	// Определить масштаб
	Set_scale(pWidth, pHeight, z_mod, coor_1g, coor_2g, 21, &scale, &X_shift, &Y_shift, pole);

	// Получить точки контура прокатного двутавра
	// Первый двутавр
	for (i=0; i<21; i++) {
	  vertices1[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
	}
	// второй двутавр
	for (i=0; i<21; i++) {
	  vertices2[i] = Point(coor_2g[i][0]*scale - X_shift, coor_2g[i][1]*scale - Y_shift);
	}

	if (index_view!=vISO_VERT) {   // Не вертикальеая колонна
	  if (flag_image) {
		Image_stand->Canvas->Brush->Color = COLOR;
	// Рисование заднего двутавра
		Image_stand->Canvas->Polyline(vertices1+2, 7);

		Image_stand->Canvas->Brush->Color = clWhite;
		Image_stand->Canvas->Pen->Color = clBlack;
	  }
	  else {
		pCanvas->Brush->Color = COLOR;
	// Рисование заднего двутавра
		pCanvas->Polyline(vertices1+2, 7);

		pCanvas->Brush->Color = clWhite;
		pCanvas->Pen->Color = clBlack;
	  }
	//----------------------------------------------------------------
	//
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 12, 13, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 8, 9, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 5, 6, clWhite);
	}
	else { // Вертикальная колонна
	  if (flag_image) {
		Image_stand->Canvas->Brush->Color = COLOR;
	// Рисование нижнего двутавра
		Image_stand->Canvas->Polyline(vertices2+7, 12);

		Image_stand->Canvas->Brush->Color = clWhite;
		Image_stand->Canvas->Pen->Color = clBlack;
	  }
	  else {
		pCanvas->Brush->Color = COLOR;
	// Рисование нижнего двутавра
		pCanvas->Polyline(vertices2+7, 12);

		pCanvas->Brush->Color = clWhite;
		pCanvas->Pen->Color = clBlack;
	  }
	//----------------------------------------------------------------
	//
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 19, COLOR);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 2, 3, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 9, 8, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 15, 16, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 10, 11, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 11, 12, COLOR);
	}
	//
	if (flag_perfor) {
		double coor_p[15][3];
		double coor_g[15][3];
		double hp;
		int ND1;
		int ND2;
		int j;
		TPoint vert[30];

	// Контур
	  if (flag_image) {
		Image_stand->Canvas->Brush->Color = clBtnFace;
	  }
	  else
		pCanvas->Brush->Color = clBtnFace;

	// Отверстия
	  for (j=0; j<1; j++) {
		if (j==0) {
		  ND1 = 5;
		  ND2 = 6;
		}
		 else {
		  ND1 = 16;
		  ND2 = 15;
		}
		hp = (coor_1[ND1][1] + coor_1[ND2][1])/4;
		for (i=0; i<13; i++)  {
			coor_p[i][0] = coor_1[ND1][0];
		}
		coor_p[0][2] = coor_2[ND1][2];
		coor_p[0][1] = coor_2[ND1][1];

		//coor_p[1][0] = coor_p[0][0] - (c_+ 2*s_);
		coor_p[1][2] = coor_1[ND1][2];
		coor_p[1][1] = coor_p[0][1];

		coor_p[2][2] = coor_p[1][2];
		coor_p[2][1] = (coor_1[ND1][1] + coor_1[ND2][1])/2;

		//coor_p[3][2] = coor_p[2][2] + 2*a_;    len = 5*a_ + 4*b_
		coor_p[3][2] = coor_p[2][2] + a_;
		coor_p[3][1] = coor_p[2][1];

		coor_p[4][2] = coor_p[3][2] + b_;
		coor_p[4][1] = coor_p[3][1] - h1;

		coor_p[5][2] = coor_p[4][2] + a_;
		coor_p[5][1] = coor_p[4][1];

		coor_p[6][2] = coor_p[5][2] + b_;
		coor_p[6][1] = coor_p[3][1];

		coor_p[7][2] = coor_p[6][2] + a_;
		coor_p[7][1] = coor_p[6][1];

		coor_p[8][2] = coor_p[7][2] + b_;
		coor_p[8][1] = coor_p[7][1] - h1;

		coor_p[9][2] = coor_p[8][2] + a_;
		coor_p[9][1] = coor_p[8][1];

		coor_p[10][2] = coor_p[9][2] + b_;
		coor_p[10][1] = coor_p[6][1];

		coor_p[11][2] = coor_p[0][2];
		coor_p[11][1] = coor_p[10][1];

		coor_p[12][2] = coor_p[0][2];
		coor_p[12][1] = coor_p[0][1];

		// преобразовать координаты в экранную систему
		Set_coorg_(t_conv, coor_p, 13, coor_g);

		// Получить точки контура прокатного двутавра
		for (i=0; i<13; i++) {
		  vert[i] = Point(coor_g[i][0]*scale - X_shift, coor_g[i][1]*scale - Y_shift);
		}

		if (flag_image)
		  Image_stand->Canvas->Polyline(vert+2, 9);
		else
		  pCanvas->Polyline(vert+2, 9);

		coor_p[0][1] += 4*hp;
		coor_p[1][1] += 4*hp;
		coor_p[12][1] += 4*hp;

		coor_p[4][1] += 2*h1;
		coor_p[5][1] += 2*h1;
		coor_p[8][1] += 2*h1;
		coor_p[9][1] += 2*h1;

		// преобразовать координаты в экранную систему
		Set_coorg_(t_conv, coor_p, 13, coor_g);

		// Получить точки
		for (i=0; i<13; i++) {
		   vert[i] = Point(coor_g[i][0]*scale - X_shift, coor_g[i][1]*scale - Y_shift);
		}

		if (flag_image)
		  Image_stand->Canvas->Polyline(vert+2, 9);
		else
		  pCanvas->Polyline(vert+2, 9);
	  }
	}

	double x0, y0;  // начало координат
	if (index_view!=vISO_VERT) {   // Не вертикальеая колонна
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 1, 2, COLOR);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);
	  Draw_side_dvut(Image_stand, vertices1, vertices2, 9, 10, COLOR);

	  if (flag_image) {
		Image_stand->Canvas->Pen->Color = clBlack;
		Image_stand->Canvas->Brush->Color = COLOR;
	// Рисование второго  двутавра
		Image_stand->Canvas->Brush->Color = clScrollBar;
		Image_stand->Canvas->Polygon(vertices2, 20);
	  }
	  else  {
		pCanvas->Pen->Color = clBlack;
		pCanvas->Brush->Color = COLOR;
	// Рисование второго  двутавра
		pCanvas->Brush->Color = clScrollBar;
		pCanvas->Polygon(vertices2, 20);
	  }
	//----------------------------------------------------------------

	//--------------------------------------------
	  x0 = (vertices2[0].x + vertices2[1].x)/2;
	  y0 = (vertices2[0].y + vertices2[1].y + vertices2[10].y + vertices2[11].y)/4;
	}
	else {
	  if (flag_image) {
		Image_stand->Canvas->Pen->Color = clBlack;
		Image_stand->Canvas->Brush->Color = COLOR;
	// Рисование второго  двутавра
		Image_stand->Canvas->Brush->Color = clScrollBar;
		Image_stand->Canvas->Polygon(vertices1, 20);
	  }
	  else {
		pCanvas->Pen->Color = clBlack;
		pCanvas->Brush->Color = COLOR;
	// Рисование второго  двутавра
		pCanvas->Brush->Color = clScrollBar;
		pCanvas->Polygon(vertices1, 20);
	  }
	  x0 = (vertices2[0].x + vertices2[1].x + vertices2[10].x + vertices2[11].x)/4;
	  y0 = (vertices2[0].y + vertices2[1].y + vertices2[10].y + vertices2[11].y)/4;
	}

	//
	if (flag_ax) {
	  Draw_axes_zero(Image_stand, index_view, x0, y0);

	}
}
//----------------------------------------------------------------------
// Рисование профиля составного сечения len_prof*heigth в проекции index_view
void Draw_dvutavr_plate(TImage * Image_stand, SECT_DVUTAVR *sect, int index_view, float len_prof, int pole, bool flag_ax, bool flag_perfor,
				  double attit, double alfa, double length_0, double plate_h, double plate_b) {
  // если length_0>0 - она принимается в качестве длины балки
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert[30];
  int rc;
  double t_conv[4][4];
  double z_mod;
  double coor_1[30][3];
  double coor_2[30][3];
  double coor_1g[30][3];
  double coor_2g[30][3];
  bool Sign[3] = {true, false, true};
  bool Sign_p[3] = {true, true, true};
  double X_shift, Y_shift, scale;
  int i;
  double h0;
  double k_att;
  double h1;
  double b_;
  double a_;
  double len_perfor;
  double * ParamProfil;

  GEOM_PARAM_SECT param_sect;


  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	pWidth = Image_stand->Width;
	pHeight = Image_stand->Height;
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }

	// установить вид и вычислить матрицу преобразования
	SetView_(t_conv, &z_mod, index_view, Sign, 2);

	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// Получить координаты переднего сечения двутавра
	Coor_stand_dvutavr(sect, ParamProfil[parRAD], coor_1);

	// Добавить координаты пластины
	Coor_plate(sect->b1, sect->h + 2*sect->h1, plate_h, plate_b, 21, coor_1, 0);

	// Параметры сечения
	Get_param_sect(sect, &param_sect);

	// координата ц.т полного сечения
	coor_1[26][0] = sect->b1/2;
	coor_1[26][2] = 0;
	coor_1[26][1] = (param_sect.Ar*param_sect.Zct + plate_h*plate_b*(sect->h + 2*sect->h1 + plate_h*0.5))/
			(param_sect.Ar + plate_h*plate_b);

	//X0 =(coor_1[0][0] + coor_1[1][0])/2;
	//Y0 =(coor_1[5][1] + coor_1[6][1])/2;

	X0 = coor_1[26][0];
	Y0 = coor_1[26][1];
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_1, 27, coor_1g);
	// Получить координаты заднего сечения двутавра
	if (length_0 == 0) {
	  if (!flag_perfor) {
		Length = sect->h*len_prof;
	  }
	  else {
		h0 = sect->h/attit + sect->h1 + sect->h2;
		k_att = attit/3;
		h1 = Round(k_att*h0, 0) - 1;
		b_ = Round(k_att*h0/tan(alfa/RADIAN), 0);
		a_ = Round(k_att*h0/sin(alfa/RADIAN), 0) + 2;
		len_perfor = 5*a_ + 4*b_;
	  //Length = sect->h*len_prof/attit;
		Length = len_perfor;
	  }
	}
	else {
	   Length = length_0*1000;
	   if (flag_perfor) {
			h0 = sect->h/attit + sect->h1 + sect->h2;
			k_att = attit/3;
			h1 = Round(k_att*h0, 0) - 1;
			b_ = Round(k_att*h0/tan(alfa/RADIAN), 0);
			a_ = Round(k_att*h0/sin(alfa/RADIAN), 0) + 2;
			len_perfor = 5*a_ + 4*b_;
	  //Length = sect->h*len_prof/attit;
			//Length = len_perfor;
	   }
	}

	for (i=0; i<27; i++) {
	  coor_2[i][0] = coor_1[i][0];
	  coor_2[i][1] = coor_1[i][1];
	  coor_2[i][2] = coor_1[i][2] + Length;
	}
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_2, 27, coor_2g);
	//--------------------------------------------------
	// Определить масштаб двутавра с пластиной
	Set_scale(pWidth, pHeight, z_mod, coor_1g, coor_2g, 27, &scale, &X_shift, &Y_shift, pole);

	// Получить точки контура прокатного двутавра
	for (i=0; i<27; i++) {
	  vertices1[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
	}

	if (flag_image) {
	  Image_stand->Canvas->Brush->Color = COLOR;
	// Рисование заднего двутавра
	  Image_stand->Canvas->Polyline(vertices1+2, 7);

	  Image_stand->Canvas->Brush->Color = clWhite;
	  Image_stand->Canvas->Pen->Color = clBlack;
	}
	else {
	  pCanvas->Brush->Color = COLOR;
	// Рисование заднего двутавра
	  pCanvas->Polyline(vertices1+2, 7);

	  pCanvas->Brush->Color = clWhite;
	  pCanvas->Pen->Color = clBlack;
	}

	// второй двутавр
	for (i=0; i<27; i++) {
	  vertices2[i] = Point(coor_2g[i][0]*scale - X_shift, coor_2g[i][1]*scale - Y_shift);
	}


	//----------------------------------------------------------------
	Draw_side_dvut(Image_stand, vertices1, vertices2, 21, 11, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 10, 22, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 22, 23, COLOR);
	//
	Draw_side_dvut(Image_stand, vertices1, vertices2, 12, 13, clWhite);
	//Draw_side_dvut(Image_stand, vertices1, vertices2, 6, 7, clWhite);
	//Draw_side_dvut(Image_stand, vertices1, vertices2, 7, 8, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 8, 9, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 5, 6, clWhite);

	//
	if (flag_perfor) {
		double coor_p[15][3];
		double coor_g[15][3];
		double hp;
		int ND1;
		int ND2;
		int j;
		TPoint vert[30];

	// Контур
	  if (flag_image)
		Image_stand->Canvas->Brush->Color = clBtnFace;
	  else
		pCanvas->Brush->Color = clBtnFace;
	// Отверстия
	  for (j=0; j<1; j++) {
		if (j==0) {
		  ND1 = 5;
		  ND2 = 6;
		}
		 else {
		  ND1 = 16;
		  ND2 = 15;
		}
		hp = (coor_1[ND1][1] + coor_1[ND2][1])/4;
		for (i=0; i<13; i++)  {
			coor_p[i][0] = coor_1[ND1][0];
		}
		coor_p[0][2] = coor_2[ND1][2];
		coor_p[0][1] = coor_2[ND1][1];

		//coor_p[1][0] = coor_p[0][0] - (c_+ 2*s_);
		coor_p[1][2] = coor_1[ND1][2];
		coor_p[1][1] = coor_p[0][1];

		coor_p[2][2] = coor_p[1][2];
		coor_p[2][1] = (coor_1[ND1][1] + coor_1[ND2][1])/2;

		//coor_p[3][2] = coor_p[2][2] + 2*a_;    len = 5*a_ + 4*b_
		coor_p[3][2] = coor_p[2][2] + a_;
		coor_p[3][1] = coor_p[2][1];

		coor_p[4][2] = coor_p[3][2] + b_;
		coor_p[4][1] = coor_p[3][1] - h1;

		coor_p[5][2] = coor_p[4][2] + a_;
		coor_p[5][1] = coor_p[4][1];

		coor_p[6][2] = coor_p[5][2] + b_;
		coor_p[6][1] = coor_p[3][1];

		coor_p[7][2] = coor_p[6][2] + a_;
		coor_p[7][1] = coor_p[6][1];

		coor_p[8][2] = coor_p[7][2] + b_;
		coor_p[8][1] = coor_p[7][1] - h1;

		coor_p[9][2] = coor_p[8][2] + a_;
		coor_p[9][1] = coor_p[8][1];

		coor_p[10][2] = coor_p[9][2] + b_;
		coor_p[10][1] = coor_p[6][1];

		coor_p[11][2] = coor_p[0][2];
		coor_p[11][1] = coor_p[10][1];

		coor_p[12][2] = coor_p[0][2];
		coor_p[12][1] = coor_p[0][1];

		// преобразовать координаты в экранную систему
		Set_coorg_(t_conv, coor_p, 13, coor_g);

		// Получить точки контура прокатного двутавра
		for (i=0; i<13; i++) {
		  vert[i] = Point(coor_g[i][0]*scale - X_shift, coor_g[i][1]*scale - Y_shift);
		}

		if (flag_image)
		  Image_stand->Canvas->Polyline(vert+2, 9);
		else
		  pCanvas->Polyline(vert+2, 9);

		coor_p[0][1] += 4*hp;
		coor_p[1][1] += 4*hp;
		coor_p[12][1] += 4*hp;

		coor_p[4][1] += 2*h1;
		coor_p[5][1] += 2*h1;
		coor_p[8][1] += 2*h1;
		coor_p[9][1] += 2*h1;

		// преобразовать координаты в экранную систему
		Set_coorg_(t_conv, coor_p, 13, coor_g);

		// Получить точки
		for (i=0; i<13; i++) {
		   vert[i] = Point(coor_g[i][0]*scale - X_shift, coor_g[i][1]*scale - Y_shift);
		}

		if (flag_image)
		  Image_stand->Canvas->Polyline(vert+2, 9);
		else
		  pCanvas->Polyline(vert+2, 9);

	  }
	}

	Draw_side_dvut(Image_stand, vertices1, vertices2, 1, 2, COLOR);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 9, 10, COLOR);
	/*
	Image_stand->Canvas->Pen->Color = clWhite;
	vert[0] = vertices1[7];
	vert[1] = vertices2[7];
	Image_stand->Canvas->Polyline(vert, 1);
	*/
	if (flag_image) {
	  Image_stand->Canvas->Pen->Color = clBlack;

	//----------------------------------------------------------------
	  Image_stand->Canvas->Brush->Color = clWhite;
	// Рисование второго  двутавра
	  Image_stand->Canvas->Brush->Color = clScrollBar;
	  Image_stand->Canvas->Polygon(vertices2, 20);
	// Рисование второй пластины
	  Image_stand->Canvas->Polygon(vertices2+21, 4);
	}
	else {
	  pCanvas->Pen->Color = clBlack;

	//----------------------------------------------------------------
	  pCanvas->Brush->Color = clWhite;
	// Рисование второго  двутавра
	  pCanvas->Brush->Color = clScrollBar;
	  pCanvas->Polygon(vertices2, 20);
	// Рисование второй пластины
	  pCanvas->Polygon(vertices2+21, 4);

    }
	//
	if (flag_ax)  {

	  Draw_axes_zero(Image_stand, index_view, vertices2[26].x, vertices2[26].y);

	  //Draw_axes_zero(Image_stand, index_view, (vertices2[0].x + vertices2[1].x)/2,
	  //				(0.5*(vertices2[0].y + vertices2[1].y) + param_sect.Zct/scale));

	}

}
//----------------------------------------------------------------------
// Рисование профиля тавра длиной len_prof*heigth в проекции index_view
void Draw_tavr(TImage * Image_stand, SECT_TAVR *sect, int index_view, float len_prof, int pole, bool flag_ax,
				  double attit, double alfa, double length_0) {
  // если length_0>0 - она принимается в качестве длины балки
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert[30];
  int rc;
  double t_conv[4][4];
  double z_mod;
  double coor_1[30][3];
  double coor_2[30][3];
  double coor_1g[30][3];
  double coor_2g[30][3];
  bool Sign[3] = {true, false, true};
  bool Sign_p[3] = {true, true, true};
  double X_shift, Y_shift, scale;
  int i;
  double h0;
  double k_att;
  double h1;
  double b_;
  double a_;
  double len_perfor;

  double * ParamProfil;

  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	pWidth = Image_stand->Width;
	pHeight = Image_stand->Height;
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }

	// установить вид и вычислить матрицу преобразования
	SetView_(t_conv, &z_mod, index_view, Sign, 2);

	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// Получить координаты переднего сечения тавра
	Coor_stand_tavr(sect, ParamProfil[parRAD_TAVR], coor_1, 0);

	// Параметры сечения
	GEOM_PARAM_SECT param_sect;
	COMMON_SECT common_sect;
	memcpy(&(common_sect.tavr), sect, sizeof(COMMON_SECT));

	Get_param_sect_comm(TAVR, &common_sect, &param_sect);
	// координата ц.т полного сечения
	coor_1[13][0] = sect->b1/2;
	coor_1[13][2] = 0;
	coor_1[13][1] = param_sect.Zct;

	//X0 =(coor_1[0][0] + coor_1[1][0])/2;
	//Y0 =(coor_1[5][1] + coor_1[6][1])/2;

	X0 = coor_1[13][0];
	Y0 = coor_1[13][1];

	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_1, 13, coor_1g);
	// Получить координаты заднего сечения тавра
	if (length_0 == 0) {
		Length = sect->h*len_prof;
	}
	else {
	   Length = length_0*1000;
	}

	for (i=0; i<14; i++) {
	  coor_2[i][0] = coor_1[i][0];
	  coor_2[i][1] = coor_1[i][1];
	  coor_2[i][2] = coor_1[i][2] + Length;
	}
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_2, 14, coor_2g);
	//--------------------------------------------------
	// Определить масштаб тавра
	Set_scale(pWidth, pHeight, z_mod, coor_1g, coor_2g, 14, &scale, &X_shift, &Y_shift, pole);

	// Получить точки контура прокатного тавра
	for (i=0; i<14; i++) {
	  vertices1[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
	}


	if (flag_image) {
	  Image_stand->Canvas->Brush->Color = COLOR;
	// Рисование заднего двутавра
	  Image_stand->Canvas->Polygon(vertices1, 12);

	  Image_stand->Canvas->Brush->Color = clWhite;
	  Image_stand->Canvas->Pen->Color = clBlack;
	}
	else {
	  pCanvas->Brush->Color = COLOR;
	// Рисование заднего двутавра
	  pCanvas->Polygon(vertices1, 12);

	  pCanvas->Brush->Color = clWhite;
	  pCanvas->Pen->Color = clBlack;
	}
	// второй тавр
	for (i=0; i<14; i++) {
	  vertices2[i] = Point(coor_2g[i][0]*scale - X_shift, coor_2g[i][1]*scale - Y_shift);
	}


	//----------------------------------------------------------------
	//
	Draw_side_dvut(Image_stand, vertices1, vertices2, 5, 6, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 1, 2, COLOR);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);

	if (flag_image) {
	  Image_stand->Canvas->Pen->Color = clBlack;

	  //--------------------------------------------
	  // Рисование второго  двутавра
	  Image_stand->Canvas->Brush->Color = clScrollBar;
	  Image_stand->Canvas->Polygon(vertices2, 12);
	}
	else {
	  pCanvas->Pen->Color = clBlack;

	  //--------------------------------------------
	  // Рисование второго  двутавра
	  pCanvas->Brush->Color = clScrollBar;
	  pCanvas->Polygon(vertices2, 12);
	}
	//
	if (flag_ax) {

	  Draw_axes_zero(Image_stand, index_view, vertices2[13].x, vertices2[13].y);
	}
	  //Draw_axes_zero(Image_stand, index_view, (vertices1[0].x + vertices1[1].x)/2,
	  //				(vertices1[0].y + vertices1[1].y + vertices1[10].y + vertices1[11].y)/4);

}
//----------------------------------------------------------------------
// Рисование профиля тавра длиной len_prof*heigth в проекции index_view
void Draw_tavr_plate(TImage * Image_stand, SECT_TAVR *sect, int index_view, float len_prof, int pole, bool flag_ax,
				  double attit, double alfa, double length_0, double plate_h, double plate_b, int index_composed) {
  // если length_0>0 - она принимается в качестве длины балки
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert[30];
  int rc;
  double t_conv[4][4];
  double z_mod;
  double coor_1[30][3];
  double coor_2[30][3];
  double coor_1g[30][3];
  double coor_2g[30][3];
  bool Sign[3] = {true, false, true};
  bool Sign_p[3] = {true, true, true};
  double X_shift, Y_shift, scale;
  int i;
  double h0;
  double k_att;
  double h1;
  double b_;
  double a_;
  double len_perfor;

  double * ParamProfil;

  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	pWidth = Image_stand->Width;
	pHeight = Image_stand->Height;
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }

	// установить вид и вычислить матрицу преобразования
	SetView_(t_conv, &z_mod, index_view, Sign, 2);

	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// Получить координаты переднего сечения тавра
	// Координата Y верхней точки тавра равна нулю
	Coor_stand_tavr(sect, ParamProfil[parRAD_TAVR], coor_1, index_composed);

	// Добавить координаты пластины
	// Координата Y верхней точки пластины для index_composed=1 равна -plate_h
	Coor_plate(sect->b1, sect->h + sect->h1, plate_h, plate_b, 13, coor_1, index_composed);

	// Параметры сечения
	GEOM_PARAM_SECT param_sect;
	COMMON_SECT common_sect;
	memcpy(&(common_sect.tavr), sect, sizeof(COMMON_SECT));

	Get_param_sect_composed(TAVR, &common_sect, plate_b, plate_h, &param_sect, index_composed);
	// координата ц.т полного сечения
	coor_1[18][0] = sect->b1/2;
	coor_1[18][2] = 0;
	//coor_1[18][1] = (param_sect.Ar*param_sect.Zct + plate_h*plate_b*(sect->h + 2*sect->h1 + plate_h*0.5))/
	//		(param_sect.Ar + plate_h*plate_b);
	if (index_composed==0)
	  coor_1[18][1] = param_sect.Zct;
	else
	  coor_1[18][1] = param_sect.Zct - plate_h;


	//X0 =(coor_1[0][0] + coor_1[1][0])/2;
	//Y0 =(coor_1[5][1] + coor_1[6][1])/2;

	X0 = coor_1[18][0];
	Y0 = coor_1[18][1];
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_1, 19, coor_1g);
	// Получить координаты заднего сечения тавра и пластины
	if (length_0 == 0) {
	   Length = sect->h*len_prof;
	}
	else {
	   Length = length_0*1000;
	}

	for (i=0; i<19; i++) {
	  coor_2[i][0] = coor_1[i][0];
	  coor_2[i][1] = coor_1[i][1];
	  coor_2[i][2] = coor_1[i][2] + Length;
	}
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_2, 19, coor_2g);
	//--------------------------------------------------
	// Определить масштаб тавра с пластиной
	Set_scale(pWidth, pHeight, z_mod, coor_1g, coor_2g, 19, &scale, &X_shift, &Y_shift, pole);

	// Получить точки контура прокатного тавра и пластины
	for (i=0; i<19; i++) {
	  vertices1[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
	}

	if (flag_image) {
	  Image_stand->Canvas->Brush->Color = COLOR;
	// Рисование заднего тавра
	  if (index_composed==0)
		Image_stand->Canvas->Polygon(vertices1, 12);
	  else
		Image_stand->Canvas->Polyline(vertices1, 4);

	// Рисование задней пластины
	  Image_stand->Canvas->Polygon(vertices1+13, 4);

	// !!Image_stand->Canvas->Polyline(vertices1+2, 7);

	  Image_stand->Canvas->Brush->Color = clWhite;
	  Image_stand->Canvas->Pen->Color = clBlack;
	}
	else {
	  pCanvas->Brush->Color = COLOR;
	// Рисование заднего тавра
	  if (index_composed==0)
		pCanvas->Polygon(vertices1, 12);
	  else
		pCanvas->Polyline(vertices1, 4);

	// Рисование задней пластины
	  pCanvas->Polygon(vertices1+13, 4);

	// !!Image_stand->Canvas->Polyline(vertices1+2, 7);

	  pCanvas->Brush->Color = clWhite;
	  pCanvas->Pen->Color = clBlack;
	}
	// второй тавр
	for (i=0; i<19; i++) {
	  vertices2[i] = Point(coor_2g[i][0]*scale - X_shift, coor_2g[i][1]*scale - Y_shift);
	}


	//----------------------------------------------------------------
	if (index_composed==0) {
		Draw_side_dvut(Image_stand, vertices1, vertices2, 13, 14, clWhite);
		Draw_side_dvut(Image_stand, vertices1, vertices2, 14, 15, COLOR);

		Draw_side_dvut(Image_stand, vertices1, vertices2, 5, 6, clWhite);
		Draw_side_dvut(Image_stand, vertices1, vertices2, 1, 2, COLOR);
		Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);
	}
	else {

		Draw_side_dvut(Image_stand, vertices1, vertices2, 8 ,9, clWhite);
		Draw_side_dvut(Image_stand, vertices1, vertices2, 5, 6, COLOR);
		Draw_side_dvut(Image_stand, vertices1, vertices2, 4, 5, clWhite);
		Draw_side_dvut(Image_stand, vertices1, vertices2, 1, 2, clWhite);

		Draw_side_dvut(Image_stand, vertices1, vertices2, 15, 16, clWhite);
		Draw_side_dvut(Image_stand, vertices1, vertices2, 14, 15, COLOR);
	}

	if (flag_image) {
	  Image_stand->Canvas->Pen->Color = clBlack;

	//--------------------------------------------
	// Рисование второго  двутавра
	  Image_stand->Canvas->Brush->Color = clScrollBar;
	  Image_stand->Canvas->Polygon(vertices2, 12);
	// Рисование второй пластины
	  Image_stand->Canvas->Polygon(vertices2+13, 4);
	}
	else {
	  pCanvas->Pen->Color = clBlack;

	//--------------------------------------------
	// Рисование второго  двутавра
	  pCanvas->Brush->Color = clScrollBar;
	  pCanvas->Polygon(vertices2, 12);
	// Рисование второй пластины
	  pCanvas->Polygon(vertices2+13, 4);
	}
	//
	if (flag_ax) {

	  Draw_axes_zero(Image_stand, index_view, vertices2[18].x, vertices2[18].y);
	}

}
//----------------------------------------------------------------------
// Рисование профиля сварного двутавра длиной len_prof*heigth
void Draw_dvutavr_weld(TImage * Image_weld, SECT_DVUTAVR *sect, int index_view, float len_prof, int pole, bool flag_ax, double length_0) {
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert[30];
  int rc;
  double t_conv[4][4];
  double z_mod;
  double coor_1[30][3];
  double coor_1g[30][3];
  double coor_2g[30][3];
  bool Sign[3] = {true, false, true};
  double X_shift, Y_shift, scale;
  int i;


	double * ParamProfil;

  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image_weld->Width, Image_weld->Height);
	pWidth = Image_weld->Width;
	pHeight = Image_weld->Height;
	Image_weld->Canvas->Pen->Color = clBlack;
	Image_weld->Canvas->Brush->Color = clWhite;
	Image_weld->Canvas->FillRect(NewRect);
	Image_weld->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }

	// установить вид и вычислить матрицу преобразования
	SetView_(t_conv, &z_mod, index_view, Sign, 2);

	//StandartProfil.SetProfil(sect->n_group);
	//ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// Получить координаты переднего сечения двутавра
	Coor_weld_dvutavr(sect, coor_1);
	X0 =(coor_1[0][0] + coor_1[1][0])/2;
	Y0 =(coor_1[3][1] + coor_1[4][1])/2;
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_1, 13, coor_1g);
	// Получить координаты заднего сечения двутавра
	if (length_0 == 0) {
	   Length = sect->h*len_prof;
	}
	else
	   Length = length_0*1000;

	for (i=0; i<13; i++) {
	  coor_1[i][2] = Length;
	}
	// преобразовать координаты в экранную систему
	Set_coorg_(t_conv, coor_1, 13, coor_2g);
	//--------------------------------------------------
	// Определить масштаб
	Set_scale(pWidth, pHeight, z_mod, coor_1g, coor_2g, 13, &scale, &X_shift, &Y_shift, pole);

	// Получить точки контура сварного двутавра
	for (i=0; i<13; i++) {
	 vertices1[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
	}


	if (flag_image) {
	  Image_weld->Canvas->Brush->Color = COLOR;
	  Image_weld->Canvas->Polygon(vertices1, 12);
	  Image_weld->Canvas->Brush->Color = clWhite;
	}
	else {
	  pCanvas->Brush->Color = COLOR;
	  pCanvas->Polygon(vertices1, 12);
	  pCanvas->Brush->Color = clWhite;
	}
	// второй сварной двутавр
	for (i=0; i<13; i++) {
	 vertices2[i] = Point(coor_2g[i][0]*scale - X_shift, coor_2g[i][1]*scale - Y_shift);
	}


	//----------------------------------------------------------------
	Draw_side_dvut(Image_weld, vertices1, vertices2, 8, 9, clWhite);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 4, 5, clWhite);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 5, 6, COLOR);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 3, 4, clWhite);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 1, 2, COLOR);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 0, 1, clWhite);

	if (flag_image) {
	  Image_weld->Canvas->Pen->Color = clBlack;

	//--------------------------------------------
	// Рисование второго  двутавра
	  Image_weld->Canvas->Brush->Color = clScrollBar;
	  Image_weld->Canvas->Polygon(vertices2, 12);
	}
	else {
	  pCanvas->Pen->Color = clBlack;

	//--------------------------------------------
	// Рисование второго  двутавра
	  pCanvas->Brush->Color = clScrollBar;
	  pCanvas->Polygon(vertices2, 12);
	}
	TPoint Vert0[2];
	Vert0[0] = vertices2[3];
	Vert0[1] = vertices2[10];
	if (flag_image)
	  Image_weld->Canvas->Polyline(Vert0, 1);
	else
	  pCanvas->Polyline(Vert0, 1);
	Vert0[0] = vertices2[4];
	Vert0[1] = vertices2[9];
	if (flag_image)
	  Image_weld->Canvas->Polyline(Vert0, 1);
	else
	  pCanvas->Polyline(Vert0, 1);
	//


	if (flag_ax)
	  Draw_axes_zero(Image_weld, index_view, (vertices2[0].x + vertices2[1].x)/2,
											(vertices2[0].y + vertices2[1].y + vertices2[6].y + vertices2[7].y)/4);
	  //Draw_axes_zero(Image_weld, index_view, (vertices1[0].x + vertices1[1].x)/2,
	  //										(vertices1[0].y + vertices1[1].y + vertices1[6].y + vertices1[7].y)/4);

	TPoint Point0_r;
	TPoint Point1_r;

	if (flag_image)
	  Image_weld->Canvas->Brush->Style=bsClear;
	/*
	//--------------- Размеры -----------------------------
	// Ширина полки
	Point0_r = vertices[0];
	Point1_r = vertices[1];

	pCanvas_Dim_vt(Image_weld, Point0_r, Point1_r, orHORIZ, sideUP, "bf",
				 13, 0, 0, 0);
	// Высота профиля
	Point0_r = vertices[11];
	Point1_r = vertices[0];

	pCanvas_Dim_vt(Image_weld, Point0_r, Point1_r, orVERT, sideLEFT, "h",
				 6, 0, 4, 0);
	// Толщина пояса профиля
	Point0_r = vertices[1];
	Point1_r = vertices[2];

	int posY = vertices[2].y - vertices[1].y;
	pCanvas_Dim_vt(Image_weld, Point0_r, Point1_r, orVERT, sideRIGHT, "tf",
				 6, 0, -4, -posY/2 - 4);
	// Толщина стенки
	Point0_r = vertices[15];
	Point1_r = vertices[6];

	pCanvas_Dim_vt(Image_weld, Point0_r, Point1_r, orHORIZ, sideUP, "tw",
				 30, 0, 13, 0);
	*/

}
//----------------------------------------------------------------------
// рисование прокатного двутавра в косоугольной аксонометрии
void Draw_dvutavr_oblic(TImage * Image_stand, SECT_DVUTAVR *sect) {
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert_rect[30];
  int zero, zero1, zero2;
  double zero_f, zero1_f, zero2_f;
  double scale_1, scale;
  int rc;


	double * ParamProfil;
	int shiftY = SHIFTY;
	int shiftX = SHIFTX;

  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	pWidth = Image_stand->Width;
	pHeight = Image_stand->Height;
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }


	scale = (pWidth-65)/(1e0*sect->b2);
	scale_1 = MIN(scale, pWidth-65/(1e0*sect->b1));
	scale = MIN(scale_1,(pHeight-60)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero_f = (pHeight - (sect->h + sect->h1 + sect->h2)*scale)/2 + 20;
	zero1_f = (pWidth - sect->b2*scale)/2 - 40;
	zero2_f = (pWidth - sect->b1*scale)/2 - 40;

	zero = zero_f;
	zero1 = zero1_f;
	zero2 = zero2_f;

	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	//  Первый двутавр
	Point_stand_dvutavr(zero - shiftY, zero1 + shiftX, zero2 + shiftX, sect, ParamProfil[parRAD], scale, vertices1); // получить точки контура двутавра

	if (flag_image) {
	  Image_stand->Canvas->Brush->Color = COLOR;
	  Image_stand->Canvas->Polygon(vertices1, 20);
	  Image_stand->Canvas->Brush->Color = clWhite;
	}
	else {
	  pCanvas->Brush->Color = COLOR;
	  pCanvas->Polygon(vertices1, 20);
	  pCanvas->Brush->Color = clWhite;
	}
	//  второй двутавр
	Point_stand_dvutavr(zero, zero1, zero2, sect, ParamProfil[parRAD], scale, vertices2); // получить точки контура двутавра


	//----------------------------------------------------------------
	Draw_side_dvut(Image_stand, vertices1, vertices2, 12, 13, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 6, 7, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 7, 8, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 8, 9, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 5, 6, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 1, 2, COLOR);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 0, 1, clWhite);
	Draw_side_dvut(Image_stand, vertices1, vertices2, 9, 10, COLOR);

	if (flag_image) {
	//----------------------------------------------------------------
	  Image_stand->Canvas->Brush->Color = clWhite;
	//----------------------------------------------------------------
	// Рисование второго  двутавра
	  Image_stand->Canvas->Brush->Color = clScrollBar;
	  Image_stand->Canvas->Polygon(vertices2, 20);
	}
	else {
	//----------------------------------------------------------------
	  pCanvas->Brush->Color = clWhite;
	//----------------------------------------------------------------
	// Рисование второго  двутавра
	  pCanvas->Brush->Color = clScrollBar;
	  pCanvas->Polygon(vertices2, 20);
	}
	Draw_axes_zero(Image_stand, vOBLIC, (vertices2[0].x + vertices2[1].x)/2, (vertices2[0].y + vertices2[11].y)/2);

	TPoint Point0_r;
	TPoint Point1_r;

	if (flag_image)
	  Image_stand->Canvas->Brush->Style=bsClear;
	else
	  pCanvas->Brush->Style=bsClear;
}
//----------------------------------------------------------------------
// рисование сварного двутавра в косоугольной аксонометрии
void Draw_dvutavr_weld_oblic(TImage * Image_weld, SECT_DVUTAVR *sect) {
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vert_rect[30];
  int zero, zero1, zero2;
  double zero_f, zero1_f, zero2_f;
  double scale_1, scale;
  int rc;


	double * ParamProfil;
	int shiftY = SHIFTY;
	int shiftX = SHIFTX;

  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image_weld->Width, Image_weld->Height);
	pWidth = Image_weld->Width;
	pHeight = Image_weld->Height;
	Image_weld->Canvas->Pen->Color = clBlack;
	Image_weld->Canvas->Brush->Color = clWhite;
	Image_weld->Canvas->FillRect(NewRect);
	Image_weld->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }

	scale = (pWidth-65)/(1e0*sect->b2);
	scale_1 = MIN(scale,(pWidth-65)/(1e0*sect->b1));
	scale = MIN(scale_1,(pHeight-60)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero_f = (pHeight - (sect->h + sect->h1 + sect->h2)*scale)/2 + 20;
	zero1_f = (pWidth - sect->b2*scale)/2 - 40;
	zero2_f = (pWidth - sect->b1*scale)/2 - 40;

	zero = zero_f;
	zero1 = zero1_f;
	zero2 = zero2_f;

	//  Точки первого сварного двутавра
	Point_weld_dvutavr(zero - shiftY, zero1 + shiftX, zero2 + shiftX, sect, scale, vertices1); // получить точки контура двутавра

	if (flag_image) {
	  Image_weld->Canvas->Brush->Color = COLOR;
	//Image_weld->Canvas->Polygon(vertices1, 12);
	  Image_weld->Canvas->Brush->Color = clWhite;
	}
	else {
	  pCanvas->Brush->Color = COLOR;
	//Image_weld->Canvas->Polygon(vertices1, 12);
	  pCanvas->Brush->Color = clWhite;
	}
	//  второй двутавр
	Point_weld_dvutavr(zero, zero1, zero2, sect, scale, vertices2); // получить точки контура двутавра


	//----------------------------------------------------------------
	Draw_side_dvut(Image_weld, vertices1, vertices2, 8, 9, clWhite);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 4, 5, clWhite);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 5, 6, COLOR);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 3, 4, clWhite);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 1, 2, COLOR);
	Draw_side_dvut(Image_weld, vertices1, vertices2, 0, 1, clWhite);
	//
	//----------------------------------------------------------------
	if (flag_image) {
	  Image_weld->Canvas->Brush->Color = clWhite;
	//----------------------------------------------------------------
	//--------------------------------------------
	// Рисование второго  двутавра
	  Image_weld->Canvas->Brush->Color = clScrollBar;
	  Image_weld->Canvas->Polygon(vertices2, 12);
	}
	else {
	  pCanvas->Brush->Color = clWhite;
	//----------------------------------------------------------------
	//--------------------------------------------
	// Рисование второго  двутавра
	  pCanvas->Brush->Color = clScrollBar;
	  pCanvas->Polygon(vertices2, 12);
	}
	Draw_axes_zero(Image_weld, vOBLIC, (vertices2[0].x + vertices2[1].x)/2, (vertices2[0].y + vertices2[7].y)/2);

	TPoint Vert0[2];
	Vert0[0] = vertices2[3];
	Vert0[1] = vertices2[10];
	if (flag_image)
	  Image_weld->Canvas->Polyline(Vert0, 1);
	else
	  pCanvas->Polyline(Vert0, 1);
	Vert0[0] = vertices2[4];
	Vert0[1] = vertices2[9];
	if (flag_image)  {
	  Image_weld->Canvas->Polyline(Vert0, 1);
	  Image_weld->Canvas->Brush->Style=bsClear;
	}
	else {
	  pCanvas->Polyline(Vert0, 1);
	  pCanvas->Brush->Style=bsClear;
	}


}
//---------------------------------------------------------------------------
// рисование сторон двутавра
void Draw_side_dvut(TImage * Image_stand, TPoint *vertices1, TPoint *vertices2, int n, int m, TColor color) {
  TPoint vert_rect[10];
	//----------------------------------------------------------------
  if (flag_image) {
	Image_stand->Canvas->Brush->Color = color;
	vert_rect[0] = vertices1[n];
	vert_rect[1] = vertices1[m];
	vert_rect[2] = vertices2[m];
	vert_rect[3] = vertices2[n];
	vert_rect[4] = vertices1[n];
	Image_stand->Canvas->Polygon(vert_rect, 4);
  }
  else {
	pCanvas->Brush->Color = color;
	vert_rect[0] = vertices1[n];
	vert_rect[1] = vertices1[m];
	vert_rect[2] = vertices2[m];
	vert_rect[3] = vertices2[n];
	vert_rect[4] = vertices1[n];
	pCanvas->Polygon(vert_rect, 4);
  }
}
//---------------------------------------------------------------------------
// рисование квадратной трубы
void Draw_tube(TImage * Image1, COMMON_SECT *com_sect, int type_tube, int index_view, float len_prof, int pole, bool flag, double length_0) {
  switch (type_tube) {
  case typeSQUARE:
  case typeRECT:
	Draw_rect_tube(Image1, com_sect, type_tube, index_view, len_prof, pole, flag, length_0);
  break;
  case typeCIRC:
	Draw_circular_tube(Image1, &com_sect->circ, index_view, len_prof, pole, flag, length_0);
  break;
  }
}
//---------------------------------------------------------------------------
// рисование квадратной и прямоугольной трубы
void Draw_rect_tube(TImage * Image1, COMMON_SECT *com_sect, int type_tube, int index_view, float len_prof, int pole, bool flag, double length_0) {
  TPoint vertices1[30];
  TPoint vertices2[30];
  TPoint vertices3[30];
  TPoint vertices4[30];
  double scale;
  int rc;
  double h_c, b_c, r_c, r2_c, t_;
  double coor[20][3];
  double coor_1g[20][3];
  double coor_2g[20][3];
  double t_conv[4][4];
  double z_mod, zmax, delta_z;
  bool Sign[3] = {true, false, true};
  int i;
  double X_shift, Y_shift;
  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image1->Width,Image1->Height);
	pWidth = Image1->Width;
	pHeight = Image1->Height;
	Image1->Canvas->Pen->Color = clBlack;
	Image1->Canvas->Brush->Color = clWhite;
	Image1->Canvas->FillRect(NewRect);
	Image1->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }
  // установить вид и вычислить матрицу преобразования
  SetView_(t_conv, &z_mod, index_view, Sign, 2);

  if (type_tube == typeSQUARE) {

	h_c = com_sect->square.side;
	b_c = com_sect->square.side;
	r_c = com_sect->square.rad;
	r2_c = Round(r_c - r_c*cos(45/57.3), 0);
  }
  else {

	h_c = com_sect->rect.h;
	b_c = com_sect->rect.b;
	r_c = com_sect->rect.rad;
	r2_c = Round(r_c - r_c*cos(45/57.3), 0);
  }
  // Точки дальнего контура трубы
  Coor_rect(h_c, b_c, r_c, r2_c, 0.0, coor);
  // преобразовать координаты в экранную систему
  Set_coorg_(t_conv, coor, 13, coor_1g);
  // Получить координаты переднего сечения трубы
  if (length_0 == 0) {
	   Length = h_c*len_prof;
  }
  else
	   Length = length_0*1000;

  //	for (i=0; i<13; i++) {
  //	  coor_1[i][2] = Length;
  //	}

  for (i=0; i<13; i++) {
	coor[i][2] = Length;
  }
  // преобразовать координаты в экранную систему
  Set_coorg_(t_conv, coor, 13, coor_2g);
  //--------------------------------------------------
  // Определить масштаб
  Set_scale(pWidth, pHeight, z_mod, coor_1g, coor_2g, 13, &scale, &X_shift, &Y_shift, pole);

  // Точки заднего сечения
  for (int i=0; i<13; i++) {
	 vertices1[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
  }

//---------------------------------------------------------------
  for (int i=0; i<13; i++) {
	 vertices2[i] = Point(coor_2g[i][0]*scale - X_shift, coor_2g[i][1]*scale - Y_shift);
  }

  if (flag_image) {
	Image1->Canvas->Brush->Color = COLOR;
  // Рисование залитого полигона внешнего контура переднего сечения
	Image1->Canvas->Polygon(vertices2, 12);
  }
  else {
	pCanvas->Brush->Color = COLOR;
  // Рисование залитого полигона внешнего контура переднего сечения
	pCanvas->Polygon(vertices2, 12);
  }

  if (type_tube == typeSQUARE) {
	t_ = com_sect->square.thickness;
  }
  else {
	t_ = com_sect->rect.h1;
  }
  Coor_rect(h_c, b_c, r_c, r2_c, t_, coor);

  X0 =(coor[3][0] + coor[4][0])/2;
  Y0 =(coor[0][1] + coor[1][1] + coor[6][1] + coor[7][1])/4;

  for (i=0; i<13; i++) {
	coor[i][2] = Length;
  }
  // преобразовать координаты в экранную систему
  Set_coorg_(t_conv, coor, 13, coor_1g);

  for (int i=0; i<13; i++) {
	 vertices3[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
  }
  //------------------------------------------------------
  if (flag_image) {
  // Внутренний контур
	Image1->Canvas->Brush->Color = clWhite;
	Image1->Canvas->Polygon(vertices3, 12);
  }
  else {
  // Внутренний контур
	pCanvas->Brush->Color = clWhite;
	pCanvas->Polygon(vertices3, 12);
  }
  vertices4[0] = vertices2[11];
  vertices4[1] = vertices1[11];
  vertices4[2] = vertices1[10];
  vertices4[3] = vertices1[9];
  vertices4[4] = vertices1[8];
  vertices4[5] = vertices2[8];
  vertices4[6] = vertices2[9];
  vertices4[7] = vertices2[10];
  vertices4[8] = vertices2[11];
  if (flag_image)
	Image1->Canvas->Polygon(vertices4, 8);
  else
	pCanvas->Polygon(vertices4, 8);
  vertices4[0] = vertices2[8];
  vertices4[1] = vertices1[8];
  vertices4[2] = vertices1[7];
  vertices4[3] = vertices1[6];
  vertices4[4] = vertices1[5];
  vertices4[5] = vertices2[5];
  vertices4[6] = vertices2[6];
  vertices4[7] = vertices2[7];
  vertices4[8] = vertices2[8];
  if (flag_image) {
	Image1->Canvas->Brush->Color = clWhite;
	Image1->Canvas->Polygon(vertices4, 8);
  }
  else {
	pCanvas->Brush->Color = clWhite;
	pCanvas->Polygon(vertices4, 8);
  }

  if (flag)
	Draw_axes_zero(Image1, index_view, (vertices2[3].x + vertices2[4].x)/2,
						 (vertices2[0].y + vertices2[1].y + vertices2[6].y + vertices2[7].y)/4);
	//Draw_axes_zero(Image1, index_view, (vertices1[3].x + vertices1[4].x)/2,
	//					 (vertices1[0].y + vertices1[1].y + vertices1[6].y + vertices1[7].y)/4);
}
//---------------------------------------------------------------------------
// рисование круглой трубы
void Draw_circular_tube(TImage * Image1, SECT_CIRC *sect, int index_view, float len_prof, int pole, bool flag, double length_0) {
  TPoint vertices1[70];
  TPoint vertices2[70];
  TPoint vertices3[70];
  TPoint vertices4[12];
  double scale, X_shift, Y_shift;
  int i, rc;
  double rad;
  double coor[70][3];
  double coor_1g[70][3];
  double coor_2g[70][3];
  double t_conv[4][4];
  double z_mod;
  bool Sign[3] = {true, false, true};
  int n = 60;
  int pWidth, pHeight;

  if (flag_image) {
	TRect NewRect = Rect(0, 0, Image1->Width,Image1->Height);
	pWidth = Image1->Width;
	pHeight = Image1->Height;
	Image1->Canvas->Pen->Color = clBlack;
	Image1->Canvas->Brush->Color = clWhite;
	Image1->Canvas->FillRect(NewRect);
	Image1->Canvas->Rectangle(0, 0, pWidth, pHeight);
  }
  else {
	TRect NewRect = Rect(0, 0, Page_Width, Page_Height);
	pWidth = Page_Width;
	pHeight = Page_Height;
	pCanvas->Pen->Color = clBlack;
	pCanvas->Brush->Color = clWhite;
	pCanvas->FillRect(NewRect);
	pCanvas->Rectangle(0, 0, pWidth, pHeight);
  }

  // установить вид и вычислить матрицу преобразования
  SetView_(t_conv, &z_mod, index_view, Sign, 2);

  rad = sect->diameter/2;
  // Точки дальнего внешнего контура трубы
  Coor_circ(n, rad, 0.0, coor);
  // преобразовать координаты в экранную систему
  Set_coorg_(t_conv, coor, n+2, coor_1g);
  // Получить координаты передего сечения трубы
   if (length_0 == 0) {
	   Length = 2*rad*len_prof;
  }
  else
	   Length = length_0*1000;
  for (i=0; i<n+2; i++) {
	coor[i][2] = Length;
  }
  // преобразовать координаты в экранную систему
  Set_coorg_(t_conv, coor, n+2, coor_2g);
  //--------------------------------------------------
  // Определить масштаб
  Set_scale(pWidth, pHeight, z_mod, coor_1g, coor_2g, n+1, &scale, &X_shift, &Y_shift, pole);

  for (int i=0; i<n+2; i++) {
	 vertices1[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
  }

  if (flag_image) {
  // Рисование полилинии заднего контура
	Image1->Canvas->Brush->Color = clWhite;
	Image1->Canvas->Polyline(vertices1 + 7, n/2 + 2);
  }
  else {
  // Рисование полилинии заднего контура
	pCanvas->Brush->Color = clWhite;
	pCanvas->Polyline(vertices1 + 7, n/2 + 2);
  }

  // Точки ближнего контура трубы
  for (int i=0; i<n+2; i++) {
	 vertices2[i] = Point(coor_2g[i][0]*scale - X_shift, coor_2g[i][1]*scale - Y_shift);
  }

  if (flag_image) {
	Image1->Canvas->Brush->Color = COLOR;
  // Рисование залитого полигона
	Image1->Canvas->Polygon(vertices2, n);
  }
  else {
	pCanvas->Brush->Color = COLOR;
  // Рисование залитого полигона
	pCanvas->Polygon(vertices2, n);
  }
  // Точки внутреннего контура
  Coor_circ(n, rad, sect->thickness, coor);
  // Получить координаты передего сечения трубы
  for (i=0; i<n+2; i++) {
	coor[i][2] = Length;
  }
  // преобразовать координаты в экранную систему
  Set_coorg_(t_conv, coor, n+1, coor_1g);
  for (int i=0; i<n+2; i++) {
	 vertices3[i] = Point(coor_1g[i][0]*scale - X_shift, coor_1g[i][1]*scale - Y_shift);
  }

  if (flag_image) {
  // Рисование белого полигона
	Image1->Canvas->Brush->Color = clWhite;
	Image1->Canvas->Polygon(vertices3, n);
  }
  else {
  // Рисование белого полигона
	pCanvas->Brush->Color = clWhite;
	pCanvas->Polygon(vertices3, n);
  }
  int k = n/2 + 7;

  vertices4[0] = vertices1[k];
  vertices4[1] = vertices2[k];
  if (flag_image)
	Image1->Canvas->Polyline(vertices4, 1);
  else
	pCanvas->Polyline(vertices4, 1);

  k -= 5;
  vertices4[0] = vertices1[k];
  vertices4[1] = vertices2[k];
  if (flag_image)
	Image1->Canvas->Polyline(vertices4, 1);
  else
	pCanvas->Polyline(vertices4, 1);
  k -= 5;
  vertices4[0] = vertices1[k];
  vertices4[1] = vertices2[k];
  if (flag_image)
	Image1->Canvas->Polyline(vertices4, 1);
  else
	pCanvas->Polyline(vertices4, 1);
  k -= 10;
  vertices4[0] = vertices1[k];
  vertices4[1] = vertices2[k];
  if (flag_image)
	Image1->Canvas->Polyline(vertices4, 1);
  else
	pCanvas->Polyline(vertices4, 1);
  k -= 5;
  vertices4[0] = vertices1[k];
  vertices4[1] = vertices2[k];
  if (flag_image)
	Image1->Canvas->Polyline(vertices4, 1);
  else
	pCanvas->Polyline(vertices4, 1);
  k -= 5;
  vertices4[0] = vertices1[k];
  vertices4[1] = vertices2[k];
  if (flag_image)
	Image1->Canvas->Polyline(vertices4, 1);
  else
	pCanvas->Polyline(vertices4, 1);

  X0 = 0;
  Y0 = 0;
  if (flag)
	Draw_axes_zero(Image1, index_view, vertices2[n+1].x, vertices2[n+1].y);
	//Draw_axes_zero(Image1, index_view, vertices1[n+1].x, vertices1[n+1].y);
}
//---------------------------------------------------------------------------
// Рисование системы координат
void  Draw_axes_zero(TImage *Image_Ax, int index_view, int x1, int y1) {
  TPoint points[10];
  int x0, y0;
  x0 = x1;
  y0 = y1;

  points[0]=Point(x0, y0);
  points[1]=Point(x0, y0 - 40);    // Ось Y

  CoorAx.PutArrow(points, 0, MAX_PIC);
  CoorAx.SetArrow();

  if (flag_image) {
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Polyline(CoorAx.LArrow, 2);
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Brush->Color=clBlack;
	Image_Ax->Canvas->Polygon(CoorAx.Ar, 3);
	Image_Ax->Canvas->Brush->Color=clWhite;
  }
  else {
	pCanvas->Pen->Width=1;
	pCanvas->Polyline(CoorAx.LArrow, 2);
	pCanvas->Pen->Width=1;
	pCanvas->Brush->Color=clBlack;
	pCanvas->Polygon(CoorAx.Ar, 3);
	pCanvas->Brush->Color=clWhite;
  }
  points[0]=Point(x0, y0);
  switch (index_view) {
  case vDIMETR:
	 //points[1]=Point(x0 + 40, y0 + 9);  // Ось Y
	 points[1]=Point(x0 - 40, y0 - 9);  // Ось Y
  break;
  case vISOMETR:
	 //points[1]=Point(x0 + 40, y0 + 23);  // Ось Y
	 points[1]=Point(x0 - 40, y0 - 23);  // Ось Y
  break;
  case vISO_VERT:
	 //points[1]=Point(x0 + 40, y0 + 23);  // Ось Y
	 points[1]=Point(x0 - 40, y0 - 23);  // Ось Z
  break;
  case vOBLIC:
  case vPLANE:
	 //points[1]=Point(x0 + 40, y0);  // Ось Y
	 points[1]=Point(x0 - 40, y0);  // Ось Y
  break;
  }


  CoorAx.PutArrow(points, 0, MAX_PIC);
  CoorAx.SetArrow();

  if (flag_image) {
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Polyline(CoorAx.LArrow, 2);
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Brush->Color=clBlack;
	Image_Ax->Canvas->Polygon(CoorAx.Ar, 3);
	Image_Ax->Canvas->Brush->Color=clWhite;
  }
  else {
	pCanvas->Pen->Width=1;
	pCanvas->Polyline(CoorAx.LArrow, 2);
	pCanvas->Pen->Width=1;
	pCanvas->Brush->Color=clBlack;
	pCanvas->Polygon(CoorAx.Ar, 3);
	pCanvas->Brush->Color=clWhite;
  }

  points[0]=Point(x0, y0);
  switch (index_view) {
  case vDIMETR:
	//points[1]=Point(x0 - 30, y0 + 24);
	points[1]=Point(x0 + 30, y0 - 24);
  break;
  case vISOMETR:
	//points[1]=Point(x0 - 40, y0 + 23);
	points[1]=Point(x0 + 40, y0 - 23);
  break;
  case vISO_VERT:
	//points[1]=Point(x0 - 40, y0 + 23);
	points[1]=Point(x0 + 40, y0 - 23);
  break;
  case vOBLIC:
	//points[1]=Point(x0 - 40, y0 + 20);
	points[1]=Point(x0 + 40, y0 - 20);
  break;
  }

  switch (index_view) {
  case vOBLIC:
  case vISOMETR:
  case vDIMETR:
	CoorAx.PutArrow(points, 0, MAX_PIC);
	CoorAx.SetArrow();

  if (flag_image) {
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Polyline(CoorAx.LArrow, 2);
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Brush->Color=clBlack;
	Image_Ax->Canvas->Polygon(CoorAx.Ar, 3);
	Image_Ax->Canvas->Brush->Color=clWhite;
	//Image_Ax->Canvas->TextOut(x0 - 40, y0 + 20 + 4,"X");   // Изменено Z на X
	Image_Ax->Canvas->TextOut(x0 + 40, y0 - 20 + 4,"X");   // Изменено Z на X
	Image_Ax->Canvas->Ellipse(x0-4, y0-4, x0+4, y0+4);
	Image_Ax->Canvas->Brush->Style=bsSolid;
	Image_Ax->Canvas->TextOut(x0 + 6, y0 - 40,"Z");       // Изменено Y на Z
  //Image_Ax->Canvas->TextOut(x0 + 44, y0 + 2,"Y");       // Изменено X на Y
	Image_Ax->Canvas->TextOut(x0 - 44, y0 - 20,"Y");       // Изменено X на Y
	Image_Ax->Canvas->Brush->Style=bsSolid;
  }
  else {
	pCanvas->Pen->Width=1;
	pCanvas->Polyline(CoorAx.LArrow, 2);
	pCanvas->Pen->Width=1;
	pCanvas->Brush->Color=clBlack;
	pCanvas->Polygon(CoorAx.Ar, 3);
	pCanvas->Brush->Color=clWhite;
	//Image_Ax->Canvas->TextOut(x0 - 40, y0 + 20 + 4,"X");   // Изменено Z на X
	pCanvas->TextOut(x0 + 40, y0 - 20 + 4,"X");   // Изменено Z на X
	pCanvas->Ellipse(x0-4, y0-4, x0+4, y0+4);
	pCanvas->Brush->Style=bsSolid;
	pCanvas->TextOut(x0 + 6, y0 - 40,"Z");       // Изменено Y на Z
  //Image_Ax->Canvas->TextOut(x0 + 44, y0 + 2,"Y");       // Изменено X на Y
	pCanvas->TextOut(x0 - 44, y0 - 20,"Y");       // Изменено X на Y
	pCanvas->Brush->Style=bsSolid;
  }
  break;
  case vPLANE:
	CoorAx.PutArrow(points, 0, MAX_PIC);
	CoorAx.SetArrow();

  if (flag_image) {
	Image_Ax->Canvas->TextOut(x0 + 40, y0 - 20 + 4,"X");   // Изменено Z на X
	Image_Ax->Canvas->Ellipse(x0-4, y0-4, x0+4, y0+4);
	Image_Ax->Canvas->Brush->Style=bsSolid;
	Image_Ax->Canvas->TextOut(x0 + 6, y0 - 40,"Z");       // Изменено Y на Z
  //Image_Ax->Canvas->TextOut(x0 + 44, y0 + 2,"Y");       // Изменено X на Y
	Image_Ax->Canvas->TextOut(x0 - 44, y0 - 20,"Y");       // Изменено X на Y
	Image_Ax->Canvas->Brush->Style=bsSolid;
  }
  else {
	pCanvas->TextOut(x0 + 40, y0 - 20 + 4,"X");   // Изменено Z на X
	pCanvas->Ellipse(x0-4, y0-4, x0+4, y0+4);
	pCanvas->Brush->Style=bsSolid;
	pCanvas->TextOut(x0 + 6, y0 - 40,"Z");       // Изменено Y на Z
  //Image_Ax->Canvas->TextOut(x0 + 44, y0 + 2,"Y");       // Изменено X на Y
	pCanvas->TextOut(x0 - 44, y0 - 20,"Y");       // Изменено X на Y
	pCanvas->Brush->Style=bsSolid;
  }
  break;
  case vISO_VERT:
	CoorAx.PutArrow(points, 0, MAX_PIC);
	CoorAx.SetArrow();

  if (flag_image) {
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Polyline(CoorAx.LArrow, 2);
	Image_Ax->Canvas->Pen->Width=1;
	Image_Ax->Canvas->Brush->Color=clBlack;
	Image_Ax->Canvas->Polygon(CoorAx.Ar, 3);
	Image_Ax->Canvas->Brush->Color=clWhite;
	//Image_Ax->Canvas->TextOut(x0 - 40, y0 + 20 + 4,"X");
	Image_Ax->Canvas->TextOut(x0 + 40, y0 - 20 + 4,"Y");
	Image_Ax->Canvas->Ellipse(x0-4, y0-4, x0+4, y0+4);
	Image_Ax->Canvas->Brush->Style=bsSolid;
	Image_Ax->Canvas->TextOut(x0 + 6, y0 - 40,"X");
  //Image_Ax->Canvas->TextOut(x0 + 44, y0 + 2,"Y");
	Image_Ax->Canvas->TextOut(x0 - 48, y0 - 22,"Z");
	Image_Ax->Canvas->Brush->Style=bsSolid;
  }
  else {
	pCanvas->Pen->Width=1;
	pCanvas->Polyline(CoorAx.LArrow, 2);
	pCanvas->Pen->Width=1;
	pCanvas->Brush->Color=clBlack;
	pCanvas->Polygon(CoorAx.Ar, 3);
	pCanvas->Brush->Color=clWhite;
	//Image_Ax->Canvas->TextOut(x0 - 40, y0 + 20 + 4,"X");
	pCanvas->TextOut(x0 + 40, y0 - 20 + 4,"Y");
	pCanvas->Ellipse(x0-4, y0-4, x0+4, y0+4);
	pCanvas->Brush->Style=bsSolid;
	pCanvas->TextOut(x0 + 6, y0 - 40,"X");
  //Image_Ax->Canvas->TextOut(x0 + 44, y0 + 2,"Y");
	pCanvas->TextOut(x0 - 48, y0 - 22,"Z");
	pCanvas->Brush->Style=bsSolid;
  }
  break;
  }
}
//----------------------------------------------------------------------
// рисование вектора силы
void  draw_load(TImage *Image1, double *x0, double *x1, double *x2, double value, double SignLoad, double Scale, bool flag_sign) {

	   TColor Bcolor;
	   //TPoint vertex[10];
	   TPoint points[10];

	   points[0]=Point(x0[0], x0[1]);
	   points[1]=Point(x1[0], x1[1]);

	   CoorAx.PutArrow(points, 0, MAX_PIC);
	   CoorAx.SetArrow();

	   Image1->Canvas->Polyline(CoorAx.LArrow, 2);
	   Image1->Canvas->Polyline(CoorAx.Ar, 3);
	   Bcolor = Image1->Canvas->Brush->Color;
	   Image1->Canvas->Brush->Style=bsSolid;
	   if (value!=0 && flag_sign)
		  Image1->Canvas->TextOut(x2[0], x2[1], FloatToStr(value));
	   Image1->Canvas->Brush->Style=bsSolid;
	   Image1->Canvas->Brush->Color=Bcolor;

}
//----------------------------------------------------------------------
// рисование стрелки силы
void  draw_load_ar(TImage *Image1, double coor_g[][3], double value, bool flag_sign, int index_ax, int index_brush) {

	   TColor Bcolor;
	   //TPoint vertex[10];
	   TPoint points[30];

	   Image1->Canvas->Brush->Style=bsSolid;
	   if (flag_image) {
		 if (index_brush==0)
		   Image1->Canvas->Brush->Color = clWhite;
		 else
		   Image1->Canvas->Brush->Color = Image1->Canvas->Pen->Color;
	   }
	   else {
		 if (index_brush==0)
		   pCanvas->Brush->Color = clWhite;
		 else
		   pCanvas->Brush->Color = pCanvas->Pen->Color;
	   }
	   for (int i=0; i<9; i++) {
		 points[i] = Point(coor_g[i][0], coor_g[i][1]);
	   }

	   pCanvas_Polygon(Image1, points, 8);
	   pBrush_Color(Image1, clWhite);

	   if (value!=0 && flag_sign) {
		  int sh = 5;
		  if (value<0 && index_ax == 1) // для вертикальной силы
			sh = -12;
		  pCanvas_TextOut(Image1, points[4].x - 5, points[4].y + sh, FloatToStr(value));
	   }
	   //Image1->Canvas->Brush->Color=Bcolor;

}
// рисование размерной линии
void  draw_dim(TImage *Image1, double coor_g[][3], double value) {

	   TPoint points[3];

	   pPen_Color(Image1, clBlack);
	   for (int i=0; i<2; i++) {
		 points[i] = Point(coor_g[i][0], coor_g[i][1]);
	   }
	   pCanvas_Polyline(Image1, points, 1);

	   pCanvas_TextOut(Image1, points[1].x - 5, points[1].y - 5, FloatToStr(value));

}
//----------------------------------------------------------------------
// рисование momenta
void  draw_moment(TImage *Image1, double coor_g[][3], double value, bool flag_sign) {

	   TColor Bcolor;
	   //TPoint vertex[10];
	   TPoint points[30];
	   TPoint point_Ar[2];

	   pPen_Width(Image1, 2);

	   for (int i=0; i< 20; i++) {
		 points[i] = Point(coor_g[i][0], coor_g[i][1]);
	   }
	   pCanvas_Polyline(Image1, points, 19);

	   if (value > 0)  {
		 point_Ar[1] = Point(coor_g[0][0], coor_g[0][1]);
		 point_Ar[0] = Point(coor_g[2][0], coor_g[2][1]);
	   }
	   else {
		 point_Ar[1] = Point(coor_g[19][0], coor_g[19][1]);
		 point_Ar[0] = Point(coor_g[17][0], coor_g[17][1]);
	   }
	   CoorAx.PutArrow(point_Ar, 0, MAX_PIC*2);
	   CoorAx.SetArrow();

	   pBrush_Style(Image1, bsSolid);
	   pCanvas_Polyline(Image1, CoorAx.LArrow, 2);
	   pCanvas_Polygon(Image1, CoorAx.Ar, 3);
	   pPen_Width(Image1, 1);
	   if (flag_image)
		 Bcolor = Image1->Canvas->Brush->Color;
	   else
		 Bcolor = pCanvas->Brush->Color;
	   pBrush_Style(Image1, bsSolid);
	   if (value!=0 && flag_sign)
		 pCanvas_TextOut(Image1, point_Ar[1].x - 5, point_Ar[1].y + 5, FloatToStr(value));
	   pBrush_Style(Image1, bsSolid);
	   pBrush_Color(Image1, Bcolor);

}

//---------------------------------------------------------------
// Получить координаты и длину
void Get_XY_Len(double *x0, double *y0, double *length) {
  *x0 = X0; *y0 = Y0; *length = Length;
}
//----------------------------------------------------------------------
// рисование стандартного двутавра
//void __fastcall TSectSelectCom_ParamFrame::draw_dvutavr(TImage * Image1, SECT_DVUTAVR *sect) {
void draw_dvutavr(TImage * Image_stand, SECT_DVUTAVR *sect) {
  TPoint vertices[30];
  int zero, zero1, zero2;
  float scale_1, scale;
  int rc;


  if (sect->n_group < 0) {
	TRect NewRect = Rect(0, 0, Image_stand->Width,Image_stand->Height);
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	scale=(Image_stand->Width-20)/(1e0*sect->b2);
	scale_1=MIN(scale,(Image_stand->Width-20)/(1e0*sect->b1));
	scale=MIN(scale_1,(Image_stand->Height-20)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2)*scale)/2;
	zero1=(Image_stand->Width - sect->b2*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;

	Point_dvutavr(zero, zero1, zero2, sect, scale, vertices); // получить точки контура двутавра

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 12);
	Image_stand->Canvas->Brush->Color = clWhite;
	draw_axes(Image_stand);
  }
  else {
	double * ParamProfil;

	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	scale=(Image_stand->Width-35)/(1e0*sect->b2);
	scale_1=MIN(scale,(Image_stand->Width-35)/(1e0*sect->b1));
	scale=MIN(scale_1,(Image_stand->Height-30)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2)*scale)/2 + 10;
	zero1=(Image_stand->Width - sect->b2*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;
	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// получить точки контура прокатного двутавра
	Point_stand_dvutavr(zero, zero1, zero2, sect, ParamProfil[parRAD], scale, vertices); // получить точки контура двутавра

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 20);
	Image_stand->Canvas->Brush->Color = clWhite;

	draw_axes_zero(Image_stand, (vertices[0].x + vertices[1].x)/2, (vertices[0].y + vertices[11].y)/2);

	TPoint Point0_r;
	TPoint Point1_r;

	//flag_image = true;
	Image_stand->Canvas->Brush->Style=bsClear;
	// Ширина полки
	Point0_r = vertices[0];
	Point1_r = vertices[1];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "bf",
				 13, 0, 0, 0);
	// Высота профиля
	Point0_r = vertices[11];
	Point1_r = vertices[0];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideLEFT, "h",
				 6, 0, 4, 0);
	// Толщина пояса профиля
	Point0_r = vertices[1];
	Point1_r = vertices[2];

	int posY = vertices[2].y - vertices[1].y;
	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, "tf",
				 6, 0, -4, -posY/2 - 4);
	// Толщина стенки
	Point0_r = vertices[15];
	Point1_r = vertices[6];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "tw",
				 30, 0, 13, 0);

  }
}
//----------------------------------------------------------------------
// рисование стандартного двутавра
//void __fastcall TSectSelectCom_ParamFrame::draw_dvutavr(TImage * Image1, SECT_DVUTAVR *sect) {
void draw_dvutavr_comp(TImage * Image_stand, SECT_DVUTAVR *sect, double width, double thick, int index_comp) {
  TPoint vertices[30];
  TPoint vert[10];
  int zero, zero1, zero2;
  float scale_1, scale;
  int rc;


  if (sect->n_group < 0) {
	TRect NewRect = Rect(0, 0, Image_stand->Width,Image_stand->Height);
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	scale=(Image_stand->Width-20)/(1e0*sect->b2);
	scale_1=MIN(scale,(Image_stand->Width-20)/(1e0*sect->b1));
	scale=MIN(scale_1,(Image_stand->Height-20)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2)*scale)/2;
	zero1=(Image_stand->Width - sect->b2*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;

	Point_dvutavr(zero, zero1, zero2, sect, scale, vertices); // получить точки контура двутавра

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 12);
	Image_stand->Canvas->Brush->Color = clWhite;
	draw_axes(Image_stand);
  }
  else {
	double * ParamProfil;

	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	scale=(Image_stand->Width-35)/(1e0*width);
	scale_1=MIN(scale,(Image_stand->Width-35)/(1e0*sect->b1));
	scale=MIN(scale_1,(Image_stand->Height-30)/(1e0*(sect->h + sect->h1 + sect->h2 + thick)));

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2 + thick)*scale)/2 + 10;
	zero1=(Image_stand->Width - sect->b2*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;
	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// получить точки контура прокатного двутавра
	Point_stand_dvutavr(zero, zero1, zero2, sect, ParamProfil[parRAD], scale, vertices); // получить точки контура двутавра

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 20);
	vert[0].x = vertices[11].x - (width - sect->b1)*scale*0.5;
	vert[0].y = vertices[11].y;
	vert[1].x = vertices[10].x + (width - sect->b1)*scale*0.5;
	vert[1].y = vertices[11].y;
	vert[2].x = vert[1].x;
	vert[2].y = vert[0].y + thick*scale;
	vert[3].x = vert[0].x;
	vert[3].y = vert[2].y;
	vert[4] = vert[0];
	Image_stand->Canvas->Polygon(vert, 4);
	Image_stand->Canvas->Brush->Color = clWhite;

	GEOM_PARAM_SECT param_sect;
	COMMON_SECT com_sect;
	memcpy((char*)&(com_sect.dvutavr), (char*)sect, sizeof(SECT_DVUTAVR));

	Get_param_sect_composed(DVUTAVR, &com_sect, width, thick, &param_sect, index_comp);

	draw_axes_zero(Image_stand, (vertices[0].x + vertices[1].x)/2, vertices[0].y + param_sect.Zct*scale);

	TPoint Point0_r;
	TPoint Point1_r;

	//flag_image = true;
	Image_stand->Canvas->Brush->Style=bsClear;
	// Ширина полки
	Point0_r = vertices[0];
	Point1_r = vertices[1];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "bf",
				 13, 0, 0, 0);
	// Высота профиля
	Point0_r = vertices[11];
	Point1_r = vertices[0];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideLEFT, "h",
				 6, 0, 4, 0);
	// Толщина пояса профиля
	Point0_r = vertices[1];
	Point1_r = vertices[2];

	int posY = vertices[2].y - vertices[1].y;
	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, "tf",
				 6, 0, -4, -posY/2 - 4);
	// Толщина стенки
	Point0_r = vertices[15];
	Point1_r = vertices[6];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "tw",
				 30, 0, 13, 0);

  }
}
//----------------------------------------------------------------------
// рисование стандартного тавра
void draw_tavr(TImage * Image_stand, SECT_TAVR *sect) {
  TPoint vertices[30];
  int zero, zero1, zero2;
  float scale_1, scale;
  int rc;


  if (sect->n_group < 0) {
	TRect NewRect = Rect(0, 0, Image_stand->Width,Image_stand->Height);
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	scale=(Image_stand->Width-20)/(1e0*sect->b2);
	scale_1=MIN(scale,(Image_stand->Width-20)/(1e0*sect->b1));
	scale=MIN(scale_1,(Image_stand->Height-20)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2)*scale)/2;
	zero1=(Image_stand->Width - sect->b2*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;

	Point_tavr(zero, zero1, zero2, sect, scale, vertices); // получить точки контура двутавра

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 12);
	Image_stand->Canvas->Brush->Color = clWhite;
	draw_axes(Image_stand);
  }
  else {
	double * ParamProfil;

	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	scale=(Image_stand->Width-35)/(1e0*sect->b1);
	scale_1=MIN(scale,(Image_stand->Width-35)/(1e0*sect->b1));
	scale=MIN(scale_1,(Image_stand->Height-30)/(1e0*(sect->h + sect->h1 + sect->h2)));

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2)*scale)/2 + 10;
	zero1=(Image_stand->Width - sect->b1*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;
	// Список параметров прокатного тавра
	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// получить точки контура прокатного тавра
	Point_stand_tavr(zero, zero1, zero2, sect, ParamProfil[parRAD_TAVR], scale, vertices, 0); // получить точки контура тавра

	/*
	char str[120];
	for (int i=0; i<12; i++) {
	  sprintf(str, "%d: x=%d; y=%d", i+1, vertices[i].X, vertices[i].Y);
	  InfMessage((AnsiString)str);
	}
	*/

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 12);
	Image_stand->Canvas->Brush->Color = clWhite;

	draw_axes_zero(Image_stand, (vertices[0].x + vertices[1].x)/2, (vertices[0].y + sect->y0*scale) );

	TPoint Point0_r;
	TPoint Point1_r;

	//flag_image = true;
	Image_stand->Canvas->Brush->Style=bsClear;
	// Ширина полки
	Point0_r = vertices[0];
	Point1_r = vertices[1];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "bf",
				 13, 0, 0, 0);
	// Высота профиля
	Point0_r = vertices[7];
	Point1_r = vertices[0];
	Point1_r.x = Point0_r.x;

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideLEFT, "h",
				 6, 0, 4, 0);
	// Толщина пояса профиля
	Point0_r = vertices[1];
	Point1_r = vertices[2];

	int posY = vertices[2].y - vertices[1].y;
	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, "tf",
				 6, 0, -4, -posY/2 - 4);
	// Толщина стенки
	Point0_r = vertices[7];
	Point1_r = vertices[6];

	pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "tw",
				 30, 0, 13, 0);

  }
}
//----------------------------------------------------------------------
// рисование стандартного тавра
void draw_tavr_comp(TImage * Image_stand, SECT_TAVR *sect, double width, double thick, int index_comp) {
  TPoint vertices[30];
  TPoint vert[10];
  int zero, zero1, zero2;
  float scale_1, scale;
  int rc;

	double * ParamProfil;

	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	scale=(Image_stand->Width-35)/(1e0*sect->b1);
	scale_1=MIN(scale,(Image_stand->Width-35)/(1e0*width));
	scale=MIN(scale_1,(Image_stand->Height-30)/(1e0*(sect->h + sect->h1 + sect->h2 + thick)));

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2 + thick)*scale)/2 + 10;
	zero1=(Image_stand->Width - sect->b1*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;
	// Список параметров прокатного тавра
	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// получить точки контура прокатного тавра
	Point_stand_tavr(zero, zero1, zero2, sect, ParamProfil[parRAD_TAVR], scale, vertices, index_comp); // получить точки контура тавра

	/*
	char str[120];
	for (int i=0; i<12; i++) {
	  sprintf(str, "%d: x=%d; y=%d", i+1, vertices[i].X, vertices[i].Y);
	  InfMessage((AnsiString)str);
	}
	*/

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 12);
	if (index_comp==0) {
	  // плита
	  vert[0].x = vertices[0].x - (width - sect->b1)*scale*0.5;
	  vert[0].y = vertices[6].y;
	  vert[1].x = vertices[1].x + (width - sect->b1)*scale*0.5;
	  vert[1].y = vertices[6].y;
	  vert[2].x = vert[1].x;
	  vert[2].y = vert[0].y + thick*scale;
	  vert[3].x = vert[0].x;
	  vert[3].y = vert[2].y;
	  vert[4] = vert[0];
	  // швы

	}
	else {
	  vert[0].x = vertices[7].x - (width - sect->b1)*scale*0.5;
	  vert[0].y = vertices[0].y;
	  vert[1].x = vertices[6].x + (width - sect->b1)*scale*0.5;
	  vert[1].y = vertices[0].y;
	  vert[2].x = vert[1].x;
	  vert[2].y = vert[0].y - thick*scale;
	  vert[3].x = vert[0].x;
	  vert[3].y = vert[2].y;
	  vert[4] = vert[0];
    }
	Image_stand->Canvas->Polygon(vert, 4);

	Image_stand->Canvas->Brush->Color = clWhite;

	GEOM_PARAM_SECT param_sect;
	COMMON_SECT com_sect;
	memcpy((char*)&(com_sect.tavr), (char*)sect, sizeof(SECT_TAVR));

	Get_param_sect_composed(TAVR, &com_sect, width, thick, &param_sect, index_comp);

	TPoint Point0_r;
	TPoint Point1_r;
	int posY;
	//flag_image = true;
	Image_stand->Canvas->Brush->Style=bsClear;


	if (index_comp==0) {
	//  Оси координат
	  draw_axes_zero(Image_stand, (vertices[0].x + vertices[1].x)/2, vertices[0].y + param_sect.Zct*scale);
	// Ширина полки
	  Point0_r = vertices[0];
	  Point1_r = vertices[1];

	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "bf",
				 13, 0, 0, 0);
	// Высота профиля
	  Point0_r = vertices[7];
	  Point1_r = vertices[0];
	  Point1_r.x = Point0_r.x;

	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideLEFT, "h",
				 6, 0, 4, 0);
	// Толщина пояса профиля
	  Point0_r = vertices[1];
	  Point1_r = vertices[2];

	  posY = vertices[2].y - vertices[1].y;
	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, "tf",
				 6, 0, -4, -posY/2 - 4);
	// Толщина стенки
	  Point0_r = vertices[7];
	  Point1_r = vertices[6];

	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "tw",
				 30, 0, 13, 0);
	}
	else {
	//  Оси координат
	  draw_axes_zero(Image_stand, (vertices[0].x + vertices[1].x)/2, vertices[0].y - thick*scale + param_sect.Zct*scale);
	// Ширина полки
	  Point0_r = vertices[7];
	  Point1_r = vertices[6];

	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideDOWN, "bf",
				 20, 0, 0, 0);
	// Высота профиля
	  Point0_r = vertices[7];
	  Point1_r = vertices[0];
	  Point1_r.x = Point0_r.x;

	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideLEFT, "h",
				 6, 0, 4, 0);
	// Толщина пояса профиля
	  Point0_r = vertices[5];
	  Point1_r = vertices[6];

	  posY = vertices[8].y - vertices[7].y;
	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, "tf",
				 6, 0, -4, -posY/2 - 4);
	// Толщина стенки
	  Point0_r = vertices[11];
	  Point1_r = vertices[2];

	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, "tw",
				 10, 0, 13, 0);
	}




}
//----------------------------------------------------------------------
// Определение масштаба рисования перфорированного профиля
float draw_profil_perfor_scale(TImage * Image_stand, TImage * Image_balka, SECT_DVUTAVR *sect, double h1, double s_, double c_) {

	float scale=(Image_stand->Width-35)/(1e0*sect->b2);
	float scale_1=MIN(scale,(Image_stand->Width-35)/(1e0*sect->b1));
	scale = MIN(scale_1,(Image_stand->Height-30)/(1e0*(sect->h + sect->h1 + sect->h2 + h1)));
	scale_1 = MIN(scale, (Image_balka->Width-40)/(1e0*(c_+2*s_)));

	return scale_1;
}
//----------------------------------------------------------------------
// Рисование перфорированного двутавра
void draw_dvutavr_perfor(TImage * Image_stand, SECT_DVUTAVR *sect, double h1, float scale, bool flag_draw_size) {
  TPoint vertices[30];
  TPoint vert[10];
  int zero, zero1, zero2;
  float scale_1;
  int rc;


	double * ParamProfil;
	double h2 = (sect->h + sect->h1 + sect->h2 - h1)/2;

	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	//Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);

	if (scale==0.0) {
	  scale = (Image_stand->Width-35)/(1e0*sect->b2);
	  scale_1 = MIN(scale,(Image_stand->Width-35)/(1e0*sect->b1));
	  scale = MIN(scale_1,(Image_stand->Height-30)/(1e0*(sect->h + sect->h1 + sect->h2 + h1)));
	}

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2 + h1)*scale)/2 + 10;
	zero1=(Image_stand->Width - sect->b2*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;
	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// получить точки контура прокатного двутавра
	sect->h += h1;
	Point_stand_dvutavr(zero, zero1, zero2, sect, ParamProfil[parRAD], scale, vertices); // получить точки контура двутавра

	Image_stand->Canvas->Brush->Color = COLOR;
	Image_stand->Canvas->Polygon(vertices, 20);
	Image_stand->Canvas->Brush->Color = clWhite;

	TPoint Point0_r;
	TPoint Point1_r;

	//flag_image = true;
	Image_stand->Canvas->Brush->Style=bsClear;
	// Ширина полки
	Point0_r = vertices[0];
	Point1_r = vertices[1];
	if (flag_draw_size)
	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, FloatToStr(sect->b1),
				 13, 0, 0, 0);
	// Высота профиля
	Point0_r = vertices[11];
	Point1_r = vertices[0];

	if (flag_draw_size)
	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideLEFT, FloatToStr(sect->h + sect->h1 + sect->h2),
				 6, 0, 14, 0);
	// Высота перфорации up
	Point1_r.x = Point0_r.x = vertices[15].x;
	Point1_r.y = (vertices[0].y + vertices[11].y)/2;
	Point0_r.y = vertices[0].y + h2*scale;
	vert[0].x = vertices[15].x;
	vert[0].y = Point0_r.y;
	vert[1].x = vertices[5].x;
	vert[1].y = Point0_r.y;

 	if (flag_draw_size)
	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, FloatToStr(h1),
				 60, 0, 4, 0);
	// Высота перфорации down
	Point1_r.x = Point0_r.x = vertices[15].x;
	Point1_r.y = (vertices[0].y + vertices[11].y)/2;
	Point0_r.y = vertices[11].y - h2*scale;
	vert[2].x = vertices[5].x;
	vert[2].y = Point0_r.y;
	vert[3].x = vertices[15].x;
	vert[3].y = Point0_r.y;
	vert[4].x = vert[0].x;
	vert[4].y = vert[0].y;

	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->Polygon(vert, 4);


	if (flag_draw_size)
	  pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, FloatToStr(h1),
				 60, 0, 4, 0);
	// Толщина пояса профиля
	Point0_r = vertices[1];
	Point1_r = vertices[2];

	int posY = vertices[2].y - vertices[1].y;
	if (flag_draw_size)
	   pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orVERT, sideRIGHT, FloatToStr(sect->h1),
				 6, 0, -4, -posY/2 - 4);
	// Толщина стенки
	Point0_r = vertices[15];
	Point1_r = vertices[6];

	if (flag_draw_size)
	   pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, FloatToStr(sect->b),
				 30, 0, 13, 0);

	draw_axes_zero(Image_stand, (vertices[0].x + vertices[1].x)/2, (vertices[0].y + vertices[11].y)/2);

	sect->h -= h1;


}
//----------------------------------------------------------------------
// Рисование перфорированного профиля
void draw_profil_perfor(TImage * Image_stand, SECT_DVUTAVR *sect, double h1, double a_, double b_, double s_, double c_,
						double alfa, float scale, bool flag_draw_size) {
  TPoint vertices[30];
  TPoint vert[30];
  int zero, zero1, zero2;
  float scale_1;
  TPoint Point0_r;
  TPoint Point1_r;
  int rc;


	double * ParamProfil;
	double h2 = (sect->h + sect->h1 + sect->h2 - h1)/2;

	TRect NewRect = Rect(0, 0, Image_stand->Width, Image_stand->Height);
	Image_stand->Canvas->Pen->Color = clBlack;
	Image_stand->Canvas->Brush->Color = clWhite;
	Image_stand->Canvas->FillRect(NewRect);
	//Image_stand->Canvas->Rectangle(0, 0, Image_stand->Width,Image_stand->Height);
	if (scale==0.0) {
	  scale=(Image_stand->Width-35)/(1e0*sect->b2);
	  scale_1=MIN(scale,(Image_stand->Width-35)/(1e0*sect->b1));
	  scale=MIN(scale_1,(Image_stand->Height-30)/(1e0*(sect->h + sect->h1 + sect->h2 + h1)));
	}

	zero=(Image_stand->Height - (sect->h + sect->h1 + sect->h2 + h1)*scale)/2 + 10;
	zero1=(Image_stand->Width - sect->b2*scale)/2;
	zero2=(Image_stand->Width - sect->b1*scale)/2;
	StandartProfil.SetProfil(sect->n_group);
	ParamProfil = StandartProfil.GetVectorParamProfil(sect->n_profil);
	// получить точки контура прокатного двутавра
	sect->h += h1;
	Point_stand_dvutavr(zero, zero1, zero2, sect, ParamProfil[parRAD], scale, vertices); // получить точки контура двутавра


	// Контур
	int zero0 = 10;
	Image_stand->Canvas->Brush->Color = clBtnFace;
	// Отверстия
	vert[0].x = zero0; vert[0].y = vertices[0].y;
	vert[1].x = zero0 + (c_+ 2*s_)*scale; vert[1].y = vertices[0].y;
	vert[2].x = zero0 + (c_+ 2*s_)*scale; vert[2].y = (vertices[0].y + vertices[11].y)/2;
	vert[3].x = vert[2].x - a_*scale;      vert[3].y = vert[2].y;
	vert[4].x = vert[3].x - b_*scale;      vert[4].y = vert[3].y - h1*scale;
	vert[5].x = vert[4].x - a_*scale;      vert[5].y = vert[4].y;
	vert[6].x = vert[5].x - b_*scale;      vert[6].y = vert[3].y;
	vert[7].x = vert[6].x - a_*scale;      vert[7].y = vert[6].y;
	vert[8].x = vert[7].x - b_*scale;      vert[8].y = vert[7].y - h1*scale;
	vert[9].x = vert[8].x - a_*scale;      vert[9].y = vert[8].y;
	vert[10].x = vert[9].x - b_*scale;     vert[10].y = vert[6].y;
	vert[11].x = vert[0].x;               vert[11].y = vert[10].y;
	vert[12].x = vert[0].x;               vert[12].y = vert[0].y;
	Image_stand->Canvas->Polygon(vert, 11);
	vert[0].x = zero0; vert[0].y = vertices[11].y;
	vert[1].x = zero0 + (c_+ 2*s_)*scale; vert[1].y = vertices[11].y;
	vert[2].x = zero0 + (c_+ 2*s_)*scale; vert[2].y = (vertices[0].y + vertices[11].y)/2;
	vert[3].x = vert[2].x - a_*scale;      vert[3].y = vert[2].y;
	vert[4].x = vert[3].x - b_*scale;      vert[4].y = vert[3].y + h1*scale;
	vert[5].x = vert[4].x - a_*scale;      vert[5].y = vert[4].y;
	vert[6].x = vert[5].x - b_*scale;      vert[6].y = vert[3].y;
	vert[7].x = vert[6].x - a_*scale;      vert[7].y = vert[6].y;
	vert[8].x = vert[7].x - b_*scale;      vert[8].y = vert[7].y + h1*scale;
	vert[9].x = vert[8].x - a_*scale;      vert[9].y = vert[8].y;
	vert[10].x = vert[9].x - b_*scale;     vert[10].y = vert[6].y;
	vert[11].x = vert[0].x;               vert[11].y = vert[10].y;
	vert[12].x = vert[0].x;               vert[12].y = vert[0].y;
	Image_stand->Canvas->Polygon(vert, 11);


	//flag_image = true;
	Image_stand->Canvas->Brush->Style=bsClear;
	// Размер a
	Point0_r = vert[7];
	Point1_r = vert[6];

	if (flag_draw_size)
		pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideDOWN, FloatToStr(a_),
				 20, 0, 0, 0);
	// Размер a
	Point0_r = vert[9];
	Point1_r = vert[8];

	if (flag_draw_size)
		pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideDOWN, FloatToStr(a_),
				 20, 0, 0, 0);
	// Размер b
	Point0_r = vert[8];
	Point1_r = vert[7];  Point1_r.y = Point0_r.y;

	if (flag_draw_size)
		pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideDOWN, FloatToStr(b_),
				 20, 0, 0, 0);
	// Размер c
	Point0_r = vert[11];
	Point1_r = vert[10];

	if (flag_draw_size)
	   pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideDOWN, FloatToStr(c_),
				 20, 0, 0, 0);
	// Шаг
	Point0_r = vert[10];
	Point1_r = vert[6];

	if (flag_draw_size)
		pCanvas_Dim_vt(Image_stand, Point0_r, Point1_r, orHORIZ, sideUP, FloatToStr(s_),
				 (vert[9].y - vert[10].y + 20), 0, 0, 0);

	// Пояса
	Image_stand->Canvas->Brush->Color = COLOR;
	vert[0].x = zero0; vert[0].y = vertices[0].y;
	vert[1].x = zero0 + (c_+ 2*s_)*scale; vert[1].y = vertices[0].y;
	vert[2].x = zero0 + (c_+ 2*s_)*scale; vert[2].y = vertices[2].y;
	vert[3].x = zero0; vert[3].y = vertices[2].y;
	vert[4] = vert[0];
	Image_stand->Canvas->Polygon(vert, 4);
	vert[0].x = zero0; vert[0].y = vertices[11].y;
	vert[1].x = zero0 + (c_+ 2*s_)*scale; vert[1].y = vertices[11].y;
	vert[2].x = zero0 + (c_+ 2*s_)*scale; vert[2].y = vertices[12].y;
	vert[3].x = zero0;                    vert[3].y = vertices[12].y;
	vert[4] = vert[0];
	Image_stand->Canvas->Polygon(vert, 4);
	//draw_axes_zero(Image_stand, (vertices[0].x + vertices[1].x)/2, (vertices[0].y + vertices[11].y)/2);

	sect->h -= h1;

	Image_stand->Canvas->Brush->Style = bsClear;
	// Точки дуги для отображения угла
	double coor_g[30][3];
	double angle = alfa;
	double rad = h2;
	get_point_arc(20, coor_g, rad, angle, 0.0);
	vertices[0] = vert[10];
	vertices[1] = vert[10];     vertices[1].x += scale*h2 + 5;
	Image_stand->Canvas->Polyline(vertices, 1);

	for (int i=0; i <=20; i++) {
		vertices[i].x = vert[10].x + coor_g[i][0]*scale;
		vertices[i].y = vert[10].y - coor_g[i][1]*scale;
	}
	Image_stand->Canvas->Polyline(vertices, 20);
	Image_stand->Canvas->Font->Charset = RUSSIAN_CHARSET;
	if (flag_draw_size)
		Image_stand->Canvas->TextOut(vertices[10].x+5, vertices[10].y-8, u"\u03B1 = "+ FloatToStr(angle));
	else
		Image_stand->Canvas->TextOut(vertices[10].x+5, vertices[10].y-8, u"\u03B1");


}
//---------------------------------------------------------------------------
// рисование квадратной трубы
void draw_square_tube(TImage * Image1, SECT_SQUARE *sect) {
  TPoint vertices[30];
  double zero, zero1;
  float scale;
  int rc;

  TRect NewRect = Rect(0, 0, Image1->Width,Image1->Height);
  Image1->Canvas->Pen->Color = clBlack;
  Image1->Canvas->Brush->Color = clWhite;
  Image1->Canvas->FillRect(NewRect);
  Image1->Canvas->Rectangle(0, 0, Image1->Width,Image1->Height);

  scale=(Image1->Width-20)/(1e0*sect->side);
  scale=MIN(scale,(Image1->Height-20)/(1e0*sect->side));

  zero1=(Image1->Height - sect->side*scale)/2;
  zero=(Image1->Width - sect->side*scale)/2;


  double s_c = sect->side*scale;
  double r_c = sect->rad*scale;
  double r2_c = Round(r_c - r_c*cos(45/57.3), 0);

  vertices[0] = Point(zero, zero1 + r_c);
  vertices[1] = Point(zero, zero1 + s_c - r_c);
  vertices[2] = Point(zero + r2_c, zero1 + s_c - r2_c);
  vertices[3] = Point(zero + r_c, zero1 + s_c);
  vertices[4] = Point(zero + s_c - r_c, zero1 + s_c);
  vertices[5] = Point(zero + s_c - r2_c, zero1 + s_c - r2_c);
  vertices[6] = Point(zero + s_c, zero1 + s_c - r_c);
  vertices[7] = Point(zero + s_c, zero1 + r_c);
  vertices[8] = Point(zero + s_c - r2_c, zero1 + r2_c);
  vertices[9] = Point(zero + s_c - r_c, zero1);
  vertices[10] = Point(zero + r_c, zero1);
  vertices[11] = Point(zero + r2_c, zero1 + r2_c);
  vertices[12] = Point(zero, zero1 + r_c);

  Image1->Canvas->Brush->Color = COLOR;
  Image1->Canvas->Polygon(vertices, 12);

  zero1=(Image1->Height - (sect->side - 2*sect->thickness)*scale)/2;
  zero=(Image1->Width - (sect->side - 2*sect->thickness)*scale)/2;

  s_c = (sect->side - 2*sect->thickness)*scale;
  r_c = (sect->rad - sect->thickness)*scale;
  r2_c = Round(r_c - r_c*cos(45/57.3), 0);

  vertices[0] = Point(zero, zero1 + r_c);
  vertices[1] = Point(zero, zero1 + s_c - r_c);
  vertices[2] = Point(zero + r2_c, zero1 + s_c - r2_c);
  vertices[3] = Point(zero + r_c, zero1 + s_c);
  vertices[4] = Point(zero + s_c - r_c, zero1 + s_c);
  vertices[5] = Point(zero + s_c - r2_c, zero1 + s_c - r2_c);
  vertices[6] = Point(zero + s_c, zero1 + s_c - r_c);
  vertices[7] = Point(zero + s_c, zero1 + r_c);
  vertices[8] = Point(zero + s_c - r2_c, zero1 + r2_c);
  vertices[9] = Point(zero + s_c - r_c, zero1);
  vertices[10] = Point(zero + r_c, zero1);
  vertices[11] = Point(zero + r2_c, zero1 + r2_c);
  vertices[12] = Point(zero, zero1 + r_c);

  Image1->Canvas->Brush->Color = clWhite;
  Image1->Canvas->Polygon(vertices, 12);

  draw_axes(Image1);

}//---------------------------------------------------------------------------
// рисование прямогольной трубы
void draw_rect_tube(TImage * Image1, SECT_RECT *sect) {
  TPoint vertices[30];
  double zero, zero1;
  float scale;
  int rc;

  TRect NewRect = Rect(0, 0, Image1->Width,Image1->Height);
  Image1->Canvas->Pen->Color = clBlack;
  Image1->Canvas->Brush->Color = clWhite;
  Image1->Canvas->FillRect(NewRect);
  Image1->Canvas->Rectangle(0, 0, Image1->Width,Image1->Height);

  scale=(Image1->Width-20)/(1e0*sect->b);
  scale=MIN(scale,(Image1->Height-20)/(1e0*sect->h));

  zero1=(Image1->Height - sect->h*scale)/2;
  zero=(Image1->Width - sect->b*scale)/2;

  vertices[0] = Point(zero, zero1);
  vertices[1] = Point(zero, zero1 + sect->h*scale);
  vertices[2] = Point(zero + sect->b*scale, zero1 + sect->h*scale);
  vertices[3] = Point(zero + sect->b*scale, zero1);
  vertices[4] = Point(zero, zero1);

  double h_c = sect->h*scale;
  double b_c = sect->b*scale;
  double r_c = sect->rad*scale;
  double r2_c = Round(r_c - r_c*cos(45/57.3), 0);

  vertices[0] = Point(zero, zero1 + r_c);
  vertices[1] = Point(zero, zero1 + h_c - r_c);
  vertices[2] = Point(zero + r2_c, zero1 + h_c - r2_c);
  vertices[3] = Point(zero + r_c, zero1 + h_c);
  vertices[4] = Point(zero + b_c - r_c, zero1 + h_c);
  vertices[5] = Point(zero + b_c - r2_c, zero1 + h_c - r2_c);
  vertices[6] = Point(zero + b_c, zero1 + h_c - r_c);
  vertices[7] = Point(zero + b_c, zero1 + r_c);
  vertices[8] = Point(zero + b_c - r2_c, zero1 + r2_c);
  vertices[9] = Point(zero + b_c - r_c, zero1);
  vertices[10] = Point(zero + r_c, zero1);
  vertices[11] = Point(zero + r2_c, zero1 + r2_c);
  vertices[12] = Point(zero, zero1 + r_c);

  Image1->Canvas->Brush->Color = COLOR;
  Image1->Canvas->Polygon(vertices, 12);

  zero1=(Image1->Height - (sect->h - 2*sect->h1)*scale)/2;
  zero=(Image1->Width - (sect->b - 2*sect->b1)*scale)/2;

  h_c = (sect->h - 2*sect->h1)*scale;
  b_c = (sect->b - 2*sect->b1)*scale;
  r_c = (sect->rad - sect->h1)*scale;
  r2_c = Round(r_c - r_c*cos(45/57.3), 0);

  /*
  vertices[0] = Point(zero + sect->b1*scale, zero1 + sect->h1*scale);
  vertices[1] = Point(zero + sect->b1*scale, zero1 + (sect->h - sect->h1)*scale);
  vertices[2] = Point(zero + (sect->b - sect->b1)*scale, zero1 + (sect->h - sect->h1)*scale);
  vertices[3] = Point(zero + (sect->b - sect->b1)*scale, zero1 + sect->h1*scale);
  vertices[4] = Point(zero + sect->b1*scale, zero1 + sect->h1*scale);
  */
  vertices[0] = Point(zero, zero1 + r_c);
  vertices[1] = Point(zero, zero1 + h_c - r_c);
  vertices[2] = Point(zero + r2_c, zero1 + h_c - r2_c);
  vertices[3] = Point(zero + r_c, zero1 + h_c);
  vertices[4] = Point(zero + b_c - r_c, zero1 + h_c);
  vertices[5] = Point(zero + b_c - r2_c, zero1 + h_c - r2_c);
  vertices[6] = Point(zero + b_c, zero1 + h_c - r_c);
  vertices[7] = Point(zero + b_c, zero1 + r_c);
  vertices[8] = Point(zero + b_c - r2_c, zero1 + r2_c);
  vertices[9] = Point(zero + b_c - r_c, zero1);
  vertices[10] = Point(zero + r_c, zero1);
  vertices[11] = Point(zero + r2_c, zero1 + r2_c);
  vertices[12] = Point(zero, zero1 + r_c);

  Image1->Canvas->Brush->Color = clWhite;
  Image1->Canvas->Polygon(vertices, 12);
  draw_axes(Image1);

}
//---------------------------------------------------------------------------
// рисование круглой трубы
void draw_circular_tube(TImage * Image1, SECT_CIRC *sect) {
  double zero, zero1;
  float scale;
  int rc;

  TRect NewRect = Rect(0, 0, Image1->Width,Image1->Height);
  Image1->Canvas->Pen->Color = clBlack;
  Image1->Canvas->Brush->Color = clWhite;
  Image1->Canvas->FillRect(NewRect);
  Image1->Canvas->Rectangle(0, 0, Image1->Width,Image1->Height);

  scale=(Image1->Width-20)/(1e0*sect->diameter);
  scale=MIN(scale,(Image1->Height-20)/(1e0*sect->diameter));

  zero=(Image1->Height - sect->diameter*scale)/2;
  zero1=(Image1->Width - sect->diameter*scale)/2;

  Image1->Canvas->Brush->Color = COLOR;
  Image1->Canvas->Ellipse(zero1, zero, zero1 + sect->diameter*scale, zero + sect->diameter*scale);

  Image1->Canvas->Brush->Color = clWhite;
  Image1->Canvas->Ellipse(zero1 + sect->thickness*scale, zero + sect->thickness*scale,
                          zero1 + (sect->diameter - sect->thickness)*scale, zero + (sect->diameter - sect->thickness)*scale);
  draw_axes(Image1);
}
//---------------------------------------------------------------------------
// Рисование системы координат
void  draw_axes(TImage *Image_Ax) {

  draw_axes_zero(Image_Ax, Image_Ax->Width/2, Image_Ax->Height/2);
}
//---------------------------------------------------------------------------
// Рисование системы координат
void  draw_axes_zero(TImage *Image_Ax, int x0, int y0) {
  TPoint points[10];
  //int zero, zero1,zero2;
  //float scale_1, scale;


  points[0]=Point(x0, y0);
  points[1]=Point(x0, y0 - 40);

  CoorAx.PutArrow(points, 0, MAX_PIC);
  CoorAx.SetArrow();

  Image_Ax->Canvas->Pen->Width=1;
  Image_Ax->Canvas->Polyline(CoorAx.LArrow, 2);
  Image_Ax->Canvas->Pen->Width=1;
  Image_Ax->Canvas->Brush->Color=clBlack;
  Image_Ax->Canvas->Polygon(CoorAx.Ar, 3);
  Image_Ax->Canvas->Brush->Color=clWhite;

  points[0]=Point(x0, y0);
  points[1]=Point(x0 + 40, y0);

  CoorAx.PutArrow(points, 0, MAX_PIC);
  CoorAx.SetArrow();

  Image_Ax->Canvas->Pen->Width=1;
  Image_Ax->Canvas->Polyline(CoorAx.LArrow, 2);
  Image_Ax->Canvas->Pen->Width=1;
  Image_Ax->Canvas->Brush->Color=clBlack;
  Image_Ax->Canvas->Polygon(CoorAx.Ar, 3);
  Image_Ax->Canvas->Brush->Color=clWhite;
  Image_Ax->Canvas->Ellipse(x0-4, y0-4, x0+4, y0+4);
  Image_Ax->Canvas->Brush->Style=bsClear;
  Image_Ax->Canvas->TextOut(x0+6, y0 - 40,"Z");             // Изменено Y на Z
  Image_Ax->Canvas->TextOut(x0 + 40, y0-16,"Y");            // Изменено X на Y
  Image_Ax->Canvas->Brush->Style=bsSolid;
}

