OTSParticle.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #pragma once
  2. #include "afx.h"
  3. #include "OTSFeature.h"
  4. #include "otsdataconst.h"
  5. #include "BSEImg.h"
  6. namespace OTSDATA {
  7. const double Pi = 3.14159;
  8. class __declspec(dllexport) COTSParticle : public xmls::ISlo
  9. {
  10. public:
  11. // constructor
  12. COTSParticle(); // constructor
  13. COTSParticle(const COTSParticle&); // copy constructor
  14. COTSParticle(COTSParticle*); // copy constructor
  15. COTSParticle& operator=(const COTSParticle&); // =operator
  16. BOOL operator==(const COTSParticle&); // ==operator
  17. virtual ~COTSParticle(); // destructor
  18. //void Serialize(CArchive& ar); // serialization
  19. void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  20. // tag id
  21. int GetTagId() { return m_nTagId; }
  22. void SetTagId(int a_nTagId) { m_nTagId = a_nTagId; }
  23. // search id
  24. int GetSearchId() { return m_nSearchId; }
  25. void SetSearchtId(int a_nSearchId) { m_nSearchId = a_nSearchId; }
  26. // analysis id
  27. int GetAnalysisId() { return m_nAnalysisId; }
  28. void SetAnalysisId(int a_nAnalysisId) { m_nAnalysisId = a_nAnalysisId; }
  29. // field id
  30. int GetFieldId() { return m_nFieldId; }
  31. void SetFieldId(int a_nFieldId) { m_nFieldId = a_nFieldId; }
  32. // area
  33. double GetArea() { return m_dArea; }
  34. void SetArea(double a_nArea) { m_dArea = a_nArea; }
  35. // rectangle
  36. CRect GetParticleRect() { return m_rectParticle; }
  37. void SetParticleRect(CRect& a_rectParticle) { m_rectParticle = a_rectParticle; }
  38. // gray
  39. BYTE GetAveGray() { return m_cAveGray; }
  40. void SetAveGray(char a_cAveGray) { m_cAveGray = a_cAveGray; }
  41. // type
  42. int GetType() { return m_nTypeId; }
  43. void SetType(int a_nType) { m_nTypeId = a_nType; }
  44. // x-ray position
  45. CPoint GetXRayPos() { return m_poiXRayPos; }
  46. void SetXRayPos(CPoint a_poiXRayPos) { m_poiXRayPos = a_poiXRayPos; }
  47. // feature
  48. COTSFeaturePtr GetFeature() { return m_pFeature; }
  49. void SetFeature(COTSFeaturePtr a_pFeautre);
  50. // Feret diameter
  51. double GetFeretDiameter() { return m_dFeretDiameter; }
  52. void SetFeretDiameter(double a_dFeretDiameter) { m_dFeretDiameter = a_dFeretDiameter; }
  53. //设置该颗粒的最小外接矩形的宽度
  54. void SetWidth(double w) { m_Width = w; }
  55. double GetWidth() { return m_Width; }
  56. //设置该颗粒的最小外接矩形的长度
  57. void SetHeight(double h) { m_Height = h; }
  58. double GetHeight() { return m_Height; }
  59. // chemical type
  60. GB_CHEMICAL_TYPE GetChemical() { return m_nChemical; }
  61. void SetChemical(GB_CHEMICAL_TYPE a_nChemical) { m_nChemical = a_nChemical; }
  62. double GetPerimeter() { return m_Perimeter; }
  63. void SetPerimeter(double p) { m_Perimeter = p; }
  64. double GetDMax() { return m_DMax; }
  65. void SetDMax(double d) { m_DMax = d; }
  66. double GetDMin() { return m_DMin; }
  67. void SetDMin(double d) { m_DMin = d; }
  68. double GetDPerp() { return m_Dp; }
  69. void SetDPerp(double dp) { m_Dp = dp; }
  70. double GetDInscr() { return m_Di; }
  71. void SetDInscr(double di) { m_Di = di; }
  72. double GetDMean() { return m_Dm; }
  73. void SetDMean(double dm) { m_Dm = dm; }
  74. double GetOrientation() { return m_Orientation; }
  75. void SetOrientation(double Orien) { m_Orientation = Orien; }
  76. double GetDElong() { return m_De; }
  77. void SetDElong(double de) { m_De = de; }
  78. double GetAspectElong() { return m_De/m_Dm; }
  79. double GetAspectRatio() { return m_DMax / m_Dm; }
  80. double GetVideo() {return m_cAveGray;}
  81. double GetEqualCircleDiameter()
  82. {
  83. double Diameter;
  84. double dSize = this->GetArea();
  85. Diameter = sqrt(dSize / Pi) * 2;
  86. return Diameter;
  87. }
  88. double GetImgPropertyValueByName(CString propertyName);
  89. // calculate area, rect, average gray, and xRay pos
  90. BOOL CalCoverRect();
  91. BOOL CalArea();
  92. BOOL CalXRayPos();
  93. std::string TypeName() const { return m_TypeName; }
  94. void TypeName(std::string val) { m_TypeName = val; }
  95. std::string TypeColor() const { return m_TypeColor; }
  96. void TypeColor(std::string val) { m_TypeColor = val; }
  97. protected:
  98. // cleanup
  99. void Cleanup();
  100. // initialization
  101. void Init();
  102. // duplication
  103. void Duplicate(const COTSParticle& a_oSource);
  104. // area
  105. double m_dArea;
  106. // rectangle
  107. CRect m_rectParticle;
  108. // rotated rectangle
  109. //RotatedRect m_rotatedParticle;
  110. // Feret's diameter
  111. double m_dFeretDiameter;
  112. //最小外接矩形的宽度
  113. double m_Width;
  114. //最小外接矩形的长度
  115. double m_Height;
  116. // STD chemical type
  117. double m_Perimeter;
  118. double m_DMax;
  119. double m_DMin;
  120. double m_Dp;
  121. double m_Di;
  122. double m_Dm;
  123. double m_De;
  124. double m_Orientation;
  125. GB_CHEMICAL_TYPE m_nChemical;
  126. // gray
  127. BYTE m_cAveGray;
  128. // type
  129. int m_nTypeId;
  130. std::string m_TypeName;
  131. std::string m_TypeColor;
  132. // tag id
  133. int m_nTagId;
  134. // search id
  135. int m_nSearchId;
  136. // analysis id
  137. int m_nAnalysisId;
  138. // field id
  139. int m_nFieldId;
  140. // x-ray position
  141. CPoint m_poiXRayPos;
  142. // feature
  143. COTSFeaturePtr m_pFeature;
  144. };
  145. typedef std::shared_ptr<COTSParticle> __declspec(dllexport) COTSParticlePtr;
  146. typedef std::vector<COTSParticlePtr> __declspec(dllexport) COTSParticleList;
  147. }