Unit1.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLBaseClasses"
  8. #pragma link "GLCoordinates"
  9. #pragma link "GLCrossPlatform"
  10. #pragma link "GLMaterial"
  11. #pragma link "GLObjects"
  12. #pragma link "GLScene"
  13. #pragma link "GLWin32Viewer"
  14. #pragma resource "*.dfm"
  15. TForm1 *Form1;
  16. typedef
  17. TGLMultiPolygon FPlane[6];
  18. //---------------------------------------------------------------------------
  19. __fastcall TForm1::TForm1(TComponent* Owner)
  20. : TForm(Owner)
  21. {
  22. }
  23. //Delphi - function Vektor(x,y,z:Double):TVektor;
  24. /*
  25. TVektor Vektor(double x,y,z)
  26. {
  27. // result.x := x;
  28. return->x = x;
  29. result.y := y;
  30. result.z := z;
  31. }
  32. */
  33. void __fastcall TForm1::ReDraw()
  34. {
  35. DX = 600;
  36. DY = 400;
  37. DZ = 19;
  38. //- CreatePanel;
  39. //- MakeHole(0,0.5*DX,0.5*DY,DZ,50,DZ);
  40. }
  41. //---------------------------------------------------------------------------
  42. void __fastcall TForm1::FormShow(TObject *Sender)
  43. {
  44. ReDraw();
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::SetDX(const double Value)
  48. {
  49. FDX = Value;
  50. Container->Position->X = -0.5*Value;
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TForm1::SetDY(const double Value)
  54. {
  55. FDY = Value;
  56. Container->Position->Y = -0.5*Value;
  57. }
  58. //---------------------------------------------------------------------------
  59. void __fastcall TForm1::SetDZ(const double Value)
  60. {
  61. FDZ = Value;
  62. Container->Position->Z = -0.5*Value;
  63. }
  64. //---------------------------------------------------------------------------
  65. void __fastcall TForm1::MakeHole(int Side, double X, double Y, double Z,
  66. double D, double T, double Phi = 0, double Rho = 0)
  67. {
  68. /*
  69. double R;
  70. TGLDummyCube *Dum;
  71. TGLCylinder *Cyl;
  72. bool through;
  73. Dum := TGLDummyCube.Create(nil);
  74. Dum.Position.x := X;
  75. Dum.Position.y := Y;
  76. Dum.Position.z := Z;
  77. case Side of
  78. 0 : Dum.PitchAngle := -90;
  79. 1 : Dum.RollAngle := 90;
  80. 2 : Dum.RollAngle := 180;
  81. 3 : Dum.RollAngle := 270;
  82. 4 : Dum.RollAngle := 0;
  83. 5 : Dum.PitchAngle := 90;
  84. end;
  85. Dum.PitchAngle := Dum.PitchAngle + Rho;
  86. Dum.RollAngle := Dum.RollAngle + Phi;
  87. R := 0.5*D;
  88. through := true;
  89. case Side of
  90. 0 : if (Z-T)<=0 then T := Z else through := false;
  91. 1 : if (X+T)>=DX then T := DX-X else through := false;
  92. 2 : if (Y+T)>=DY then T := DY-Y else through := false;
  93. 3 : if (X-T)<=0 then T := X else through := false;
  94. 4 : if (Y-T)<=0 then T := Y else through := false;
  95. 5 : if (Z+T)>=DZ then T := DZ-Z else through := false;
  96. end;
  97. Cyl := TGLCylinder.Create(nil);
  98. AddMaterial(Cyl);
  99. Cyl.Position.x := 0;
  100. Cyl.Position.y := - 0.5*T;
  101. Cyl.Position.z := 0;
  102. Cyl.Height := T;
  103. Cyl.BottomRadius := R;
  104. Cyl.TopRadius := R;
  105. Cyl.NormalDirection := ndInside;
  106. if through then Cyl.Parts := [cySides]
  107. else Cyl.Parts := [cySides,cyBottom];
  108. Dum.AddChild(Cyl);
  109. Container.AddChild(Dum);
  110. Plane[Side].Contours.Add.Nodes.AddXYArc(R/cos(Phi*c180divPi),R,0,360,16, AffineVectorMake(X,Y,0));
  111. if through then
  112. Plane[cOpposite[Side]].Contours.Add.Nodes.AddXYArc(R/cos(Phi*c180divPi),R,0,360,16, AffineVectorMake(X,Y,0));
  113. */
  114. }