#pragma once #include "afx.h" #include "OTSFeature.h" #include "otsdataconst.h" #include "BSEImg.h" #include "PosXray.h" #include "OTSRect.h" namespace OTSDATA { const double Pi = 3.14159; class COTSParticle; typedef std::shared_ptr __declspec(dllexport) COTSParticlePtr; 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 GetParticleId() { return m_nTagId; } void SetParticleId(int a_nTagId) { m_nTagId = a_nTagId; if (m_pXRayInfo != nullptr) { m_pXRayInfo->SetPartTagId(a_nTagId); } } // 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 GetActualArea() { return m_dArea; } void SetActualArea(double a_nArea) { m_dArea = a_nArea; } // Pixel area double GetPixelArea() { if (m_dPixelArea == 0) CalPixelArea(); return m_dPixelArea; } void SetPixelArea(double a_nArea) { m_dPixelArea = a_nArea; } // rectangle CRect GetParticleRect() { if (m_rectParticle.Width() == 0) { CalCoverRectFromSegment(); } return m_rectParticle; } void SetParticleRect(CRect& a_rectParticle) { m_rectParticle = a_rectParticle; } COTSRect GetOTSRect() { return m_OTSRect; } void SetOTSRect(COTSRect r) { m_OTSRect = r; } // gray BYTE GetAveGray() { return m_cAveGray; } void SetAveGray(char a_cAveGray) { m_cAveGray = a_cAveGray; } // type int GetClassifyId() { return m_classifyId; } void SetClassifyId(int a_nType) { m_classifyId = 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; } CPosXrayPtr GetXrayInfo() const { return m_pXRayInfo; } void SetXrayInfo(CPosXrayPtr val) { m_pXRayInfo = val; } std::vector GetXrayMatrixPoints() { return m_MatrixPoints; } void SetXrayMatrixPoints(std::vector points) { m_MatrixPoints = points; } CPoint GetSEMPos() { return m_absolutPos; } void SetSEMPos(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 SetMinWidth(double w) { m_Width = w; } double GetMinWidth() { return m_Width; } //设置该颗粒的最小外接矩形的长度 void SetMinHeight(double h) { m_Height = h; } double GetMinHeight() { return m_Height; } 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_DMin; } double GetAspectRatio() { return m_DMax / m_DMin; } double GetVideo() {return m_cAveGray;} double GetEqualCircleDiameter() { double Diameter; double dSize = this->GetActualArea(); Diameter = sqrt(dSize / Pi) * 2; return Diameter; } double GetImgPropertyValueByName(CString propertyName); std::string GetImgPortraitString(); double CalculateSimilarity(COTSParticlePtr part); // calculate area, rect, average gray, and xRay pos BOOL CalCoverRectFromSegment(); BOOL CalPixelArea(); BOOL CalXRayPos(); BOOL CalActualArea(double pixelsize); std::string GetClassifyName() const { return m_classifyName; } void SetClassifyName(std::string val) { m_classifyName = val; } std::string GetColor() const { return m_TypeColor; } void SetColor(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 GetConnectedParticlesSequentialString() const { return m_connectedParticlesName; } void SetConnectedParticlesSequentialString(std::string val) { m_connectedParticlesName = val; } std::vector> GetSubParticles() const { return m_subParticles; } void SetSubParticles(std::vector> val) { m_subParticles = val; } void AddSubParticle(std::shared_ptr val) { m_subParticles.push_back(val); } void ClearSubParticles() { m_subParticles.clear(); } BOOL IsConnected(COTSParticle* a_p, int fldwidth, int fldheight, int direction); BOOL IfContain(CPoint pos);//determine if the point is in the region of this particle. int GetGroupId() { return (int)m_grpId; } void SetGroupId(int a_grpId) { m_grpId = (IDENTIFIED_INC_GRP_ID)a_grpId; } std::string GetGroupName() const { return m_grpName; } void SetGroupName(std::string val) { m_grpName = val; } std::string GetGroupColor() const { return m_grpColor; } void SetGroupColor(std::string val) { m_grpColor = val; } BOOL IsXrayParticle() const { return m_isXrayParticle; } void SetIsXrayParticle(bool value) { m_isXrayParticle = value; } protected: // cleanup void Cleanup(); // initialization void Init(); // duplication void Duplicate(const COTSParticle& a_oSource); double GetMorphologyVectorNorm(); std::vector GetMorphData(); bool m_isXrayParticle; // area double m_dArea; double m_dPixelArea; // rectangle CRect m_rectParticle; COTSRect m_OTSRect; // 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_classifyId; OTS_PARTICLE_TYPE m_nType; IDENTIFIED_INC_GRP_ID m_grpId; std::string m_grpName; std::string m_grpColor; std::string m_classifyName; std::string m_TypeColor; std::string m_hardness; std::string m_density; std::string m_conductivity; std::string m_connectedParticlesName; std::vector> 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; std::vector m_MatrixPoints; std::vector m_MatrixXrayInfo; CPoint m_absolutPos;//the ots coordinate position in the whole measure area. not the screen position. // feature COTSFeaturePtr m_pFeature; CPosXrayPtr m_pXRayInfo; double m_vectorNorm=0; }; typedef std::vector __declspec(dllexport) COTSParticleList; }