Ver Fonte

optimize the OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.cpp code.

gsp há 2 anos atrás
pai
commit
b4e115cc22

+ 24 - 176
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.cpp

@@ -21,6 +21,7 @@ namespace OTSClassifyEngine
 	const CString STR_N = _T("N");
 	const CString STR_CR = _T("Cr");
 	const double SIC_MOLAR_CUTOFF = 85.0;
+	const double NBC_MOLAR_CUTOFF = 30.0;
 	const double FEO_MOLAR_CUTOFF = 85.0;
 
 	// key element
@@ -29,7 +30,7 @@ namespace OTSClassifyEngine
 	const double INC_KEY_ELEMENT_TOTAL_100 = 5.0;	// total molar value
 	const CString INC_KEY_ELEMENT_NAMES[INC_KEY_ELEMENT_MAX] =
 	{
-		_T("S"),_T("N"),_T("O"),_T("C")
+		_T("S"),_T("N"),_T("O")
 	};
 
 	// sub element
@@ -191,13 +192,7 @@ namespace OTSClassifyEngine
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::NitrideClassify: failed to call GetClassifySTDItem method."));
 		}
-		// get all nitride STD items
-		
-		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::CARBON, listCarbonSTD))
-		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("CClassifyEng::NitrideClassify: failed to call GetClassifySTDItem method."));
-		}
+
 		
 
 
@@ -289,6 +284,7 @@ namespace OTSClassifyEngine
 		double dSumKeyElements = 0;
 		double dSumSubElements = 0;
 		double dCarbonMolar = 0;
+		double dNbMolar = 0;
 		double dOMolar = 0;
 		double dSiMolar = 0;
 		double dFeMolar = 0;
@@ -320,10 +316,7 @@ namespace OTSClassifyEngine
 				{
 					dOMolar = pElChem->GetMolarPercentage();
 				}
-				else if (pElChem->GetName().CompareNoCase(STR_C) == 0)
-				{
-					dCarbonMolar = pElChem->GetMolarPercentage();
-				}
+				
 			}
 			// sub element?, include Fe
 			else if (IsSubElement(pElChem))
@@ -350,6 +343,10 @@ namespace OTSClassifyEngine
 				{
 					dSiMolar = pElChem->GetMolarPercentage();
 				}
+				else if (pElChem->GetName().CompareNoCase(STR_Nb) == 0)
+				{
+					dNbMolar = pElChem->GetMolarPercentage();
+				}
 					
 				
 			}
@@ -357,7 +354,10 @@ namespace OTSClassifyEngine
 			{
 				dFeMolar = pElChem->GetMolarPercentage();
 			}
-			
+			else if (pElChem->GetName().CompareNoCase(STR_C) == 0)
+			{
+				dCarbonMolar = pElChem->GetMolarPercentage();
+			}
 			
 			
 		}
@@ -369,13 +369,21 @@ namespace OTSClassifyEngine
 		{
 			// calculate molar % of C + Si
 			double dMolarC_Si = Cal100NorValue(dCarbonMolar + dSiMolar, a_dMolarSumNoFe + dCarbonMolar);
-			if (dMolarC_Si > SIC_MOLAR_CUTOFF)
+			if (dMolarC_Si > SIC_MOLAR_CUTOFF && dSiMolar> INC_SUB_ELEMENT_CUT_OFF)
 			{
 				// this is a SiC, not a inclusion, return FALSE
 				a_nIncId =OTS_PARTCLE_TYPE::ISNOT_INCLUTION;
 				notIncId = NOT_INCLUTION_ID::SiC;
 				return TRUE;
 			}
+			double dMolarC_Nb = Cal100NorValue(dCarbonMolar + dNbMolar, a_dMolarSumNoFe + dCarbonMolar);
+			if (dMolarC_Nb > NBC_MOLAR_CUTOFF && dNbMolar > INC_SUB_ELEMENT_CUT_OFF)
+			{
+				// this is a SiC, not a inclusion, return FALSE
+				a_nIncId = OTS_PARTCLE_TYPE::ISNOT_INCLUTION;
+				notIncId = NOT_INCLUTION_ID::NbC;
+				return TRUE;
+			}
 		}
 		//=========================================
 
@@ -480,22 +488,7 @@ namespace OTSClassifyEngine
 			return TRUE;
 		}
 
-		// CarbonClassify classification
-		if (!CarbonClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
-		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call CarbonClassify method."));
-			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-			return FALSE;
-		}
 
