| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 | #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());					}	}	return TRUE;}bool CurveCompareEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray){	// similarity	double dSim = 0;	// classify Particles	const std::vector<CString> vecIgnoreElementNames;	auto stditm = CClassifyOnCurveCompEng::GetCompareSTD(0, vecIgnoreElementNames, xray,myLib, dSim);	//if (dSim > 0.05)		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");	}	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;}}
 |