瀏覽代碼

optimize GB cal

gsp 1 年之前
父節點
當前提交
78f97d7e79

+ 3 - 3
OTSCPP/OTSData/OTSParticle.h

@@ -122,8 +122,8 @@ const double Pi = 3.14159;
 		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; }
+		//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; }
@@ -249,7 +249,7 @@ protected:
 		double m_Dm;
 		double m_De;
 		double m_Orientation;
-		GB_CHEMICAL_TYPE m_nChemical;
+		//GB_CHEMICAL_TYPE m_nChemical;
 
 		// gray
 		BYTE m_cAveGray;

+ 2 - 2
OTSCPP/OTSData/otsdataconst.h

@@ -260,7 +260,7 @@ namespace OTSDATA
 		MAX = 2
 	} MEMBRANE_TYPE;
 
-	typedef enum class __declspec(dllexport) GB_LEVEL_TYPE
+	typedef enum class __declspec(dllexport) GB_CLASSIFY_TYPE
 	{
 		INVALID = -1,
 		MIN = 0,
@@ -271,7 +271,7 @@ namespace OTSDATA
 		DS_TYPE = 4,
 		DSulfide_TYPE = 5,
 		MAX = 5
-	} GB_LEVEL_TYPE;
+	} GB_CLASSIFY_TYPE;
 
 	typedef enum class __declspec(dllexport) GB_WIDTH_TYPE
 	{

+ 2 - 1
OTSCPP/OTSImagePro/BaseFunction.cpp

@@ -295,7 +295,7 @@ void CVRemoveBG(const cv::Mat& img, cv::Mat& dst,int bgstart,int bgend, long& nN
 	cv::morphologyEx(image, out_fill, cv::MorphTypes::MORPH_OPEN, cv::getStructuringElement(0, cv::Size(1, 5)), cv::Point(-1, -1), 1);
 	out_fill = out_fill + out_fill0;
 	//±ÕÔËËã 
-	//cv::morphologyEx(out_fill, out_fill, cv::MorphTypes::MORPH_CLOSE, cv::getStructuringElement(0, cv::Size(5, 3)), cv::Point(-1, -1), 1);
+	cv::morphologyEx(out_fill, out_fill, cv::MorphTypes::MORPH_CLOSE, cv::getStructuringElement(0, cv::Size(3, 3)), cv::Point(-1, -1), 1);
 	//¶þÖµ
 	cv::threshold(out_fill, out_fill, 1, 255, cv::ThresholdTypes::THRESH_BINARY);
 	dst = out_fill.clone();
@@ -330,4 +330,5 @@ void RemoveBG_old(const cv::Mat& img, cv::Mat& dst, int nBGStart, int nBGEnd,lon
 		BDilate3(pTempImg, pPixel, errodDilateParam, h, w);
 	}
 	dst.data = pPixel;
+	delete[] pTempImg;
 }

+ 3 - 2
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -576,7 +576,7 @@ namespace OTSIMGPROC
 
 		long nImgSize = nWidthImg * nHeightImg;
 
-		BYTE* pTempImg = new BYTE[nImgSize];		
+	
 
 		BYTE* pSrcImg = a_pImgIn->GetImageDataPointer();
 	
@@ -639,13 +639,14 @@ namespace OTSIMGPROC
 			default:
 				break;
 			}
+			pPixel = rstMat.data;
 			
 		
 		}
 		a_pBinImgOut->SetImageData(pPixel,nWidthImg,nHeightImg);
 		
 		foundedPixelNum = nNumParticle;
-		delete[] pTempImg;
+		
 		
 		return ;
 	}

+ 17 - 17
OTSCPP/OTSRptCalculate/GBCal/CGBCalculate.cpp

@@ -341,19 +341,19 @@ namespace OTSGBCalculate
 	CGridDatasList CGBCalculate::GetGridDataListForOneDataSourceDIN(CGBFieldDataPtr DINFld)
 	{
 		CGridDatasList listGridData;
-		COTSParticleList cotsparticlelistA;
-		set<COTSParticlePtr> cotsparticlelistB;
-		COTSParticleList cotsparticlelistC;
-		COTSParticleList cotsparticlelistD;
+		CGBParticleList cGBparticlelistA;
+		CGBParticleList cGBparticlelistB;
+		CGBParticleList cGBparticlelistC;
+		CGBParticleList cGBparticlelistD;
 
 	
-		cotsparticlelistA = DINFld->listAThinParticles;
-		cotsparticlelistB = DINFld->listBThinParticles;
-		cotsparticlelistC = DINFld->listCThinParticles;
-		cotsparticlelistD = DINFld->listDThinParticles;
+		cGBparticlelistA = DINFld->listAThinParticles;
+		cGBparticlelistB = DINFld->listBThinParticles;
+		cGBparticlelistC = DINFld->listCThinParticles;
+		cGBparticlelistD = DINFld->listDThinParticles;
 
 		CGridDataPtr AGrid;
-		AGrid = GetGridDIN(cotsparticlelistA, cotsparticlelistB, cotsparticlelistC, cotsparticlelistD);
+		AGrid = GetGridDIN(cGBparticlelistA, cGBparticlelistB, cGBparticlelistC, cGBparticlelistD);
 		listGridData.push_back(AGrid);
 
 		return listGridData;
@@ -575,7 +575,7 @@ namespace OTSGBCalculate
 	}
 		
 	//get grid with level ABCD
-	CGridDataPtr CGBCalculate::GetGridDIN(COTSParticleList cotsparticlelistA, set<COTSParticlePtr> cotsparticlelistB, COTSParticleList cotsparticlelistC, COTSParticleList cotsparticlelistD)
+	CGridDataPtr CGBCalculate::GetGridDIN(CGBParticleList cotsparticlelistA, CGBParticleList cotsparticlelistB, CGBParticleList cotsparticlelistC, CGBParticleList cotsparticlelistD)
 	{
 		CGridDataPtr pGridData = CGridDataPtr(new CGridData());
 		std::vector<CString> listDataSource;
@@ -1057,7 +1057,7 @@ namespace OTSGBCalculate
 						part->SetOTSRect(recInOTSCord);
 
 
-						pGBFieldData->IdentifyPartChemicalType(part);
+						
 						listNormalizedParticles.push_back(part);
 					}
 
@@ -1069,7 +1069,7 @@ namespace OTSGBCalculate
 
 	
 		// put new particle in the  GB Field
-		pGBFieldData->SetParticleList(listNormalizedParticles);
+		pGBFieldData->SetOTSParticleList(listNormalizedParticles);
 		return pGBFieldData;
 	}
 
@@ -1079,7 +1079,7 @@ namespace OTSGBCalculate
 		PixSize = p;
 	}
 
