fExPolygonC.cpp 3.2 KB

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