OTSParticle.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. #pragma once
  2. #include "afx.h"
  3. #include "OTSFeature.h"
  4. #include "otsdataconst.h"
  5. #include "BSEImg.h"
  6. #include "PosXray.h"
  7. namespace OTSDATA {
  8. const double Pi = 3.14159;
  9. class __declspec(dllexport) COTSParticle : public xmls::ISlo
  10. {
  11. public:
  12. // constructor
  13. COTSParticle(); // constructor
  14. COTSParticle(const COTSParticle&); // copy constructor
  15. COTSParticle(COTSParticle*); // copy constructor
  16. COTSParticle& operator=(const COTSParticle&); // =operator
  17. BOOL operator==(const COTSParticle&); // ==operator
  18. virtual ~COTSParticle(); // destructor
  19. //void Serialize(CArchive& ar); // serialization
  20. void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  21. // tag id
  22. int GetTagId() { return m_nTagId; }
  23. void SetTagId(int a_nTagId)
  24. {
  25. m_nTagId = a_nTagId;
  26. if (m_pXRayInfo != nullptr)
  27. {
  28. m_pXRayInfo->SetPartTagId(a_nTagId);
  29. }
  30. }
  31. // search id
  32. int GetSearchId() { return m_nSearchId; }
  33. void SetSearchtId(int a_nSearchId) { m_nSearchId = a_nSearchId; }
  34. // analysis id
  35. int GetAnalysisId() { return m_nAnalysisId; }
  36. void SetAnalysisId(int a_nAnalysisId)
  37. {
  38. m_nAnalysisId = a_nAnalysisId;
  39. if (m_pXRayInfo != nullptr)
  40. {
  41. m_pXRayInfo->SetIndex(a_nAnalysisId);
  42. }
  43. }
  44. // field id
  45. int GetFieldId() { return m_nFieldId; }
  46. void SetFieldId(int a_nFieldId) { m_nFieldId = a_nFieldId; }
  47. // area
  48. double GetActualArea() { return m_dArea; }
  49. void SetActualArea(double a_nArea) { m_dArea = a_nArea; }
  50. // Pixel area
  51. double GetPixelArea() { return m_dPixelArea; }
  52. void SetPixelArea(double a_nArea) { m_dPixelArea = a_nArea; }
  53. // rectangle
  54. CRect GetParticleRect() { return m_rectParticle; }
  55. void SetParticleRect(CRect& a_rectParticle) { m_rectParticle = a_rectParticle; }
  56. // gray
  57. BYTE GetAveGray() { return m_cAveGray; }
  58. void SetAveGray(char a_cAveGray) { m_cAveGray = a_cAveGray; }
  59. // type
  60. int GetClassifyId() { return m_nTypeId; }
  61. void SetClassifyId(int a_nType) { m_nTypeId = a_nType; }
  62. // type
  63. OTS_PARTICLE_TYPE GetType() { return m_nType; }
  64. void SetType(OTS_PARTICLE_TYPE a_nType) { m_nType = a_nType; }
  65. // x-ray position
  66. CPoint GetXRayPos() { return m_poiXRayPos; }
  67. void SetXRayPos(CPoint a_poiXRayPos) { m_poiXRayPos = a_poiXRayPos; }
  68. CPoint GetAbsolutPos() { return m_absolutPos; }
  69. void SetAbsolutePos(CPoint a_poiabsPos) { m_absolutPos = a_poiabsPos; }
  70. // feature
  71. COTSFeaturePtr GetFeature() { return m_pFeature; }
  72. void SetFeature(COTSFeaturePtr a_pFeautre);
  73. // Feret diameter
  74. double GetFeretDiameter() { return m_dFeretDiameter; }
  75. void SetFeretDiameter(double a_dFeretDiameter) { m_dFeretDiameter = a_dFeretDiameter; }
  76. //设置该颗粒的最小外接矩形的宽度
  77. void SetWidth(double w) { m_Width = w; }
  78. double GetWidth() { return m_Width; }
  79. //设置该颗粒的最小外接矩形的长度
  80. void SetHeight(double h) { m_Height = h; }
  81. double GetHeight() { return m_Height; }
  82. // chemical type
  83. GB_CHEMICAL_TYPE GetChemical() { return m_nChemical; }
  84. void SetChemical(GB_CHEMICAL_TYPE a_nChemical) { m_nChemical = a_nChemical; }
  85. double GetPerimeter() { return m_Perimeter; }
  86. void SetPerimeter(double p) { m_Perimeter = p; }
  87. double GetDMax() { return m_DMax; }
  88. void SetDMax(double d) { m_DMax = d; }
  89. double GetDMin() { return m_DMin; }
  90. void SetDMin(double d) { m_DMin = d; }
  91. double GetDPerp() { return m_Dp; }
  92. void SetDPerp(double dp) { m_Dp = dp; }
  93. double GetDInscr() { return m_Di; }
  94. void SetDInscr(double di) { m_Di = di; }
  95. double GetDMean() { return m_Dm; }
  96. void SetDMean(double dm) { m_Dm = dm; }
  97. double GetOrientation() { return m_Orientation; }
  98. void SetOrientation(double Orien) { m_Orientation = Orien; }
  99. double GetDElong() { return m_De; }
  100. void SetDElong(double de) { m_De = de; }
  101. double GetAspectElong() { return m_De/m_Dm; }
  102. double GetAspectRatio() { return m_DMax / m_Dm; }
  103. double GetVideo() {return m_cAveGray;}
  104. double GetEqualCircleDiameter()
  105. {
  106. double Diameter;
  107. double dSize = this->GetActualArea();
  108. Diameter = sqrt(dSize / Pi) * 2;
  109. return Diameter;
  110. }
  111. double GetImgPropertyValueByName(CString propertyName);
  112. // calculate area, rect, average gray, and xRay pos
  113. BOOL CalCoverRect();
  114. BOOL CalArea();
  115. BOOL CalXRayPos();
  116. std::string TypeName() const { return m_TypeName; }
  117. void TypeName(std::string val) { m_TypeName = val; }
  118. std::string TypeColor() const { return m_TypeColor; }
  119. void TypeColor(std::string val) { m_TypeColor = val; }
  120. std::string GetHardness() const { return m_hardness; }
  121. void SetHardness(std::string val) { m_hardness = val; }
  122. std::string GetDensity() const { return m_density; }
  123. void SetDensity(std::string val) { m_density = val; }
  124. std::string GetConductivity() const { return m_conductivity; }
  125. void SetConductivity(std::string val) { m_conductivity = val; }
  126. std::string GetSubParticles() const { return m_SubParticles; }
  127. void SetSubParticles(std::string val) { m_SubParticles = val; }
  128. CPosXrayPtr GetXrayInfo() const { return m_pXRayInfo; }
  129. void SetXrayInfo(CPosXrayPtr val) { m_pXRayInfo = val; }
  130. BOOL IsConnected(COTSParticle* a_p, int fldwidth, int fldheight, int direction);
  131. COTSParticle* headerParticle;//used to merge particles ,if this particle has been merged then this pointer will point to the first particle of these merged particles else it's NULL.
  132. int GetGroupId() { return m_grpId; }
  133. void SetGroupId(int a_grpId) { m_grpId = a_grpId; }
  134. std::string GetGroupName() const { return m_grpName; }
  135. void SetGroupName(std::string val) { m_grpName = val; }
  136. std::string GetGroupColor() const { return m_grpColor; }
  137. void SetGroupColor(std::string val) { m_grpColor = val; }
  138. BOOL IsXrayParticle() const { return m_isXrayParticle; }
  139. void SetIsXrayParticle(bool value) { m_isXrayParticle = value; }
  140. protected:
  141. // cleanup
  142. void Cleanup();
  143. // initialization
  144. void Init();
  145. // duplication
  146. void Duplicate(const COTSParticle& a_oSource);
  147. bool m_isXrayParticle;
  148. // area
  149. double m_dArea;
  150. double m_dPixelArea;
  151. // rectangle
  152. CRect m_rectParticle;
  153. // Feret's diameter
  154. double m_dFeretDiameter;
  155. //最小外接矩形的宽度
  156. double m_Width;
  157. //最小外接矩形的长度
  158. double m_Height;
  159. // STD chemical type
  160. double m_Perimeter;
  161. double m_DMax;
  162. double m_DMin;
  163. double m_Dp;
  164. double m_Di;
  165. double m_Dm;
  166. double m_De;
  167. double m_Orientation;
  168. GB_CHEMICAL_TYPE m_nChemical;
  169. // gray
  170. BYTE m_cAveGray;
  171. // type
  172. int m_nTypeId;
  173. OTS_PARTICLE_TYPE m_nType;
  174. int m_grpId;
  175. std::string m_grpName;
  176. std::string m_grpColor;
  177. std::string m_TypeName;
  178. std::string m_TypeColor;
  179. std::string m_hardness;
  180. std::string m_density;
  181. std::string m_conductivity;
  182. std::string m_SubParticles;
  183. // tag id
  184. int m_nTagId;
  185. // search id
  186. int m_nSearchId;
  187. // analysis id
  188. int m_nAnalysisId;
  189. // field id
  190. int m_nFieldId;
  191. // x-ray position
  192. CPoint m_poiXRayPos;
  193. CPoint m_absolutPos;//the ots coordinate position in the whole measure area. not the screen position.
  194. // feature
  195. COTSFeaturePtr m_pFeature;
  196. CPosXrayPtr m_pXRayInfo;
  197. };
  198. typedef std::shared_ptr<COTSParticle> __declspec(dllexport) COTSParticlePtr;
  199. typedef std::vector<COTSParticlePtr> __declspec(dllexport) COTSParticleList;
  200. }