123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #include "stdafx.h"
- #include "CurveCompareEngine.h"
- #include "OTSSTDLibFileMgr.h"
- #include "OTSClassifyOnCurveCompEng.h"
- #include "ParticleEngine/ParticleSTD.h"
- namespace OTSClassifyEngine
- {
- bool CurveCompareEngine::Init()
- {
-
-
- CSTDLibFileMgrPtr pLibFileMgr = CSTDLibFileMgrPtr(new CSTDLibFileMgr(m_StrName));
- if (!pLibFileMgr->Load(myLib))
- {
- return FALSE;
- }
- ParticleSTDPtr m_std = ParticleSTDPtr(new ParticleSTD());
- if (!pLibFileMgr->LoadPartSTD(m_std))
- {
- return FALSE;
- }
- for (int i = 0; i < myLib->GetSTDItemCount(); i++)
- {
- auto itm = myLib->GetSTDItem(i);
- auto expstditm = m_std->GetSTDItemById(itm->GetID());
- if (expstditm != nullptr)
- {
- itm->SetName(expstditm->GetName().c_str());
- DWORD r, g, b;
- sscanf(expstditm->GetColor().c_str(), "#%2X%2X%2X", &r, &g, &b);
- COLORREF rgb = RGB(r, g, b);
- itm->SetColor(rgb);
- //itm->SetElementsList(expstditm->GetKeyElementList());
- itm->SetBSEValue(expstditm->GetBSE());
-
- itm->SetDensity(expstditm->GetDensity());
-
- itm->SetFormula(expstditm->GetFormula().c_str());
-
- }
- }
- m_Engine = new CClassifyOnCurveCompEng(0,myLib);
- return TRUE;
- }
- bool CurveCompareEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray)
- {
- // similarity
- double dSim = 0;
- // classify Particles
-
- auto stditm = m_Engine->GetMatchingSTD( xray, dSim);
- if (dSim > 0.8)
- {
- if (stditm != nullptr)
- {
- particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
- particle->SetClassifyId(stditm->GetID());
- particle->TypeName(stditm->GetName().GetBuffer());
- particle->TypeColor(std::to_string(stditm->GetColor()));
- }
- else
- {
- particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
- particle->TypeName("Not Identified");
- }
- }
- else
- {
- particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
- particle->TypeName("Not Identified");
- }
-
-
- return true;
- }
- bool CurveCompareEngine::Classify(COTSParticlePtr particle, int SteelTech, CPosXrayPtr xray)
- {
- throw std::logic_error("The method or operation is not implemented.");
- }
- bool CurveCompareEngine::IfNeedMaxEDS(COTSParticlePtr particle, CPosXrayPtr xray, double& MaxEDSTime)
- {
- throw std::logic_error("The method or operation is not implemented.");
- }
- OTSClassifyEngine::CLEEnginePtr GetCurveCompareEngine(std::string libName)
- {
- static CLEEnginePtr engine;
- if (engine == NULL)
- {
- engine = CLEEnginePtr(new CurveCompareEngine(libName));
- engine->Init();
- }
- return engine;
- }
- }
|