-	void CGBCalculate::DisplayDSPartRow(COTSParticlePtr part, CGridColumnsList listCol)
+	void CGBCalculate::DisplayDSPartRow(CGBParticlePtr part, CGridColumnsList listCol)
 	{
 		int columnNum = 6;
 		CGridColumnPtr pColumn;
@@ -1098,8 +1098,8 @@ namespace OTSGBCalculate
 				pColumn = listCol.at(0);
 				pRow = CGridRowPtr(new CGridRow());
 				pRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
-				fldid = part->GetFieldId();
-				partId = part->GetParticleId();
+				fldid = part->myOTSParts[0]->GetFieldId();
+				partId = part->myOTSParts[0]->GetParticleId();
 
 				idstr.Format("%d_%d", fldid, partId);
 
@@ -1125,14 +1125,14 @@ namespace OTSGBCalculate
 				pColumn = listCol.at(3);
 				pRow = CGridRowPtr(new CGridRow());
 				pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
-				pRow->SetDoubleValue(part->GetSEMPos().x);
+				pRow->SetDoubleValue(part->myOTSParts[0]->GetSEMPos().x);
 				pColumn->AddGridRow(pRow);
 				break;
 			case 4:
 				pColumn = listCol.at(4);
 				pRow = CGridRowPtr(new CGridRow());
 				pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
-				pRow->SetDoubleValue(part->GetSEMPos().y);
+				pRow->SetDoubleValue(part->myOTSParts[0]->GetSEMPos().y);
 				pColumn->AddGridRow(pRow);
 				break;
 			case 5:

+ 2 - 2
OTSCPP/OTSRptCalculate/GBCal/CGBCalculate.h

@@ -50,7 +50,7 @@ namespace OTSGBCalculate
 	
 
 		CGridDataPtr GetGridLevel(CString GridType, GBGradeCell a_nLevel[], GBGradeCell a_nLevel_w[], GBGradeCell a_nLevel_s[]);
-		CGridDataPtr GetGridDIN(COTSParticleList cotsparticlelistA, set<COTSParticlePtr> cotsparticlelistB, COTSParticleList cotsparticlelistC, COTSParticleList cotsparticlelistD);
+		CGridDataPtr GetGridDIN(CGBParticleList cotsparticlelistA, CGBParticleList cotsparticlelistB, CGBParticleList cotsparticlelistC, CGBParticleList cotsparticlelistD);
 		CGridDataPtr GetGridDSLevel(CGBGradeData* gradeData);
 		void SetFrameLevelNo(GB_GRADE_TYPE levela, int nALevel[]);
 									
@@ -62,7 +62,7 @@ namespace OTSGBCalculate
 		//pointer to the whole reportprojfilemgr
 		CReportMgr* m_rptMgrPtr;
 	private:
-		void DisplayDSPartRow(COTSParticlePtr part, CGridColumnsList listCol);
+		void DisplayDSPartRow(CGBParticlePtr part, CGridColumnsList listCol);
 	};
 	
 

+ 1 - 1
OTSCPP/OTSRptCalculate/GBCal/CGBGradeData.h

@@ -142,7 +142,7 @@ namespace OTSGBCalculate
 		GBGradeCell DSulfideLevel[LEVEL_LENGTH];// nDLevelZero, nDLevel_0_5, nDLevel_1_0, nDLevel_1_5, nDLevel_2_0, nDLevel_2_5, nDLevel_3_0, nDLevel_3_5, nDLevel_4_0, nDLevel_4_5, nDLevel_5_0;
 		GBGradeCell DSulfideLevel_w[LEVEL_LENGTH]; //nDLevelZero_f, nDLevel_0_5_f, nDLevel_1_0_f, nDLevel_1_5_f, nDLevel_2_0_f, nDLevel_2_5_f, nDLevel_3_0_f, nDLevel_3_5_f, nDLevel_4_0_f, nDLevel_4_5_f, nDLevel_5_0_f;
 		GBGradeCell DSulfideLevel_s[LEVEL_LENGTH];
-		COTSParticleList allDSParts;
+		CGBParticleList allDSParts;
 		
 		private: 
 			CGBFieldList GBMeasureArea;

+ 32 - 32
OTSCPP/OTSRptCalculate/GBCal/CGBLevel.cpp

@@ -15,7 +15,7 @@ namespace OTSGBCalculate
 		Init();
 	}
 