-		// inclusion identified?
-		if (nIncId != (int)OTS_PARTICLE_TYPE::INVALID)
-		{
-			// yes, this is a oxide
-			a_nIncId = nIncId;
-			return TRUE;
-		}
 		// can't identify this inclusion
 		a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 		return TRUE;
@@ -1269,152 +1262,7 @@ namespace OTSClassifyEngine
 		return TRUE;
 	}
 
-	// nitrides classification
-	BOOL COTSClassifyEng::CarbonClassify(
-		CElementChemistriesList& a_listElChemsIncNoFe,
-		double a_dMolarSumNoFe,
-		int& a_nIncId)
-	{
-		
-
-		// check if element chemistries list contain any nitrogen
-		CElementChemistryPtr pCarElChem = GetNamedElementChemistry(a_listElChemsIncNoFe, STR_CAR);
-		if (!pCarElChem)
-		{
-			// contains no nitrogen, this is not a nitride
-			return TRUE;
-		}
-
-		// check if nitrogen amount enough
-		double dCarMolar100 = Cal100NorValue(pCarElChem->GetMolarPercentage(), a_dMolarSumNoFe);
-		if (dCarMolar100 < MIN_CAR_MOLAR)
-		{
-			// have no enough nitrogen, this is not a nitride
-			return TRUE;
-		}
-
-		// this is a carbon
-
-		// any carbon STD items
-		if (listCarbonSTD.empty())
-		{
-			// no nitrides std items. 
-
-			// can't identify this inclusion
-			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-			return TRUE;
-		}
-
-		// mapping carbon sub elements
-		CString strCarbonName = _T("");
-		BOOL bMapped = FALSE;
-		for (int i = 0; i < INC_CAR_SUB_ELEMENT_MAX; ++i)
-		{
-			CElementChemistryPtr pCarSubElChem = GetNamedElementChemistry(a_listElChemsIncNoFe, INC_CAR_SUB_ELEMENT_NAMES[i]);
-			if (pCarSubElChem)
-			{
-				// this is a nitride sub element chemistry
-
-				// get %molar value of this sub element chemistry
-				double dCar_Sub_Molar = Cal100NorValue(pCarSubElChem->GetMolarPercentage(), a_dMolarSumNoFe);
-
-				// make sure the sub element molar value is over mapping min value
-				if (dCar_Sub_Molar > MIN_CAR_SUB_MOLAR)
-				{
-
-					// try to map Nb
-					BOOL bNbMapped = FALSE;
-
-					// get molar % of the rest nitrogen 
-					dCarMolar100 = Cal100NorValue(pCarElChem->GetMolarPercentage(), a_dMolarSumNoFe);
-
-					// make sure nitrogen amount is enough
-					if (dCarMolar100 > MIN_CAR_MOLAR)
-					{
-						// get element "Nb" 
-						CElementChemistryPtr pElChemNb = GetNamedElementChemistry(a_listElChemsIncNoFe, STR_Nb);
-
-						// is there Nb in the list
-						if (pElChemNb)
-						{
-							// get %molar value of Nb
-							double dNb_Molar = Cal100NorValue(pElChemNb->GetMolarPercentage(), a_dMolarSumNoFe);
-
-							// make sure Nb molar value is over mapping min value
-							double dNbMappingRatio = INC_NITR_MAPPING_RATIO[2];
-							if (dNb_Molar > MIN_CAR_SUB_MOLAR)
-							{
-								if (!ElementsMapping(a_dMolarSumNoFe, dNbMappingRatio, pElChemNb, pCarElChem, bNbMapped))
-								{
-									// something is wrong
-									LogErrorTrace(__FILE__, __LINE__, _T("CClassifyEng::NitrideClassify: failed to call ElementsMapping method."));
-									return FALSE;
-								}
-							}
-						}
-					}
-					// mapped "Nb"
-					if (bNbMapped)
-					{
-						// carbon name is "NbC"
-						strCarbonName = INC_CAR_NAMES[0];
-					}
-					// completed mapping, get out the loop
-					break;
-				}
-			}
-		}
-
-		// mapped?
-		if (a_nIncId >= (int)OTS_PARTICLE_TYPE::IDENTIFIED)
-		{
-			// this is an oxide nitride
-
-			// confirm the oxide nitride id
-			CSTDItemPtr pCarSTDItem = GetSTDItemByName(listCarbonSTD, strCarbonName);
-			// get the STD item of the mapped oxide
-			if (pCarSTDItem)
-			{
-				// found the STD item
-				a_nIncId = pCarSTDItem->GetSTDId();
-				return TRUE;
-			}
-
-			// can't identify this inclusion
-			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-			return TRUE;
-		}
-
-		// confirm the carben id
-
-		// try to find the STD 
-		auto pSTDItem = GetSTDItemByName(listCarbonSTD, strCarbonName);
-		if (pSTDItem)
-		{
-			// found the STD item
-			a_nIncId = pSTDItem->GetSTDId();
-			return TRUE;
-		}
-
-		// rename the Carbon as "Carbon" if it is not
-		if (strCarbonName.CompareNoCase(CARBON_STR) != 0)
-		{
-			strCarbonName = NITRIDE_STR;
-			auto pSTDItem = GetSTDItemByName(listCarbonSTD, strCarbonName);
-			if (pSTDItem)
-			{
-				// found the STD item
-				a_nIncId = pSTDItem->GetSTDId();
-				return TRUE;
-			}
-		}
-
-		// can't identify this inclusion
-		a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-		return TRUE;
-	}
-
-
+	
 
 	// nominate element chemistries list 
 	BOOL COTSClassifyEng::NomiNateElChemsList( CElementChemistriesList& a_listElChemsInc, 
@@ -1423,7 +1271,7 @@ namespace OTSClassifyEngine
 		// return FALSE if nothing in the input list
 		if (a_listElChemsInc.empty())
 		{
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::NomiNateElChemsList: invalid inclusion x-ray data."));
+			//LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::NomiNateElChemsList: invalid inclusion x-ray data."));
 			return FALSE;
 		}
 

+ 6 - 10
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.h

@@ -63,15 +63,8 @@ namespace OTSClassifyEngine
 									 double a_dMolarSumNoFe,
 									 int& a_nIncId);
 
