cParticle.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #include <iostream>
  2. #include <assert.h>
  3. #include "cParticle.h"
  4. #include "const_def_cPartic.h"
  5. using std::cout;
  6. using std::endl;
  7. //==============================
  8. cParticle::cParticle (double x_, double y_, double z_, double mass_, double radii_, double px_, double py_, double pz_) {
  9. m_mass = mass_;
  10. m_radii = radii_;
  11. m_coordin.SetX (x_);
  12. m_coordin.SetY (y_);
  13. m_coordin.SetZ (z_);
  14. m_speed.SetX (px_);
  15. m_speed.SetY (py_);
  16. m_speed.SetZ (pz_);
  17. }
  18. //==============================
  19. cParticle::~cParticle () {
  20. cout << "I am a distruction, I delit your Particle \n";
  21. }
  22. //==============================
  23. bool cParticle::show () {
  24. /*
  25. #define IF_ERROR_SHOW_(variable, msg) if (variable < 0) { \
  26. cout << "ERROR!!!" << endl; \
  27. cout << msg << "< 0" << endl; \
  28. cout << __FILE__ << endl; \
  29. cout << _FUNC_<< " " << __LINE__ << endl; \
  30. return false; \
  31. } \
  32. else cout << endl; \
  33. return true;
  34. */
  35. cout << __FILE__ << " "<< _FUNC_ << endl;
  36. cout << "m_mass = " << m_mass; IF_ERROR_SHOW_(m_mass, "m_mass")
  37. cout << "m_radii_ = " << m_radii; IF_ERROR_SHOW_(m_radii, "m_radii_")
  38. cout << "m_coordin X = " << m_coordin.X () << endl;
  39. cout << "m_coordin Y = " << m_coordin.Y () << endl;
  40. cout << "m_coordin Z = " << m_coordin.Z () << endl;
  41. cout << "m_speed X = " << m_speed.X () << endl;
  42. cout << "m_speed Y = " << m_speed.Y () << endl;
  43. cout << "m_speed Z = " << m_speed.Z () << endl;
  44. //#undef IFERROR_SHOW_
  45. }
  46. //==============================
  47. bool cParticle::Ok () {
  48. IF_ERROR_SHOW_(m_mass, "m_mass")
  49. IF_ERROR_SHOW_(m_radii, "m_radii_")
  50. }
  51. //==============================
  52. cMyVector3 cParticle::return_coordin () {
  53. #ifdef USE_SUPER_PUPER_GUARDS
  54. _ASSERT_OK_()
  55. #endif
  56. return m_coordin;
  57. }
  58. //==============================
  59. cMyVector3 cParticle::return_speed () {
  60. #ifdef USE_SUPER_PUPER_GUARDS
  61. _ASSERT_OK_()
  62. #endif
  63. return m_speed;
  64. }
  65. //==============================
  66. double cParticle::return_mass () {
  67. #ifdef USE_SUPER_PUPER_GUARDS
  68. _ASSERT_OK_()
  69. #endif
  70. return m_mass;
  71. }
  72. //==============================
  73. double cParticle::return_radii () {
  74. #ifdef USE_SUPER_PUPER_GUARDS
  75. _ASSERT_OK_()
  76. #endif
  77. return m_radii;
  78. }
  79. //==============================
  80. void cParticle::change_coordin (cMyVector3 new_coordin) {
  81. #ifdef USE_SUPER_PUPER_GUARDS
  82. _ASSERT_OK_()
  83. #endif
  84. m_coordin = new_coordin;4
  85. #ifdef USE_SUPER_PUPER_GUARDS
  86. _ASSERT_OK_()
  87. #endif
  88. }
  89. //==============================
  90. void cParticle::change_speed (cMyVector3 new_speed) {
  91. #ifdef USE_SUPER_PUPER_GUARDS
  92. _ASSERT_OK_()
  93. #endif
  94. m_speed = new_speed;
  95. #ifdef USE_SUPER_PUPER_GUARDS
  96. _ASSERT_OK_()
  97. #endif
  98. }
  99. //==============================
  100. void cParticle::change_mass (double new_mass) {
  101. #ifdef USE_SUPER_PUPER_GUARDS
  102. _ASSERT_OK_();
  103. #endif
  104. m_mass = new_mass;
  105. #ifdef USE_SUPER_PUPER_GUARDS
  106. _ASSERT_OK_();
  107. #endif
  108. }
  109. //==============================
  110. void cParticle::change_radii (double new_radii) {
  111. #ifdef USE_SUPER_PUPER_GUARDS
  112. _ASSERT_OK_();
  113. #endif
  114. m_radii = new_radii;
  115. #ifdef USE_SUPER_PUPER_GUARDS
  116. _ASSERT_OK_();
  117. #endif
  118. }