-	CGBLevel::CGBLevel(CGBFieldData* GBField, GB_LEVEL_TYPE a_nLevel)
+	CGBLevel::CGBLevel(CGBFieldData* GBField, GB_CLASSIFY_TYPE a_nLevel)
 	{
 		m_GBField = GBField;
 		m_nLevel = a_nLevel;
@@ -86,7 +86,7 @@ namespace OTSGBCalculate
 		int nSize;
 		switch (m_nLevel)
 		{
-		case GB_LEVEL_TYPE::A_TYPE:
+		case GB_CLASSIFY_TYPE::A_TYPE:
 
 
 			for (auto pAparticle : m_GBField->listAThinParticles)
@@ -101,7 +101,7 @@ namespace OTSGBCalculate
 			return GetAGrade(dLengthAll);
 
 			break;
-		case  GB_LEVEL_TYPE::B_TYPE:
+		case  GB_CLASSIFY_TYPE::B_TYPE:
 
 			dLengthAll = 0;
 			for (auto pBparticle : m_GBField->listBThinParticles)
@@ -114,7 +114,7 @@ namespace OTSGBCalculate
 			}
 			return	GetBGrade(dLengthAll);
 
-		case  GB_LEVEL_TYPE::C_TYPE:
+		case  GB_CLASSIFY_TYPE::C_TYPE:
 			dLengthAll = 0;
 			for (auto pCparticle : m_GBField->listCThinParticles)
 			{
@@ -126,13 +126,13 @@ namespace OTSGBCalculate
 			}
 			return	GetCGrade(dLengthAll);
 			break;
-		case  GB_LEVEL_TYPE::D_TYPE:
+		case  GB_CLASSIFY_TYPE::D_TYPE:
 
 			 nSize = (int)m_GBField->listDThinParticles.size();
 			return	GetDGrade(nSize);
 			break;
 
-		case  GB_LEVEL_TYPE::DSulfide_TYPE:
+		case  GB_CLASSIFY_TYPE::DSulfide_TYPE:
 
 			nSize = (int)m_GBField->listDSulfideThinParticles.size();
 			return	GetDGrade(nSize);
@@ -150,7 +150,7 @@ namespace OTSGBCalculate
 		int nSize;
 		switch (m_nLevel)
 		{
-		case GB_LEVEL_TYPE::A_TYPE:
+		case GB_CLASSIFY_TYPE::A_TYPE:
 
 
 			for (auto pAparticle : m_GBField->listAWideParticles)
@@ -164,7 +164,7 @@ namespace OTSGBCalculate
 			return GetAGrade(dLengthAll);
 
 			break;
-		case  GB_LEVEL_TYPE::B_TYPE:
+		case  GB_CLASSIFY_TYPE::B_TYPE:
 
 			dLengthAll = 0;
 			for (auto pBparticle : m_GBField->listBWideParticles)
@@ -177,7 +177,7 @@ namespace OTSGBCalculate
 			}
 			return	GetBGrade(dLengthAll);
 
-		case  GB_LEVEL_TYPE::C_TYPE:
+		case  GB_CLASSIFY_TYPE::C_TYPE:
 			dLengthAll = 0;
 			for (auto pCparticle : m_GBField->listCWideParticles)
 			{
@@ -191,12 +191,12 @@ namespace OTSGBCalculate
 
 
 			break;
-		case  GB_LEVEL_TYPE::D_TYPE:
+		case  GB_CLASSIFY_TYPE::D_TYPE:
 
 			 nSize = (int)m_GBField->listDWideParticles.size();
 			return	GetDGrade(nSize);
 			break;
-		case  GB_LEVEL_TYPE::DSulfide_TYPE:
+		case  GB_CLASSIFY_TYPE::DSulfide_TYPE:
 
 			 nSize = (int)m_GBField->listDSulfideWideParticles.size();
 			return	GetDGrade(nSize);
@@ -212,7 +212,7 @@ namespace OTSGBCalculate
 		int nSize;
 		switch (m_nLevel)
 		{
-		case GB_LEVEL_TYPE::A_TYPE:
+		case GB_CLASSIFY_TYPE::A_TYPE:
 
 
 			for (auto pAparticle : m_GBField->listASuperParticles)
@@ -226,7 +226,7 @@ namespace OTSGBCalculate
 			return GetAGrade(dLengthAll);
 
 			break;
-		case  GB_LEVEL_TYPE::B_TYPE:
+		case  GB_CLASSIFY_TYPE::B_TYPE:
 
 			dLengthAll = 0;
 			for (auto pBparticle : m_GBField->listBSuperParticles)
@@ -238,7 +238,7 @@ namespace OTSGBCalculate
 			}
 			return	GetBGrade(dLengthAll);
 
-		case  GB_LEVEL_TYPE::C_TYPE:
+		case  GB_CLASSIFY_TYPE::C_TYPE:
 			dLengthAll = 0;
 			for (auto pParticle : m_GBField->listCSuperParticles)
 			{
@@ -252,12 +252,12 @@ namespace OTSGBCalculate
 
 
 			break;
-		case  GB_LEVEL_TYPE::D_TYPE:
+		case  GB_CLASSIFY_TYPE::D_TYPE:
 
 			 nSize = (int)m_GBField->listDSuperParticles.size();
 			return	GetDGrade(nSize);
 			break;
-		case  GB_LEVEL_TYPE::DSulfide_TYPE:
+		case  GB_CLASSIFY_TYPE::DSulfide_TYPE:
 
 			nSize = (int)m_GBField->listDSulfideSuperParticles.size();
 			return	GetDGrade(nSize);
@@ -294,7 +294,7 @@ namespace OTSGBCalculate
 		int nSize;
 		switch (m_nLevel)
 		{
-		case GB_LEVEL_TYPE::A_TYPE:
+		case GB_CLASSIFY_TYPE::A_TYPE:
 
 
 			for (auto pAparticle : m_GBField->listAThinParticles)
@@ -309,7 +309,7 @@ namespace OTSGBCalculate
 			return dLengthAll;
 
 			break;
-		case  GB_LEVEL_TYPE::B_TYPE:
+		case  GB_CLASSIFY_TYPE::B_TYPE:
 
 			dLengthAll = 0;
 			for (auto pBparticle : m_GBField->listBThinParticles)
@@ -322,7 +322,7 @@ namespace OTSGBCalculate
 			}
 			return	dLengthAll;
 
-		case  GB_LEVEL_TYPE::C_TYPE:
+		case  GB_CLASSIFY_TYPE::C_TYPE:
 			dLengthAll = 0;
 			for (auto pCparticle : m_GBField->listCThinParticles)
 			{
@@ -334,13 +334,13 @@ namespace OTSGBCalculate
 			}
 			return	dLengthAll;
 			break;
-		case  GB_LEVEL_TYPE::D_TYPE:
+		case  GB_CLASSIFY_TYPE::D_TYPE:
 
 			nSize = (int)m_GBField->listDThinParticles.size();
 			return	nSize;
 			break;
 
-		case  GB_LEVEL_TYPE::DSulfide_TYPE:
+		case  GB_CLASSIFY_TYPE::DSulfide_TYPE:
 
 			nSize = (int)m_GBField->listDSulfideThinParticles.size();
 			return	nSize;
@@ -357,7 +357,7 @@ namespace OTSGBCalculate
 		int nSize;
 		switch (m_nLevel)
 		{
-		case GB_LEVEL_TYPE::A_TYPE:
+		case GB_CLASSIFY_TYPE::A_TYPE:
 
 
 			for (auto pAparticle : m_GBField->listAWideParticles)
@@ -371,7 +371,7 @@ namespace OTSGBCalculate
 			return dLengthAll;
 
 			break;
-		case  GB_LEVEL_TYPE::B_TYPE:
+		case  GB_CLASSIFY_TYPE::B_TYPE:
 
 			dLengthAll = 0;
 			for (auto pBparticle : m_GBField->listBWideParticles)
@@ -384,7 +384,7 @@ namespace OTSGBCalculate
 			}
 			return	dLengthAll;
 
-		case  GB_LEVEL_TYPE::C_TYPE:
+		case  GB_CLASSIFY_TYPE::C_TYPE:
 			dLengthAll = 0;
 			for (auto pCparticle : m_GBField->listCWideParticles)
 			{
@@ -398,12 +398,12 @@ namespace OTSGBCalculate
 
 
 			break;
-		case  GB_LEVEL_TYPE::D_TYPE:
+		case  GB_CLASSIFY_TYPE::D_TYPE:
 
 			nSize = (int)m_GBField->listDWideParticles.size();
 			return	nSize;
 			break;
-		case  GB_LEVEL_TYPE::DSulfide_TYPE:
+		case  GB_CLASSIFY_TYPE::DSulfide_TYPE:
 
 			nSize = (int)m_GBField->listDSulfideWideParticles.size();
 			return	nSize;
@@ -418,7 +418,7 @@ namespace OTSGBCalculate
 		int nSize;
 		switch (m_nLevel)
 		{
-		case GB_LEVEL_TYPE::A_TYPE:
+		case GB_CLASSIFY_TYPE::A_TYPE:
 
 
 			for (auto pAparticle : m_GBField->listASuperParticles)
@@ -432,7 +432,7 @@ namespace OTSGBCalculate
 			return dLengthAll;
 
 			break;
-		case  GB_LEVEL_TYPE::B_TYPE:
+		case  GB_CLASSIFY_TYPE::B_TYPE:
 
 			dLengthAll = 0;
 			for (auto pBparticle : m_GBField->listBSuperParticles)
@@ -444,7 +444,7 @@ namespace OTSGBCalculate
 			}
 			return	dLengthAll;
 
-		case  GB_LEVEL_TYPE::C_TYPE:
+		case  GB_CLASSIFY_TYPE::C_TYPE:
 			dLengthAll = 0;
 			for (auto pParticle : m_GBField->listCSuperParticles)
 			{
@@ -458,12 +458,12 @@ namespace OTSGBCalculate
 
 
 			break;
-		case  GB_LEVEL_TYPE::D_TYPE:
+		case  GB_CLASSIFY_TYPE::D_TYPE:
 
 			nSize = (int)m_GBField->listDSuperParticles.size();
 			return	nSize;
 			break;
-		case  GB_LEVEL_TYPE::DSulfide_TYPE:
+		case  GB_CLASSIFY_TYPE::DSulfide_TYPE:
 
 			nSize = (int)m_GBField->listDSulfideSuperParticles.size();
 			return	nSize;
@@ -733,7 +733,7 @@ namespace OTSGBCalculate
 	// initialization
 	void CGBLevel::Init()
 	{
-		m_nLevel = GB_LEVEL_TYPE::INVALID;
+		m_nLevel = GB_CLASSIFY_TYPE::INVALID;
 
 
 

+ 2 - 2
OTSCPP/OTSRptCalculate/GBCal/CGBLevel.h

@@ -12,7 +12,7 @@ namespace OTSGBCalculate
 	public:
 		CGBLevel();
 		// constructor
-		CGBLevel(CGBFieldData * GBField, GB_LEVEL_TYPE a_nLevel);
+		CGBLevel(CGBFieldData * GBField, GB_CLASSIFY_TYPE a_nLevel);
 
 		CGBLevel(const CGBLevel&);			// copy constructor
 		CGBLevel(CGBLevel*);					// copy constructor
@@ -51,7 +51,7 @@ namespace OTSGBCalculate
 
 	private:
 		//ÊÓ³¡¸÷ÀàµÄ·Ö¼¶Êý£ºA / B / C / D / DS
-		GB_LEVEL_TYPE m_nLevel;
+		GB_CLASSIFY_TYPE m_nLevel;
 		CGBFieldData* m_GBField;
 		double m_FeretDiameterMax;
 	};

文件差異過大導致無法顯示
+ 319 - 454
OTSCPP/OTSRptCalculate/GBCal/GBFieldData.cpp


+ 34 - 42
OTSCPP/OTSRptCalculate/GBCal/GBFieldData.h

@@ -9,17 +9,8 @@ namespace OTSGBCalculate
 {
 	using namespace std;
 	using namespace OTSDATA;
-	const CString STR_Al = _T("Al");
-	const CString STR_SI = _T("Si");
-	const CString STR_O = _T("O");
-	const CString STR_SUL = _T("S");
-	const CString STR_N = _T("N");
-	const CString STR_Mn = _T("Mn");
-	const CString STR_Fe = _T("Fe");
-	const CString STR_C = _T("C");
-	const double MIN_ELEMENT_SUM = 0.02;
-	const double RICH_ELEMENT_SUM = 5;
-	class __declspec(dllexport) CGBFieldData : public COTSFieldData
+	
+	class __declspec(dllexport) CGBFieldData 
 	{
 	public:
 
@@ -33,10 +24,11 @@ namespace OTSGBCalculate
 
 		void SetMyRect(COTSRect r) { m_myRect = r; }
 		COTSRect GetMyRect() { return m_myRect; }
-
-												// serialization
-		//virtual void Serialize(bool isStoring, tinyxml2::XMLDocument *classDoc, tinyxml2::XMLElement *rootNode);
-		// id
+		COTSParticleList& GetALLOTSParticleList() { return m_listOTSParticles; }
+		void SetOTSParticleList(COTSParticleList& a_listParticles, BOOL a_bClear = TRUE);
+		CPoint GetPosition() { return m_poiPos; }
+		void SetPosition(CPoint a_poiPos) { m_poiPos.x = a_poiPos.x; m_poiPos.y = a_poiPos.y; }										// serialization
+		
 		int GetFrameId() { return m_nFrameId; }
 		void SetFrameId(int a_nFrameId) { m_nFrameId = a_nFrameId; }
 	
@@ -58,29 +50,29 @@ namespace OTSGBCalculate
 		// D sulfide level
 		CGBLevelPtr GetDSulfideLevel() { return m_pDSulfidLevel; }
 		COTSParticlePtr FindAdjacentParticle(COTSParticlePtr p, COTSParticleList plist);
-		// caculate Level
-		//void CaculateLevel( OTSMODEL::GB_METHODE_TYPE a_nMethodType);
-		COTSParticleList listAThinParticles;
-		COTSParticleList listAWideParticles;
-		COTSParticleList listASuperParticles;
-		set<COTSParticlePtr>  listBThinParticles;
-		set<COTSParticlePtr> listBWideParticles;
-		set<COTSParticlePtr> listBSuperParticles;
-		COTSParticleList listCThinParticles;
-		COTSParticleList listCWideParticles;
-		COTSParticleList listCSuperParticles;
-		COTSParticleList listDThinParticles;
-		COTSParticleList listDWideParticles;
-		COTSParticleList listDSuperParticles;
-		COTSParticleList listDSParticles;
-		COTSParticleList listDSulfideThinParticles;
-		COTSParticleList listDSulfideWideParticles;
-		COTSParticleList listDSulfideSuperParticles;
-
+	
+		CGBParticleList listAThinParticles;
+		CGBParticleList listAWideParticles;
+		CGBParticleList listASuperParticles;
+		CGBParticleList  listBThinParticles;
+		CGBParticleList listBWideParticles;
+		CGBParticleList listBSuperParticles;
+		CGBParticleList listCThinParticles;
+		CGBParticleList listCWideParticles;
+		CGBParticleList listCSuperParticles;
+		CGBParticleList listDThinParticles;
+		CGBParticleList listDWideParticles;
+		CGBParticleList listDSuperParticles;
+		CGBParticleList listDSParticles;
+		CGBParticleList listDSulfideThinParticles;
+		CGBParticleList listDSulfideWideParticles;
+		CGBParticleList listDSulfideSuperParticles;
 
+		
 		COTSFieldDataList myReleventOTSFlds;
-		std::map<COTSParticlePtr, GBParticle> mapAllParticles;
-		std::vector <GBParticle> allMyParticles;
+		COTSParticleList m_listOTSParticles;
+		//std::map<COTSParticlePtr, GBParticle> mapAllParticles;
+		//std::vector <GBParticle> allMyParticles;
 		void CategoryByMethod1();
 
 		// caculate Level by method 2
@@ -90,7 +82,7 @@ namespace OTSGBCalculate
 
 		void CaculateLevelDIN(COTSParticleList listParticle);
 
-		BOOL IdentifyPartChemicalType(COTSParticlePtr Particle);
+		void ConnectStringParts(COTSParticleList listParticle, CGBParticleList& listGBParticle);
 
 		std::string GetGBGradeString();
 
@@ -112,11 +104,11 @@ namespace OTSGBCalculate
 
 
 		// caculate Level Width
-		BOOL CaculateLevelThinWidth(COTSParticleList& a_listParticles, GB_LEVEL_TYPE a_nLevel);
-		GB_WIDTH_TYPE CaculateLevelWidth(COTSParticlePtr Particle, GB_LEVEL_TYPE a_nLevel);
+		BOOL CaculateLevelThinWidth(COTSParticleList& a_listParticles, GB_CLASSIFY_TYPE a_nLevel);
+		//GB_WIDTH_TYPE CaculateLevelWidth(COTSParticlePtr Particle, GB_CLASSIFY_TYPE a_nLevel);
 
-		BOOL CaculateLevelFatWidth(COTSParticleList& a_listParticles, GB_LEVEL_TYPE a_nLevel);
-		BOOL CaculateSuper(COTSParticleList& a_listParticles, GB_LEVEL_TYPE a_nLevel);
+		BOOL CaculateLevelFatWidth(COTSParticleList& a_listParticles, GB_CLASSIFY_TYPE a_nLevel);
+		BOOL CaculateSuper(COTSParticleList& a_listParticles, GB_CLASSIFY_TYPE a_nLevel);
 		
 		GB_METHODE_TYPE calcuType;
 	private:
@@ -126,7 +118,7 @@ namespace OTSGBCalculate
 		int m_nFrameId;
 
 		COTSRect m_myRect;
-
+		CPoint m_poiPos;
 		// A level
 		CGBLevelPtr m_pALevel;
 

+ 204 - 4
OTSCPP/OTSRptCalculate/GBCal/GBParticle.cpp

@@ -6,10 +6,210 @@ namespace OTSGBCalculate
 	using namespace std;
 	using namespace OTSDATA;
 
-	GBParticle::GBParticle(COTSParticlePtr p, GB_LEVEL_TYPE theType, GB_WIDTH_TYPE theWidth)
+	
+	GB_CHEMICAL_TYPE GBParticle::IdentifyPartChemicalType(COTSParticlePtr Particle)
 	{
-		myPart = p;
-		myType = theType;
-		myWidth = theWidth;
+		const CString STR_Al = _T("Al");
+		const CString STR_SI = _T("Si");
+		const CString STR_O = _T("O");
+		const CString STR_SUL = _T("S");
+		const CString STR_N = _T("N");
+		const CString STR_Mn = _T("Mn");
+		const CString STR_Fe = _T("Fe");
+		const CString STR_C = _T("C");
+		const double MIN_ELEMENT_SUM = 0.02;
+		const double RICH_ELEMENT_SUM = 5;
+		if (Particle->GetXrayInfo() == NULL)
+		{
+			return GB_CHEMICAL_TYPE::INVALID;
+			
+		}
+		auto chamicalList = Particle->GetXrayInfo()->GetElementQuantifyData();
+
+		double dOWeight = 0;
+		double dSWeight = 0;
+		double dNWeight = 0;
+		double dSiWeight = 0;
+		double dAlWeight = 0;
+		double dMnWeight = 0;
+		double dFeWeight = 0;
+		double dCWeight = 0;
+
+
+
+
+		for (auto pElChem : chamicalList)
+		{
+
+			if (pElChem->GetName().CompareNoCase(STR_O) == 0)
+			{
+
+				dOWeight = pElChem->GetPercentage();
+
+			}
+			else if (pElChem->GetName().CompareNoCase(STR_SUL) == 0)
+			{
+
+				dSWeight = pElChem->GetPercentage();
+
+			}
+			else if (pElChem->GetName().CompareNoCase(STR_N) == 0)
+			{
+				dNWeight = pElChem->GetPercentage();
+			}
+			else if (pElChem->GetName().CompareNoCase(STR_SI) == 0)
+			{
+				dSiWeight = pElChem->GetPercentage();
+			}
+			else if (pElChem->GetName().CompareNoCase(STR_Al) == 0)
+			{
+				dAlWeight = pElChem->GetPercentage();
+			}
+			else if (pElChem->GetName().CompareNoCase(STR_Mn) == 0)
+			{
+				dMnWeight = pElChem->GetPercentage();
+			}
+			else if (pElChem->GetName().CompareNoCase(STR_Fe) == 0)
+			{
+				dFeWeight = pElChem->GetPercentage();
+			}
+			else if (pElChem->GetName().CompareNoCase(STR_C) == 0)
+			{
+				dCWeight = pElChem->GetPercentage();
+			}
+
+
+
+		}
+
+
+		if (dSWeight >= MIN_ELEMENT_SUM && dMnWeight > MIN_ELEMENT_SUM)
+		{
+
+			return GB_CHEMICAL_TYPE::CHE_S;
+
+
+		}
+		else if (dSWeight >= MIN_ELEMENT_SUM && dOWeight < MIN_ELEMENT_SUM)//
+		{
+			return GB_CHEMICAL_TYPE::CHE_S;
+
+		}
+		else if (dOWeight >= MIN_ELEMENT_SUM && dAlWeight >= MIN_ELEMENT_SUM)
+		{
+			return GB_CHEMICAL_TYPE::CHE_Al;
+
+		}
+		else if (dOWeight >= MIN_ELEMENT_SUM && dSiWeight >= MIN_ELEMENT_SUM)
+		{
+			return GB_CHEMICAL_TYPE::CHE_Si;
+		}
+		else if (dOWeight >= RICH_ELEMENT_SUM)
+		{
+			return GB_CHEMICAL_TYPE::CHE_O;
+		}
+		else
+		{
+			return GB_CHEMICAL_TYPE::INVALID;
+		}
+
+	}
+	GB_WIDTH_TYPE 	 GBParticle::CaculateLevelWidth( GB_CLASSIFY_TYPE a_nLevel)
+	{
+		COTSParticlePtr Particle= myOTSParts[0];
+		for (auto p : myOTSParts)//get the longest particle 
+		{
+			if (p->GetDMax() > Particle->GetDMax())
+			{
+				Particle = p;
+			}
+		}
+
+		double dWidth = (double)Particle->GetDMin();
+		double dMin = 2, dMax = 0;
+
+		switch ((int)a_nLevel)
+		{
+		case (int)GB_CLASSIFY_TYPE::A_TYPE:
+			dMax = 4;
+			break;
+		case (int)GB_CLASSIFY_TYPE::B_TYPE:
+			dMax = 9;
+			break;
+		case (int)GB_CLASSIFY_TYPE::C_TYPE:
+			dMax = 5;
+			break;
+		case (int)GB_CLASSIFY_TYPE::D_TYPE:
+			dMax = 8;
+			break;
+		}
+
+		//if (dWidth < dMin)
+		//{
+		//	return GB_WIDTH_TYPE::INVALID;//СÓÚ2um²»¿¼ÂÇ
+		//}
+		/*else*/
+		if (dWidth >= 0 && dWidth <= dMax)
+		{
+			return GB_WIDTH_TYPE::THIN;
+		}
+
+		switch ((int)a_nLevel)
+		{
+		case (int)GB_CLASSIFY_TYPE::A_TYPE:
+			dMin = 4;
+			dMax = 12;
+			break;
+		case (int)GB_CLASSIFY_TYPE::B_TYPE:
+			dMin = 9;
+			dMax = 15;
+			break;
+		case (int)GB_CLASSIFY_TYPE::C_TYPE:
+			dMin = 5;
+			dMax = 12;
+			break;
+		case (int)GB_CLASSIFY_TYPE::D_TYPE:
+			dMin = 8;
+			dMax = 13;
+			break;
+		}
+		if (dWidth > dMin && dWidth <= dMax)
+		{
+			return GB_WIDTH_TYPE::WIDE;
+		}
+		switch ((int)a_nLevel)
+		{
+		case (int)GB_CLASSIFY_TYPE::A_TYPE:
+			dMin = 12;
+			break;
+		case (int)GB_CLASSIFY_TYPE::B_TYPE:
+			dMin = 15;
+			break;
+		case (int)GB_CLASSIFY_TYPE::C_TYPE:
+			dMin = 12;
+			break;
+		case (int)GB_CLASSIFY_TYPE::D_TYPE:
+			dMin = 13;
+			break;
+		}
+		if (dWidth > dMin)
+		{
+			return GB_WIDTH_TYPE::SUPER;
+		}
+
+		return GB_WIDTH_TYPE::INVALID;
+
+	}
+	double GBParticle::GetDMax()
+	{
+		return 0.0;
+	}
+	double GBParticle::GetFeretDiameter()
+	{
+		return 0.0;
+	}
+	double GBParticle::GetActualArea()
+	{
+		return 0.0;
 	}
 }

+ 12 - 4
OTSCPP/OTSRptCalculate/GBCal/GBParticle.h

@@ -9,15 +9,23 @@ namespace OTSGBCalculate
 	class GBParticle
 	{
 	public:
-		GBParticle(COTSParticlePtr p, GB_LEVEL_TYPE theType, GB_WIDTH_TYPE theWidth);
-
 		GBParticle()
 		{
 		}
 
-		GB_LEVEL_TYPE myType;
+		static GB_CHEMICAL_TYPE IdentifyPartChemicalType(COTSParticlePtr Particle);
+
+		GB_WIDTH_TYPE CaculateLevelWidth( GB_CLASSIFY_TYPE a_nLevel);
+		double GetDMax();
+		double GetFeretDiameter();
+		double GetActualArea();
+
+		GB_CLASSIFY_TYPE myType;
 		GB_WIDTH_TYPE myWidth;
 
-		COTSParticlePtr myPart;
+		
+		COTSParticleList myOTSParts;
 	};
+	typedef std::shared_ptr<GBParticle> __declspec(dllexport) CGBParticlePtr;
+	typedef std::vector<CGBParticlePtr> __declspec(dllexport) CGBParticleList;
 }

+ 200 - 5
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

@@ -5,6 +5,7 @@ using OTSModelSharp.ServiceCenter;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
+using System.Linq;
 using System.Xml;
 
 namespace OTSDataType
@@ -184,22 +185,200 @@ namespace OTSDataType
             imgwidth = a_pBSEImg.GetWidth();
             imgheight = a_pBSEImg.GetHeight();
         }
+        public void GetOriginalParticles(CSampleParam pMsrParam, double pixelsize)
+        {
+
+            // get image process parameter
+            //CSampleParam pMsrParam = m_Sample.GetMsrParams();
+            COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
+            var specialPartsparam = pMsrParam.GetSpecialGrayRangeParam();
+
+            if (specialPartsparam != null && specialPartsparam.GetIsToRun())
+            {
+                List<CSpecialGrayRange> ranges = specialPartsparam.GetSpecialGreyRanges();
+                foreach (var grayRange in ranges)
+                {
+                    CIntRangeClr range = new CIntRangeClr(grayRange.range.GetStart(), grayRange.range.GetEnd());
+                    CDoubleRangeClr diaRange = new CDoubleRangeClr(grayRange.diameterRange.GetStart(), grayRange.diameterRange.GetEnd());
+                    GetPartsBySpecialGray(range, diaRange, pixelsize, grayRange.ifCollectXray);
+                }
+            }
+          
+            // remove BES image background
+            RemoveImgBGAndGetParticles(pImgProcessParam, pixelsize);
 
-        public void RemoveImgBGAndGetParticles(COTSImageProcParam a_pImageProcessParam, double a_pixelSize, bool ifXray)
+            log.Info("Find all particle num:" + GetAllParticles().Count);
+
+            return;
+        }
+
+        private void RemoveImgBGAndGetParticles(COTSImageProcParam a_pImageProcessParam, double a_pixelSize)
         {
             if (m_pBSEImg == null)
                 return;
             CImageHandler imghandler = new CImageHandler();
             List<COTSParticleClr> allParts = new List<COTSParticleClr>();
             imghandler.RemoveBGAndGetParts(this, a_pImageProcessParam, ref allParts);
-            foreach (var p in allParts)
+           
+
+            return;
+        }
+        public void FilterParticles(COTSXRayParam pXRayParam)
+        {
+            log.Info("filter particle according to xraylimit");
+            var listXray = ((IOrderedEnumerable<COTSParticleClr>)m_listAllParticles).OrderByDescending(x => x.GetActualArea()).ToList();
+            var listXray1 = new List<COTSParticleClr>();
+            //var pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
+            if (listXray.Count > pXRayParam.GetXrayLimit())
             {
-                p.SetIsXrayParticle(ifXray);
-                m_listAllParticles.Add(p);
+                for (var i = 0; i < pXRayParam.GetXrayLimit(); i++)
+                {
+
+                    listXray1.Add(listXray[i]);
+                }
 
             }
+            else
+            {
+                listXray1 = listXray;
+            }
+
+            SetListAnalysisParticles(listXray1);
+
+            log.Info("Analysis particles:" + listXray1.Count);
+
+
+        }
+        public void SelectParticlesAccordingImgProp(COTSImageProcParam a_pImageProcessParam)
+        {
+            var selconditiondic = a_pImageProcessParam.GetParticleSelConditionDic();
+            var listselparts = new List<COTSParticleClr>();
+            var excludeparts = new List<COTSParticleClr>();
+            if (selconditiondic.ContainsKey("dmax"))
+            {
+                log.Info("Select particles according to dmax");
+                var rng = selconditiondic["dmax"];
+                foreach (var p in GetListAnalysisParticles())
+                {
+                    if (p.GetDMAX() < rng.GetStart() || p.GetDMAX() >= rng.GetEnd())
+                    {
+                        excludeparts.Add(p);
+                    }
+                    else
+                    {
+                        log.Info("dmax=" + p.GetDMAX().ToString("F2"));
+                    }
+
+                }
+
+            }
+            if (selconditiondic.ContainsKey("dmin"))
+            {
+                log.Info("Select particles according to dmin");
+                var rng = selconditiondic["dmin"];
+                foreach (var p in GetListAnalysisParticles())
+                {
+                    if (p.GetDMIN() < rng.GetStart() || p.GetDMIN() >= rng.GetEnd())
+                    {
+                        if (!excludeparts.Contains(p))
+                        {
+                            excludeparts.Add(p);
+                        }
+                        else
+                        {
+                            log.Info("dmin=" + p.GetDMIN().ToString("F2"));
+                        }
+                    }
+
+                }
+
+            }
+            if (selconditiondic.ContainsKey("orientation"))
+            {
+                log.Info("Select particles according to orientation");
+                var rng = selconditiondic["orientation"];
+                foreach (var p in GetListAnalysisParticles())
+                {
+                    if (p.GetORIENTATION() < rng.GetStart() || p.GetORIENTATION() >= rng.GetEnd())
+                    {
+                        if (!excludeparts.Contains(p))
+                        {
+                            excludeparts.Add(p);
+                        }
+                        else
+                        {
+                            log.Info("orientation=" + p.GetORIENTATION().ToString("F2"));
+                        }
+
+                    }
+
+
+                }
+
+            }
+            if (selconditiondic.ContainsKey("aspect"))
+            {
+                log.Info("Select particles according to aspect");
+                var rng = selconditiondic["aspect"];
+                foreach (var p in GetListAnalysisParticles())
+                {
+                    double aspect = p.GetDMAX() / p.GetDMIN();
+                    if (aspect < rng.GetStart() || aspect >= rng.GetEnd())
+                    {
+                        if (!excludeparts.Contains(p))
+                        {
+                            excludeparts.Add(p);
+                        }
+                        else
+                        {
+                            log.Info("aspect=" + aspect.ToString("F2"));
+                        }
+
+                    }
+
+
+                }
+
+            }
+            if (selconditiondic.ContainsKey("ferret"))
+            {
+                log.Info("Select particles according to ferret");
+                var rng = selconditiondic["ferret"];
+                foreach (var p in GetListAnalysisParticles())
+                {
+                    double dferet = p.GetFeretDiameter();
+                    if (dferet < rng.GetStart() || dferet >= rng.GetEnd())
+                    {
+                        if (!excludeparts.Contains(p))
+                        {
+                            excludeparts.Add(p);
+                        }
+                        else
+                        {
+                            log.Info("ferret=" + dferet.ToString("F2"));
+                        }
+
+                    }
+
+                }
+
+            }
+
+            foreach (var p in GetListAnalysisParticles())
+            {
+                if (!excludeparts.Contains(p))
+                {
+                    listselparts.Add(p);
+                }
+
+            }
+
+
+            SetListAnalysisParticles(listselparts);
+
+            log.Info("Analysis particles:" + listselparts.Count);
+
 
-            return;
         }
         public void RemoveDuplicateOverlapParticles(int overlap)
         {
@@ -574,7 +753,23 @@ namespace OTSDataType
             }
             return true;
         }
+        public void CalculateParticleAbsolutPos(CSEMStageData pCSEMStageData)
+        {
+            //double dPixelSize = m_Sample.CalculatePixelSize();
+            //CSEMStageData pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
+            foreach (var p in GetListAnalysisParticles())
+            {
 
+                //Point fldOtsPos = new Point((curFldData.OTSPos.X, curFldData.OTSPos.Y);
+                PointF semP = new PointF(); ;
+                Point semPos = new Point();
+                pCSEMStageData.ConvertOTSToSEMCoord(GetOTSPosition(), ref semP);
+                semPos.X = (int)semP.X;
+                semPos.Y = (int)semP.Y;
+                p.SetSEMPos(semPos);
+            }
+
+        }
         public void InitParticles(COTSImageProcParam a_pImageProcessParam)
         {
 

+ 14 - 207
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -835,28 +835,31 @@ namespace OTSModelSharp
             //first step:remove background of the bse image and compound all the finded particles.
 
             log.Info("Begin to process image and get all particles!");
-            GetOriginalParticles(ref curFldData);//according to the ECD scope,filter out the effective particles,remove the noise.
-
+            //according to the ECD scope,filter out the effective particles,remove the noise.
+            curFldData.GetOriginalParticles(m_Sample.GetMsrParams(), m_Sample.CalculatePixelSize());
             log.Info("Begin to filter particles!");
-            FilterParticles(ref curFldData);//filter according to the xraylimit
+             curFldData.FilterParticles(m_Sample.GetMsrParams().GetXRayParam());//filter according to the xraylimit
 
             log.Info("Begin to Calculate the image property of every particle!");
             var analysisparts = curFldData.GetListAnalysisParticles();
             curFldData.CalParticleImageProp(analysisparts);//calculate particle image property such as feret diameter, DMAX etc.
 
-            SelectParticles(ref curFldData);
-            
+           
+           
+
             CSampleParam pMsrParam = m_Sample.GetMsrParams();
             COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
+
+            curFldData.SelectParticlesAccordingImgProp(pImgProcessParam);
             var overlap = pImgProcessParam.GetOverlapParam();
             if (overlap > 0)
             {
                 curFldData.RemoveDuplicateOverlapParticles(overlap);
             }
-           
-            
 
-            CalculateParticleAbsolutPos(ref curFldData);
+
+
+            curFldData.CalculateParticleAbsolutPos(m_pMsrThread.GetProjResultData().GetSEMStageData());
            
             curFldData.InitParticles(pImgProcessParam);
 
@@ -864,189 +867,9 @@ namespace OTSModelSharp
 
         }
 
-        private void FilterParticles(ref COTSField curFldData)
-        {
-            log.Info("filter particle according to xraylimit");
-            var listXray = curFldData.GetAllParticles().OrderByDescending(x => x.GetActualArea()).ToList();
-            var listXray1 = new List<COTSParticleClr>();
-            var pXRayParam =m_Sample.GetMsrParams().GetXRayParam();
-            if (listXray.Count > pXRayParam.GetXrayLimit())
-            {
-                for (var i = 0; i < pXRayParam.GetXrayLimit(); i++)
-                {
-
-                    listXray1.Add(listXray[i]);
-                }
-
-            }
-            else
-            {
-                listXray1 = listXray;
-            }
-
-            curFldData.SetListAnalysisParticles(listXray1);
-
-            log.Info("Analysis particles:" + listXray1.Count);
-
-
-        }
-        private void SelectParticles(ref COTSField curFldData)
-        {
-            var selconditiondic = m_Sample.GetMsrParams().GetImageProcessParam().GetParticleSelConditionDic();
-            var listselparts = new List<COTSParticleClr>();
-            var excludeparts= new List<COTSParticleClr>();
-            if (selconditiondic.ContainsKey("dmax"))
-            {
-                log.Info("Select particles according to dmax");
-                var rng = selconditiondic["dmax"];
-                foreach (var p in curFldData.GetListAnalysisParticles())
-                {
-                    if (p.GetDMAX() < rng.GetStart() || p.GetDMAX() >= rng.GetEnd())
-                    {
-                        excludeparts.Add(p);
-                    }
-                    else 
-                    {
-                        log.Info("dmax=" + p.GetDMAX().ToString("F2"));
-                    }
-                
-                }
-            
-            }
-            if (selconditiondic.ContainsKey("dmin"))
-            {
-                log.Info("Select particles according to dmin");
-                var rng = selconditiondic["dmin"];
-                foreach (var p in curFldData.GetListAnalysisParticles())
-                {
-                    if (p.GetDMIN() < rng.GetStart() || p.GetDMIN() >= rng.GetEnd())
-                    {
-                        if (!excludeparts.Contains(p))
-                        {
-                            excludeparts.Add(p);
-                        }
-                        else
-                        {
-                            log.Info("dmin=" + p.GetDMIN().ToString("F2"));
-                        }
-                    }
-
-                }
-
-            }
-            if (selconditiondic.ContainsKey("orientation"))
-            {
-                log.Info("Select particles according to orientation");
-                var rng = selconditiondic["orientation"];
-                foreach (var p in curFldData.GetListAnalysisParticles())
-                {
-                    if (p.GetORIENTATION() < rng.GetStart() || p.GetORIENTATION() >= rng.GetEnd())
-                    {
-                        if (!excludeparts.Contains(p))
-                        {
-                            excludeparts.Add(p);
-                        }
-                        else
-                        {
-                            log.Info("orientation=" + p.GetORIENTATION().ToString("F2"));
-                        }
-
-                    }
-                   
-
-                }
-
-            }
-            if (selconditiondic.ContainsKey("aspect"))
-            {
-                log.Info("Select particles according to aspect");
-                var rng = selconditiondic["aspect"];
-                foreach (var p in curFldData.GetListAnalysisParticles())
-                {
-                    double aspect = p.GetDMAX() / p.GetDMIN();
-                    if (aspect < rng.GetStart() || aspect >= rng.GetEnd())
-                    {
-                        if (!excludeparts.Contains(p))
-                        {
-                            excludeparts.Add(p);
-                        }
-                        else
-                        {
-                            log.Info("aspect=" + aspect.ToString("F2"));
-                        }
-
-                    }
-
-
-                }
-
-            }
-            if (selconditiondic.ContainsKey("ferret"))
-            {
-                log.Info("Select particles according to ferret");
-                var rng = selconditiondic["ferret"];
-                foreach (var p in curFldData.GetListAnalysisParticles())
-                {
-                    double dferet = p.GetFeretDiameter();
-                    if (dferet < rng.GetStart() || dferet >= rng.GetEnd())
-                    {
-                        if (!excludeparts.Contains(p))
-                        {
-                            excludeparts.Add(p);
-                        }
-                        else
-                        {
-                            log.Info("ferret=" + dferet.ToString("F2"));
-                        }
-
-                    }
-
-                }
-
-            }
-
-            foreach (var p in curFldData.GetListAnalysisParticles())
-            {
-                if (!excludeparts.Contains(p))
-                {
-                    listselparts.Add(p);
-                }
-            
-            }
-
-
-            curFldData.SetListAnalysisParticles(listselparts);
-
-            log.Info("Analysis particles:" + listselparts.Count);
-
-
-        }
-        public void GetOriginalParticles(ref COTSField curFldData)
-        {
         
-            // get image process parameter
-            CSampleParam pMsrParam = m_Sample.GetMsrParams();
-            COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
-            var specialPartsparam = pMsrParam.GetSpecialGrayRangeParam();
-            var pixelsize = m_Sample.CalculatePixelSize();
-            if (specialPartsparam != null && specialPartsparam.GetIsToRun())
-            {
-                List<CSpecialGrayRange> ranges = pMsrParam.GetSpecialGrayRangeParam().GetSpecialGreyRanges();
-                foreach (var grayRange in ranges)
-                {
-                    CIntRangeClr range = new CIntRangeClr(grayRange.range.GetStart(), grayRange.range.GetEnd());
-                    CDoubleRangeClr diaRange = new CDoubleRangeClr(grayRange.diameterRange.GetStart(), grayRange.diameterRange.GetEnd());
-                    curFldData.GetPartsBySpecialGray(range, diaRange, pixelsize, grayRange.ifCollectXray);
-                }
-            }
-            var ifCollectxray = pMsrParam.GetXRayParam().GetUsingXray();
-            // remove BES image background
-            curFldData.RemoveImgBGAndGetParticles(pImgProcessParam, pixelsize, ifCollectxray);
-
-            log.Info("Find all particle num:" +curFldData.GetAllParticles().Count);
-           
-            return;
-        }
+        
+       
        
         public virtual void CollectParticlesXrayData(COTSField curFldData)
         {
@@ -1514,23 +1337,7 @@ namespace OTSModelSharp
 
             }
         }
-        public void CalculateParticleAbsolutPos(ref COTSField curFldData)
-        {
-            double dPixelSize = m_Sample.CalculatePixelSize();
-            CSEMStageData pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
-            foreach (var p in curFldData.GetListAnalysisParticles())
-            {
-
-                //Point fldOtsPos = new Point((curFldData.OTSPos.X, curFldData.OTSPos.Y);
-                PointF semP = new PointF(); ;
-                Point semPos = new Point();
-                pCSEMStageData.ConvertOTSToSEMCoord(curFldData.GetOTSPosition(), ref semP);
-                semPos.X = (int)semP.X;
-                semPos.Y = (int)semP.Y;
-                p.SetSEMPos(semPos);
-            }
-
-        }
+       
 
     }
 }