-		// carbon classification
-		 BOOL CarbonClassify(
-			CElementChemistriesList& a_listElChemsIncNoFe,
-			double a_dMolarSumNoFe,
-			int& a_nIncId);
-
-		// nominate element chemistries list 
-		 BOOL NomiNateElChemsList( CElementChemistriesList& a_listElChemsInc, 
-										 CElementChemistriesList& a_listNomiElChemsInc);
+		
+	
 	
 	protected:
 		
@@ -124,7 +117,10 @@ namespace OTSClassifyEngine
 		CSTDItemsList listOxideSTD;
 		CSTDItemsList listNitrideSTD;
 		CSTDItemsList listCarbonSTD;
-		//CSTDItemsList listUserSTD;
+	
+		//  nominate element chemistries list 
+		BOOL NomiNateElChemsList(CElementChemistriesList& a_listElChemsInc,
+			CElementChemistriesList& a_listNomiElChemsInc);
 		// get classify STD items
 		BOOL GetClassifySTDItem(CInclutionSTDDataPtr a_pPartSTDDataPtr, INC_CLASSIFY_TYPE a_nClassifyType, CSTDItemsList& a_listSTDItems);
 		BOOL GetSulfildeOxideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe,

+ 3 - 14
OTSCPP/OTSData/otsdataconst.h

@@ -325,19 +325,7 @@ namespace OTSDATA
 	const int RESOLUTION_ID_MAX = 6;
 	const int RESOLUTION_ID_DEFAULT = 4;
 	const int RESOLUTION_ID_FIRST_TIE = 2;
-	/*_512_384 = 0,
-		_1024_684 = 1,
-		_1024_704 = 2,
-		_1024_768 = 3,
-		_1536_1024 = 4,
-		_2048_1408 = 5,
-		_2048_1536 = 6,
-		_3072_2048 = 7,
-		_4096_3072 = 8,*/
-	/*const CSize RESOLUTION_VALUE[RESOLUTION_ID_MAX + 1] = { CSize(512, 384), CSize(1024, 684), CSize(1024, 704), CSize(1024, 768),
-		CSize(1536,1024), CSize(2048, 1408), CSize(2048, 1536) };
-	const CString RESOLUTION_STRINGS[RESOLUTION_ID_MAX + 1] = { _T("64 X 48"), _T("128 X 96"), _T("256 X 192"), _T("512 X 384"),
-		_T("1024 X 768"), _T("2048 X 1536"), _T("4096 X 3072") };*/
+
 
 	// image parameter
 	const int STOP_PARAM_PARTICLE_MIN = 0;
@@ -422,7 +410,8 @@ namespace OTSDATA
 		Min=0,
 		SiC = 20001,
 		FeO = 20002,
-		Max=20002
+		NbC=20003,
+		Max=20003
 	}NOT_INCLUTION_ID;
 
 	typedef enum class __declspec(dllexport) IDENTIFIED_INC_GRP_ID//ʶ±ð¼ÐÔÓÎï·Ö×é