OTSParticle.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 GetArea() { return m_dArea; }
  49. void SetArea(double a_nArea) { m_dArea = a_nArea; }
  50. // rectangle
  51. CRect GetParticleRect() { return m_rectParticle; }
  52. void SetParticleRect(CRect& a_rectParticle) { m_rectParticle = a_rectParticle; }
  53. // gray
  54. BYTE GetAveGray() { return m_cAveGray; }
  55. void SetAveGray(char a_cAveGray) { m_cAveGray = a_cAveGray; }
  56. // type
  57. int GetClassifyId() { return m_nTypeId; }
  58. void SetClassifyId(int a_nType) { m_nTypeId = a_nType; }
  59. // type
  60. OTS_PARTICLE_TYPE GetType() { return m_nType; }
  61. void SetType(OTS_PARTICLE_TYPE a_nType) { m_nType = a_nType; }
  62. // x-ray position
  63. CPoint GetXRayPos() { return m_poiXRayPos; }
  64. void SetXRayPos(CPoint a_poiXRayPos) { m_poiXRayPos = a_poiXRayPos; }
  65. CPoint GetAbsolutPos() { return m_absolutPos; }
  66. void SetAbsolutePos(CPoint a_poiabsPos) { m_absolutPos = a_poiabsPos; }
  67. // feature
  68. COTSFeaturePtr GetFeature() { return m_pFeature; }
  69. void SetFeature(COTSFeaturePtr a_pFeautre);
  70. // Feret diameter
  71. double GetFeretDiameter() { return m_dFeretDiameter; }
  72. void SetFeretDiameter(double a_dFeretDiameter) { m_dFeretDiameter = a_dFeretDiameter; }
  73. //设置该颗粒的最小外接矩形的宽度
  74. void SetWidth(double w) { m_Width = w; }
  75. double GetWidth() { return m_Width; }
  76. //设置该颗粒的最小外接矩形的长度
  77. void SetHeight(double h) { m_Height = h; }
  78. double GetHeight() { return m_Height; }
  79. // chemical type
  80. GB_CHEMICAL_TYPE GetChemical() { return m_nChemical; }
  81. void SetChemical(GB_CHEMICAL_TYPE a_nChemical) { m_nChemical = a_nChemical; }
  82. double GetPerimeter() { return m_Perimeter; }
  83. void SetPerimeter(double p) { m_Perimeter = p; }
  84. double GetDMax() { return m_DMax; }
  85. void SetDMax(double d) { m_DMax = d; }
  86. double GetDMin() { return m_DMin; }
  87. void SetDMin(double d) { m_DMin = d; }
  88. double GetDPerp() { return m_Dp; }
  89. void SetDPerp(double dp) { m_Dp = dp; }
  90. double GetDInscr() { return m_Di; }
  91. void SetDInscr(double di) { m_Di = di; }
  92. double GetDMean() { return m_Dm; }
  93. void SetDMean(double dm) { m_Dm = dm; }
  94. double GetOrientation() { return m_Orientation; }
  95. void SetOrientation(double Orien) { m_Orientation = Orien; }
  96. double GetDElong() { return m_De; }
  97. void SetDElong(double de) { m_De = de; }
  98. double GetAspectElong() { return m_De/m_Dm; }
  99. double GetAspectRatio() { return m_DMax / m_Dm; }
  100. double GetVideo() {return m_cAveGray;}
  101. double GetEqualCircleDiameter()
  102. {
  103. double Diameter;
  104. double dSize = this->GetArea();
  105. Diameter = sqrt(dSize / Pi) * 2;
  106. return Diameter;
  107. }
  108. double GetImgPropertyValueByName(CString propertyName);
  109. // calculate area, rect, average gray, and xRay pos
  110. BOOL CalCoverRect();
  111. BOOL CalArea();
  112. BOOL CalXRayPos();
  113. std::string TypeName() const { return m_TypeName; }
  114. void TypeName(std::string val) { m_TypeName = val; }
  115. std::string TypeColor() const { return m_TypeColor; }
  116. void TypeColor(std::string val) { m_TypeColor = val; }
  117. std::string GetHardness() const { return m_hardness; }
  118. void SetHardness(std::string val) { m_hardness = val; }
  119. std::string GetDensity() const { return m_density; }
  120. void SetDensity(std::string val) { m_density = val; }
  121. std::string GetConductivity() const { return m_conductivity; }
  122. void SetConductivity(std::string val) { m_conductivity = val; }
  123. std::string GetSubParticles() const { return m_SubParticles; }
  124. void SetSubParticles(std::string val) { m_SubParticles = val; }
  125. CPosXrayPtr GetXrayInfo() const { return m_pXRayInfo; }
  126. void SetXrayInfo(CPosXrayPtr val) { m_pXRayInfo = val; }
  127. BOOL IsConnected(COTSParticle* a_p, int fldwidth, int fldheight, int direction);
  128. 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.
  129. protected:
  130. // cleanup
  131. void Cleanup();
  132. // initialization
  133. void Init();
  134. // duplication
  135. void Duplicate(const COTSParticle& a_oSource);
  136. // area
  137. double m_dArea;
  138. // rectangle
  139. CRect m_rectParticle;
  140. // Feret's diameter
  141. double m_dFeretDiameter;
  142. //最小外接矩形的宽度
  143. double m_Width;
  144. //最小外接矩形的长度
  145. double m_Height;
  146. // STD chemical type
  147. double m_Perimeter;
  148. double m_DMax;
  149. double m_DMin;
  150. double m_Dp;
  151. double m_Di;
  152. double m_Dm;
  153. double m_De;
  154. double m_Orientation;
  155. GB_CHEMICAL_TYPE m_nChemical;
  156. // gray
  157. BYTE m_cAveGray;
  158. // type
  159. int m_nTypeId;
  160. OTS_PARTICLE_TYPE m_nType;
  161. std::string m_TypeName;
  162. std::string m_TypeColor;
  163. std::string m_hardness;
  164. std::string m_density;
  165. std::string m_conductivity;
  166. std::string m_SubParticles;
  167. // tag id
  168. int m_nTagId;
  169. // search id
  170. int m_nSearchId;
  171. // analysis id
  172. int m_nAnalysisId;
  173. // field id
  174. int m_nFieldId;
  175. // x-ray position
  176. CPoint m_poiXRayPos;
  177. CPoint m_absolutPos;//the ots coordinate position in the whole measure area. not the screen position.
  178. // feature
  179. COTSFeaturePtr m_pFeature;
  180. CPosXrayPtr m_pXRayInfo;
  181. };
  182. typedef std::shared_ptr<COTSParticle> __declspec(dllexport) COTSParticlePtr;
  183. typedef std::vector<COTSParticlePtr> __declspec(dllexport) COTSParticleList;
  184. }