Browse Source

optimize OTSClassifyEng.cpp sulfideclassification code.

gsp 2 years ago
parent
commit
6961782525

+ 113 - 178
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.cpp

@@ -770,9 +770,8 @@ namespace OTSClassifyEngine
 		}
 		else
 		{
-			// mapped nothing
 
-			// force sulfide base name as "Sulfide" if sulfur 100% molar value over cutting off value
+			// // mapped nothing, force sulfide base name as "Sulfide" if sulfur 100% molar value over cutting off value
 			if (dSulMolar100 > SULFIDE_MOLAR_CUTOFF)
 			{
 				strSulfideBaseName = SULFIDE_STR;
@@ -785,183 +784,36 @@ namespace OTSClassifyEngine
 		}
 
 		// check if the rest element chemistries map an oxide
-		int nIncId = (int)OTS_PARTICLE_TYPE::INVALID;
-		if (!OxideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		int nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
+		if (!GetSulfildeOxideComplexItemId(a_listElChemsIncNoFe, a_dMolarSumNoFe, strSulfideBaseName, nIncId))
 		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::SulClassify: failed to call OxideClassify method."));
+			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 			return FALSE;
 		}
-
-		// mapped?
+			
 		if (nIncId >= (int)OTS_PARTICLE_TYPE::IDENTIFIED)
 		{
-			// this is an oxide sulfide
-
-			// confirm the oxide sulfide id
-
-			// get the STD item of the mapped oxide
-			CSTDItemPtr pOxideSTDItem = pPartSTDData->GetSTDItemById(nIncId);
-			if (pOxideSTDItem)
-			{
-				// get mapped oxide name
-				CString strOxideName = pOxideSTDItem->GetName();
-
-				// oxide sulfide name: oxide + "-" + sulfide base string
-				CString strOxide_SulName = strOxideName + STR_CONNECT + strSulfideBaseName;
-
-				// try to find the STD item
-				CSTDItemPtr pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
-				if (pOxideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pOxideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as "Oxide" + "-" + sulfide base string
-				strOxide_SulName = OXIDE_STR + STR_CONNECT + strSulfideBaseName;
-
-				// try to find the STD item
-				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
-				if (pOxideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pOxideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as strOxideName + "-" + "Sulfide"
-				strOxide_SulName = strOxideName + STR_CONNECT + SULFIDE_STR;
-
-				// try to find the STD item
-				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
-				if (pOxideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pOxideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as "Oxide" + "-" + "Sulfide"
-				strOxide_SulName = OXIDE_STR + STR_CONNECT + SULFIDE_STR;
-
-				// try to find the STD item
-				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
-				if (pOxideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pOxideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as "Sulfide"
-				strOxide_SulName = SULFIDE_STR;
-
-				// try to find the STD item
-				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
-				if (pOxideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pOxideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-			}
-
-			// can't identify this inclusion
-			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
+			a_nIncId = nIncId;
 			return TRUE;
 		}
+		
 		nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-		if (!NitrideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!GetSulfildeNitrideComplexItemId(a_listElChemsIncNoFe, a_dMolarSumNoFe, strSulfideBaseName, nIncId))
 		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call NitrideClassify method."));
 			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 			return FALSE;
 		}
+
 		if (nIncId >= (int)OTS_PARTICLE_TYPE::IDENTIFIED)
 		{
-			CSTDItemPtr pNitrideTDItem = pPartSTDData->GetSTDItemById(nIncId);
-			if (pNitrideTDItem)
-			{// get mapped oxide name
-				CString strNitrideName = pNitrideTDItem->GetName();
-
-				// oxide sulfide name: oxide + "-" + sulfide base string
-				CString strNitride_SulName = strNitrideName + STR_CONNECT + strSulfideBaseName;
-
-				// try to find the STD item
-				CSTDItemPtr pNitrideSulSTDItem = GetSTDItemByName(listSulfideSTD, strNitride_SulName);
-				if (pNitrideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pNitrideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as "Oxide" + "-" + sulfide base string
-				strNitride_SulName = NITRIDE_STR + STR_CONNECT + strSulfideBaseName;
-
-				// try to find the STD item
-				pNitrideSulSTDItem = GetSTDItemByName(listSulfideSTD, strNitride_SulName);
-				if (pNitrideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pNitrideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as strOxideName + "-" + "Sulfide"
-				strNitride_SulName = strNitrideName + STR_CONNECT + SULFIDE_STR;
-
-				// try to find the STD item
-				pNitrideSulSTDItem = GetSTDItemByName(listSulfideSTD, strNitride_SulName);
-				if (pNitrideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pNitrideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as "Oxide" + "-" + "Sulfide"
-				strNitride_SulName = NITRIDE_STR + STR_CONNECT + SULFIDE_STR;
-
-				// try to find the STD item
-				pNitrideSulSTDItem = GetSTDItemByName(listSulfideSTD, strNitride_SulName);
-				if (pNitrideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pNitrideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-				// rename the oxide sulfide name as "Sulfide"
-				strNitride_SulName = SULFIDE_STR;
-
-				// try to find the STD item
-				pNitrideSulSTDItem = GetSTDItemByName(listSulfideSTD, strNitride_SulName);
-				if (pNitrideSulSTDItem)
-				{
-					// found the STD item
-					a_nIncId = pNitrideSulSTDItem->GetSTDId();
-					return TRUE;
-				}
-
-			}
-
-
+			a_nIncId = nIncId;
+			return TRUE;
 		}
-		
-
-		// this is a general sulfide
 
-		// confirm the sulfide id
-
-		// try to find the STD item
+		// try to find the STD item	// this is a general sulfide// confirm the sulfide id
 		CSTDItemPtr pSulSTDItem = GetSTDItemByName(listSulfideSTD, strSulfideBaseName);
 		if (pSulSTDItem)
 		{
-			// found the STD item
 			a_nIncId = pSulSTDItem->GetSTDId();
 			return TRUE;
 		}
@@ -1803,14 +1655,13 @@ namespace OTSClassifyEngine
 		return TRUE;
 	}
 
-	BOOL COTSClassifyEng::GetNitrideItemString(CElementChemistriesList& listChemistriesToAnalysis, double a_dMolarSumNoFe, CString strSulfideBaseName, CString& a_STDItemStr)
+	BOOL COTSClassifyEng::GetSulfildeOxideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe, double a_dMolarSumNoFe, CString strSulfideBaseName, int& a_nIncId)
 	{
 		int nIncId;
-		if (!NitrideClassify(listChemistriesToAnalysis, a_dMolarSumNoFe, nIncId))
+		if (!OxideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call NitrideClassify method."));
-			nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
+
+			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 			return FALSE;
 		}
 
@@ -1822,11 +1673,95 @@ namespace OTSClassifyEngine
 			// confirm the oxide sulfide id
 
 			// get the STD item of the mapped oxide
-			CSTDItemPtr pNitrideSTDItem = pPartSTDData->GetSTDItemById(nIncId);
-			if (pNitrideSTDItem)
+			CSTDItemPtr pOxideSTDItem = pPartSTDData->GetSTDItemById(nIncId);
+			if (pOxideSTDItem)
 			{
 				// get mapped oxide name
-				CString strNitrideName = pNitrideSTDItem->GetName();
+				CString strOxideName = pOxideSTDItem->GetName();
+
+				// oxide sulfide name: oxide + "-" + sulfide base string
+				CString strOxide_SulName = strOxideName + STR_CONNECT + strSulfideBaseName;
+
+				// try to find the STD item
+				CSTDItemPtr pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
+				if (pOxideSulSTDItem)
+				{
+					// found the STD item
+					a_nIncId = pOxideSulSTDItem->GetSTDId();
+					return TRUE;
+				}
+
+				// rename the oxide sulfide name as "Oxide" + "-" + sulfide base string
+				strOxide_SulName = OXIDE_STR + STR_CONNECT + strSulfideBaseName;
+
+				// try to find the STD item
+				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
+				if (pOxideSulSTDItem)
+				{
+					// found the STD item
+					a_nIncId = pOxideSulSTDItem->GetSTDId();
+					return TRUE;
+				}
+
+				// rename the oxide sulfide name as strOxideName + "-" + "Sulfide"
+				strOxide_SulName = strOxideName + STR_CONNECT + SULFIDE_STR;
+
+				// try to find the STD item
+				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
+				if (pOxideSulSTDItem)
+				{
+					// found the STD item
+					a_nIncId = pOxideSulSTDItem->GetSTDId();
+					return TRUE;
+				}
+
+				// rename the oxide sulfide name as "Oxide" + "-" + "Sulfide"
+				strOxide_SulName = OXIDE_STR + STR_CONNECT + SULFIDE_STR;
+
+				// try to find the STD item
+				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
+				if (pOxideSulSTDItem)
+				{
+					// found the STD item
+					a_nIncId = pOxideSulSTDItem->GetSTDId();
+					return TRUE;
+				}
+
+				// rename the oxide sulfide name as "Sulfide"
+				strOxide_SulName = SULFIDE_STR;
+
+				// try to find the STD item
+				pOxideSulSTDItem = GetSTDItemByName(listSulfideSTD, strOxide_SulName);
+				if (pOxideSulSTDItem)
+				{
+					// found the STD item
+					a_nIncId = pOxideSulSTDItem->GetSTDId();
+					return TRUE;
+				}
+			}
+
+			// can't identify this inclusion
+			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
+			return TRUE;
+		}
+		a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
+		return TRUE;
+	}
+
+	BOOL COTSClassifyEng::GetSulfildeNitrideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe, double a_dMolarSumNoFe, CString strSulfideBaseName, int& a_nIncId)
+	{
+		int nIncId;
+		if (!NitrideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		{			
+			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
+			return FALSE;
+		}
+		if (nIncId >= (int)OTS_PARTICLE_TYPE::IDENTIFIED)
+		{
+			CSTDItemPtr pNitrideTDItem = pPartSTDData->GetSTDItemById(nIncId);
+			if (pNitrideTDItem)
+			{// get mapped oxide name
+				CString strNitrideName = pNitrideTDItem->GetName();
 
 				// oxide sulfide name: oxide + "-" + sulfide base string
 				CString strNitride_SulName = strNitrideName + STR_CONNECT + strSulfideBaseName;
@@ -1836,7 +1771,7 @@ namespace OTSClassifyEngine
 				if (pNitrideSulSTDItem)
 				{
 					// found the STD item
-					nIncId = pNitrideSulSTDItem->GetSTDId();
+					a_nIncId = pNitrideSulSTDItem->GetSTDId();
 					return TRUE;
 				}
 
@@ -1848,7 +1783,7 @@ namespace OTSClassifyEngine
 				if (pNitrideSulSTDItem)
 				{
 					// found the STD item
-					nIncId = pNitrideSulSTDItem->GetSTDId();
+					a_nIncId = pNitrideSulSTDItem->GetSTDId();
 					return TRUE;
 				}
 
@@ -1860,19 +1795,19 @@ namespace OTSClassifyEngine
 				if (pNitrideSulSTDItem)
 				{
 					// found the STD item
-					nIncId = pNitrideSulSTDItem->GetSTDId();
+					a_nIncId = pNitrideSulSTDItem->GetSTDId();
 					return TRUE;
 				}
 
 				// rename the oxide sulfide name as "Oxide" + "-" + "Sulfide"
-				strNitride_SulName = OXIDE_STR + STR_CONNECT + SULFIDE_STR;
+				strNitride_SulName = NITRIDE_STR + STR_CONNECT + SULFIDE_STR;
 
 				// try to find the STD item
 				pNitrideSulSTDItem = GetSTDItemByName(listSulfideSTD, strNitride_SulName);
 				if (pNitrideSulSTDItem)
 				{
 					// found the STD item
-					nIncId = pNitrideSulSTDItem->GetSTDId();
+					a_nIncId = pNitrideSulSTDItem->GetSTDId();
 					return TRUE;
 				}
 
@@ -1884,15 +1819,16 @@ namespace OTSClassifyEngine
 				if (pNitrideSulSTDItem)
 				{
 					// found the STD item
-					nIncId = pNitrideSulSTDItem->GetSTDId();
+					a_nIncId = pNitrideSulSTDItem->GetSTDId();
 					return TRUE;
 				}
+
 			}
 
-			// can't identify this inclusion
-			nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-			return TRUE;
+
 		}
+		return true;
+		
 	}
 
 	void COTSClassifyEng::FilterOnSteelTech(STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElChemsIncNoFe)
@@ -1973,7 +1909,6 @@ namespace OTSClassifyEngine
 		BOOL bMapped = FALSE;
 		{
 			CElementChemistryPtr psubChem = GetNamedElementChemistry(a_listElChemsInc, subEleName);
-			double dMappingRatio = INC_SULFILSES_MAPPING_RATIO[0];
 			if (psubChem)
 			{
 				if (!ElementsMapping(a_dMolarSum, mappingRatio, psubChem, KeyEleChemistry, bMapped))

+ 5 - 2
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.h

@@ -127,9 +127,12 @@ namespace OTSClassifyEngine
 		//CSTDItemsList listUserSTD;
 		// get classify STD items
 		BOOL GetClassifySTDItem(CInclutionSTDDataPtr a_pPartSTDDataPtr, INC_CLASSIFY_TYPE a_nClassifyType, CSTDItemsList& a_listSTDItems);
-		BOOL GetNitrideItemString(CElementChemistriesList& a_listElChemsIncNoFe,
+		BOOL GetSulfildeOxideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe,
 			double a_dMolarSumNoFe, CString strSulfideBaseName,
-			CString& a_STDItemStr);
+			int& nIncId);
+		BOOL GetSulfildeNitrideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe,
+			double a_dMolarSumNoFe, CString strSulfideBaseName,
+			int& nIncId);
 		void FilterOnSteelTech(STEEL_TECHNOLOGY steelTech,
 			CElementChemistriesList& a_listElChemsInc);
 		BOOL ElementMatching(double a_dMolarSumNoFe, CElementChemistriesList a_listElChemsInc, CElementChemistryPtr KeyEleChemistry, CString subEleName, double mappingRatio, double& dKeyEleResidualMolar100);

+ 2 - 2
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -219,8 +219,8 @@ namespace OTSMeasureApp
                 PrepareIpcServer();
                 log.Info("Ipc server start success!");
                 //----------------------Test Code, Don't delete
-                var f = new BaseFunctionTest();
-                f.ShowDialog();
+                //var f = new BaseFunctionTest();
+                //f.ShowDialog();
                 //----------------------
             }
             catch (Exception ex)