| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 | #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<COTSParticle> __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<CPoint> GetXrayMatrixPoints() {			return m_MatrixPoints;		}		void SetXrayMatrixPoints(std::vector<CPoint> 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; }		// chemical type		//GB_CHEMICAL_TYPE GetChemicalType() { return m_nChemical; }//for GB 30834 Method2		//void SetChemicalType(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_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();		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<std::shared_ptr<COTSParticle>> GetSubParticles() const { return m_subParticles; }		void SetSubParticles(std::vector<std::shared_ptr<COTSParticle>> val) { m_subParticles = val; }		void AddSubParticle(std::shared_ptr<COTSParticle> val) { m_subParticles.push_back(val); }		void ClearSubParticles() { m_subParticles.clear(); }			BOOL IsConnected(COTSParticle* a_p, int fldwidth, int fldheight, int direction);	    		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<double> 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<std::shared_ptr<COTSParticle>> 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<CPoint> m_MatrixPoints;		std::vector<CPosXrayPtr> 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<COTSParticlePtr> __declspec(dllexport) COTSParticleList;}
 |