+ 6 - 20
OTSIncAMeasureApp/ServiceCenter/CImageHandler.cs

@@ -392,22 +392,6 @@ namespace OTSModelSharp.ServiceCenter
 
             }
 
-
-            foreach (var p in parts)
-            {
-
-                foreach (var s in p.GetFeature().GetSegmentsList())
-                {
-
-                    for (int i = s.GetStart(); i < s.GetStart() + s.GetLength(); i++)
-                    {
-                        var bseValue = a_pImgIn.GetBSEValue(i, s.GetHeight());
-                        a_pImgOut.SetBSEValue(i, s.GetHeight(), bseValue);
-                    }
-                }
-
-
-            }
             Graphics graphics = Graphics.FromImage(a_pBmpOut);
 
             // 绘制一个红色矩形
@@ -556,16 +540,18 @@ namespace OTSModelSharp.ServiceCenter
             double right = fldpos.X + currentField.ImgWidth * a_pixelSize / 2;
             double bottom = fldpos.Y - currentField.ImgHeight * a_pixelSize / 2;
             flddataclr.SetOTSRect(left, top, right, bottom);
-            //flddataclr.SetLeftBorderParticlesBiasDefine(currentField.GetLeftBorderParticlesBiasDefine());
-            //flddataclr.SetRightBorderParticlesBiasDefine(currentField.GetRightBorderParticlesBiasDefine());
-            //flddataclr.SetUpBorderParticlesBiasDefine(currentField.GetUpBorderParticlesBiasDefine());
-            //flddataclr.SetDownBorderParticlesBiasDefine(currentField.GetDownBorderParticlesBiasDefine());
+          
             if (!imgProEngine.GetFieldDataFromImage(currentField.GetBSEImage(), prm, a_pixelSize, flddataclr))
             {
                 return false;
             }
             
             parts = flddataclr.GetParticleList();
+            //currentField.FilterParticles(m_Sample.GetMsrParams().GetXRayParam());//filter according to the xraylimit
+            currentField.SetListAnalysisParticles(parts);
+            currentField.CalParticleImageProp(parts);
+            currentField.SelectParticlesAccordingImgProp(a_pImgProcessParam);
+            parts = currentField.GetListAnalysisParticles();
             return true;
 
         }

部分文件因文件數量過多而無法顯示