//using OTSDataType; using OTSModelSharp.ServiceCenter; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OTSModelSharp.ServiceCenter { using OTSCLRINTERFACE; public class CClassifyEngine : IClassifyEngine { COTSClassifyEngineClr myEng; bool ifWeightPercentageToAtomicPercentage; public bool ClassifyIncA(COTSParticleClr particle, int steelTech) { bool r = myEng.ClassifyIncA(particle,steelTech);//the classify engine will return true; } public IClassifyEngine GetSpectrumCompareEngine(string libName) { if (!libName.Contains(".db")) { libName = libName + ".db"; } myEng = new COTSClassifyEngineClr(EngineType.SpectrumCompare, libName); return this; } public IClassifyEngine GetIncClassifyEngine() { myEng = new COTSClassifyEngineClr(EngineType.InclutionEng, ""); return this; } public IClassifyEngine GetExpressionClassifyEngine(string libName) { if (!libName.Contains(".db")) { libName = libName + ".db"; } myEng = new COTSClassifyEngineClr(EngineType.ExpressionClassifyEng, libName); ifWeightPercentageToAtomicPercentage = FileHelper.GetIfTranslateWeightPercentageToAtomicPercentage(); return this; } public bool IfNeedMaxEDS(COTSParticleClr particle,ref double maxeds) { return myEng.IfNeedMaxEDS(particle,ref maxeds); } public bool ClassifyBySpectrum(COTSParticleClr particle) { return myEng.ClassifyBySpectrum(particle); } public bool ClassifyByExpressionTemporarySpectrum(COTSParticleClr particle) { return myEng.ClassifyByExpressionTemporarySpectrum(particle); } public bool ClassifyByExpression(COTSParticleClr particle) { if (ifWeightPercentageToAtomicPercentage==true) { double sumMolar=0; foreach (var ele in particle.GetXray().GetElementQuantifyData()) { sumMolar += ele.GetMolarPercentage(); } foreach (var ele in particle.GetXray().GetElementQuantifyData()) { ele.SetPercentage(ele.GetMolarPercentage() / sumMolar); } } return myEng.ClassifyByExpression(particle); } } }