OTSImageProcessParam.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #include "stdafx.h"
  2. #include "OTSImageProcessParam.h"
  3. namespace OTSIMGPROC
  4. {
  5. // constructor
  6. COTSImageProcessParam::COTSImageProcessParam()
  7. {
  8. Init();
  9. }
  10. // copy constructor
  11. COTSImageProcessParam::COTSImageProcessParam(const COTSImageProcessParam& a_oSource)
  12. {
  13. // can't copy itself
  14. if (&a_oSource == this)
  15. {
  16. return;
  17. }
  18. // copy data over
  19. Duplicate(a_oSource);
  20. }
  21. // copy constructor
  22. COTSImageProcessParam::COTSImageProcessParam(COTSImageProcessParam* a_poSource)
  23. {
  24. // input check
  25. ASSERT(a_poSource);
  26. if (!a_poSource)
  27. {
  28. return;
  29. }
  30. // can't copy itself
  31. if (a_poSource == this)
  32. {
  33. return;
  34. }
  35. // copy data over
  36. Duplicate(*a_poSource);
  37. }
  38. // =operator
  39. COTSImageProcessParam& COTSImageProcessParam::operator=(const COTSImageProcessParam& a_oSource)
  40. {
  41. // cleanup
  42. Cleanup();
  43. // copy the class data over
  44. Duplicate(a_oSource);
  45. // return class
  46. return *this;
  47. }
  48. // ==operator
  49. BOOL COTSImageProcessParam::operator==(const COTSImageProcessParam& a_oSource)
  50. {
  51. // return test result
  52. return m_oIncArea == a_oSource.m_oIncArea &&
  53. m_oBGGray == a_oSource.m_oBGGray &&
  54. m_oParticleGray == a_oSource.m_oParticleGray;
  55. }
  56. // detractor
  57. COTSImageProcessParam::~COTSImageProcessParam()
  58. {
  59. Cleanup();
  60. }
  61. // COTSStageData member functions
  62. // serialization
  63. void COTSImageProcessParam::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  64. {
  65. xmls::Slo slo;
  66. slo.Register("IncArea", &m_oIncArea);
  67. slo.Register("BGGray", &m_oBGGray);
  68. slo.Register("ParticleGray", &m_oParticleGray);
  69. if (isStoring)
  70. {
  71. slo.Serialize(true, classDoc, rootNode);
  72. }
  73. else
  74. {
  75. slo.Serialize(false, classDoc, rootNode);
  76. }
  77. }
  78. // cleanup
  79. void COTSImageProcessParam::Cleanup()
  80. {
  81. // nothing needs to be done at the moment
  82. }
  83. // initialization
  84. void COTSImageProcessParam::Init()
  85. {
  86. m_oIncArea = CDoubleRange(DEFUALT_PARTICALE_AREA_MIN, DEFUALT_PARTICALE_AREA_MAX);
  87. m_oBGGray = CIntRange(DEFUALT_BG_GRAY_LEVEL_MIN, DEFUALT_BG_GRAY_LEVEL_MAX);
  88. m_oParticleGray = CIntRange(DEFUALT_PARTICLE_GRAY_LEVEL_MIN, DEFUALT_PARTICLE_GRAY_LEVEL_MAX);
  89. }
  90. // duplication
  91. void COTSImageProcessParam::Duplicate(const COTSImageProcessParam& a_oSource)
  92. {
  93. // initialization
  94. Init();
  95. // copy data over
  96. m_oIncArea = a_oSource.m_oIncArea;
  97. m_oBGGray = a_oSource.m_oBGGray;
  98. m_oParticleGray = a_oSource.m_oParticleGray;
  99. }
  100. }