OTSParticle.h 7.4 KB

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