#pragma once #include "afx.h" #include "OTSFeature.h" #include "otsdataconst.h" #include "BSEImg.h" #include "PosXray.h" namespace OTSDATA { const double Pi = 3.14159; class __declspec(dllexport) COTSParticle : public xmls::ISlo { public: // constructor COTSParticle(); // constructor COTSParticle(const COTSParticle&); // copy constructor COTSParticle(COTSParticle*); // copy constructor COTSParticle& operator=(const COTSParticle&); // =operator BOOL operator==(const COTSParticle&); // ==operator virtual ~COTSParticle(); // destructor //void Serialize(CArchive& ar); // serialization void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode); // tag id int GetTagId() { return m_nTagId; } void SetTagId(int a_nTagId) { m_nTagId = a_nTagId; if (m_pXRayInfo != nullptr) { m_pXRayInfo->SetPartTagId(a_nTagId); } } // search id int GetSearchId() { return m_nSearchId; } void SetSearchtId(int a_nSearchId) { m_nSearchId = a_nSearchId; } // analysis id int GetAnalysisId() { return m_nAnalysisId; } void SetAnalysisId(int a_nAnalysisId) { m_nAnalysisId = a_nAnalysisId; if (m_pXRayInfo != nullptr) { m_pXRayInfo->SetIndex(a_nAnalysisId); } } // field id int GetFieldId() { return m_nFieldId; } void SetFieldId(int a_nFieldId) { m_nFieldId = a_nFieldId; } // area double GetArea() { return m_dArea; } void SetArea(double a_nArea) { m_dArea = a_nArea; } // rectangle CRect GetParticleRect() { return m_rectParticle; } void SetParticleRect(CRect& a_rectParticle) { m_rectParticle = a_rectParticle; } // gray BYTE GetAveGray() { return m_cAveGray; } void SetAveGray(char a_cAveGray) { m_cAveGray = a_cAveGray; } // type int GetClassifyId() { return m_nTypeId; } void SetClassifyId(int a_nType) { m_nTypeId = a_nType; } // type OTS_PARTICLE_TYPE GetType() { return m_nType; } void SetType(OTS_PARTICLE_TYPE a_nType) { m_nType = a_nType; } // x-ray position CPoint GetXRayPos() { return m_poiXRayPos; } void SetXRayPos(CPoint a_poiXRayPos) { m_poiXRayPos = a_poiXRayPos; } CPoint GetAbsolutPos() { return m_absolutPos; } void SetAbsolutePos(CPoint a_poiabsPos) { m_absolutPos = a_poiabsPos; } // feature COTSFeaturePtr GetFeature() { return m_pFeature; } void SetFeature(COTSFeaturePtr a_pFeautre); // Feret diameter double GetFeretDiameter() { return m_dFeretDiameter; } void SetFeretDiameter(double a_dFeretDiameter) { m_dFeretDiameter = a_dFeretDiameter; } //设置该颗粒的最小外接矩形的宽度 void SetWidth(double w) { m_Width = w; } double GetWidth() { return m_Width; } //设置该颗粒的最小外接矩形的长度 void SetHeight(double h) { m_Height = h; } double GetHeight() { return m_Height; } // chemical type GB_CHEMICAL_TYPE GetChemical() { return m_nChemical; } void SetChemical(GB_CHEMICAL_TYPE a_nChemical) { m_nChemical = a_nChemical; } double GetPerimeter() { return m_Perimeter; } void SetPerimeter(double p) { m_Perimeter = p; } double GetDMax() { return m_DMax; } void SetDMax(double d) { m_DMax = d; } double GetDMin() { return m_DMin; } void SetDMin(double d) { m_DMin = d; } double GetDPerp() { return m_Dp; } void SetDPerp(double dp) { m_Dp = dp; } double GetDInscr() { return m_Di; } void SetDInscr(double di) { m_Di = di; } double GetDMean() { return m_Dm; } void SetDMean(double dm) { m_Dm = dm; } double GetOrientation() { return m_Orientation; } void SetOrientation(double Orien) { m_Orientation = Orien; } double GetDElong() { return m_De; } void SetDElong(double de) { m_De = de; } double GetAspectElong() { return m_De/m_Dm; } double GetAspectRatio() { return m_DMax / m_Dm; } double GetVideo() {return m_cAveGray;} double GetEqualCircleDiameter() { double Diameter; double dSize = this->GetArea(); Diameter = sqrt(dSize / Pi) * 2; return Diameter; } double GetImgPropertyValueByName(CString propertyName); // calculate area, rect, average gray, and xRay pos BOOL CalCoverRect(); BOOL CalArea(); BOOL CalXRayPos(); std::string TypeName() const { return m_TypeName; } void TypeName(std::string val) { m_TypeName = val; } std::string TypeColor() const { return m_TypeColor; } void TypeColor(std::string val) { m_TypeColor = val; } std::string GetHardness() const { return m_hardness; } void SetHardness(std::string val) { m_hardness = val; } std::string GetDensity() const { return m_density; } void SetDensity(std::string val) { m_density = val; } std::string GetConductivity() const { return m_conductivity; } void SetConductivity(std::string val) { m_conductivity = val; } std::string GetSubParticles() const { return m_SubParticles; } void SetSubParticles(std::string val) { m_SubParticles = val; } CPosXrayPtr GetXrayInfo() const { return m_pXRayInfo; } void SetXrayInfo(CPosXrayPtr val) { m_pXRayInfo = val; } BOOL IsConnected(COTSParticle* a_p, int fldwidth, int fldheight, int direction); 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. protected: // cleanup void Cleanup(); // initialization void Init(); // duplication void Duplicate(const COTSParticle& a_oSource); // area double m_dArea; // rectangle CRect m_rectParticle; // Feret's diameter double m_dFeretDiameter; //最小外接矩形的宽度 double m_Width; //最小外接矩形的长度 double m_Height; // STD chemical type double m_Perimeter; double m_DMax; double m_DMin; double m_Dp; double m_Di; double m_Dm; double m_De; double m_Orientation; GB_CHEMICAL_TYPE m_nChemical; // gray BYTE m_cAveGray; // type int m_nTypeId; OTS_PARTICLE_TYPE m_nType; std::string m_TypeName; std::string m_TypeColor; std::string m_hardness; std::string m_density; std::string m_conductivity; std::string m_SubParticles; // tag id int m_nTagId; // search id int m_nSearchId; // analysis id int m_nAnalysisId; // field id int m_nFieldId; // x-ray position CPoint m_poiXRayPos; CPoint m_absolutPos;//the ots coordinate position in the whole measure area. not the screen position. // feature COTSFeaturePtr m_pFeature; CPosXrayPtr m_pXRayInfo; }; typedef std::shared_ptr __declspec(dllexport) COTSParticlePtr; typedef std::vector __declspec(dllexport) COTSParticleList; }