123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- #pragma once
- #include "stdafx.h"
- #include "GBParticle.h"
- namespace OTSGBCalculate
- {
- using namespace std;
- using namespace OTSDATA;
-
- GB_CHEMICAL_TYPE GBParticle::IdentifyPartChemicalType(COTSParticlePtr Particle)
- {
- 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;
- }
- }
- int GBParticle::GetFieldId()
- {
- COTSParticlePtr Particle = myOTSParts[0];
- for (auto p : myOTSParts)//get the longest particle
- {
- if (p->GetDMax() > Particle->GetDMax())
- {
- Particle = p;
- }
- }
- return Particle->GetFieldId();
- }
- CString GBParticle::GetParticleId()
- {
- COTSParticlePtr Particle = myOTSParts[0];
- CString partsid="";
- for (auto p : myOTSParts)
- {
-
- CString partid;
- partid.Format(_T("%d:%d "), p->GetFieldId(), p->GetParticleId());
- partsid += partid;
-
- }
- partsid.TrimRight();
- return partsid;
- }
- 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()
- {
- auto compare = [](const COTSParticlePtr& a, const COTSParticlePtr& b)
- {
- return a->GetOTSRect().GetTopLeft().y> b->GetOTSRect().GetTopLeft().y;
- };
- std::sort(myOTSParts.begin(), myOTSParts.end(), compare);
- double dmax=0;
- auto p = myOTSParts.begin();
- while (p != myOTSParts.end())
- {
- dmax += (*p)->GetDMax();
- auto cur = p;
- auto next = ++p;
- if (next!= myOTSParts.end())
- {
- auto distance= (*cur)->GetOTSRect().GetBottomRight().y - (*next)->GetOTSRect().GetTopLeft().y;
- if (distance > 0)
- {
- dmax += distance;
- }
-
- }
- }
-
- return dmax;
- }
- double GBParticle::GetFeretDiameter()
- {
- double dferet=0;
- for (auto p : myOTSParts)
- {
- dferet += p->GetFeretDiameter();
- }
- return dferet;
- }
- double GBParticle::GetActualArea()
- {
- double area = 0;
- for (auto p : myOTSParts)
- {
- area += p->GetActualArea();
- }
- return area;
- }
- }
|