ExpressionClassifyEngine.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "ExpressionClassifyEngine.h"
  4. #include "ExpressionParseEngine/LogicExp.h"
  5. #include "XMLSerialization.h"
  6. #include <map>
  7. #include <Element.h>
  8. #include "ExpressionParseEngine/OTSSTDLibFileMgr.h"
  9. #include "COTSUtilityDllFunExport.h"
  10. namespace OTSClassifyEngine
  11. {
  12. using namespace expInterpreter;
  13. bool ExpressionClassifyEngine::Init()
  14. {
  15. CSTDLibFileMgrPtr pLibFileMgr = CSTDLibFileMgrPtr(new CSTDLibFileMgr(m_StrName));
  16. m_std = ParticleSTDPtr(new ParticleSTD());
  17. if (!pLibFileMgr->LoadPartSTD(m_std))
  18. {
  19. return FALSE;
  20. }
  21. pLibFileMgr->LoadMaxEDSRulesData(m_std);
  22. if (!pLibFileMgr->LoadZeroElementRulesData(m_std))
  23. {
  24. //return false;
  25. }
  26. string constantStr = pLibFileMgr->LoadConstantsData();
  27. std::map<std::string, double> m_mapConstants;
  28. m_mapConstants.clear();
  29. std::vector<std::string> strs;
  30. xmls::SplitString(constantStr, strs, ",");
  31. for (std::string s : strs)
  32. {
  33. std::vector<std::string> oneExp;
  34. xmls::SplitString(s, oneExp, "=");
  35. m_mapConstants[oneExp[0]] = std::atof(oneExp[1].c_str());
  36. }
  37. m_std->setConstantsMap(m_mapConstants);
  38. return true;
  39. }
  40. bool ExpressionClassifyEngine::ClassifyExpression(COTSParticlePtr particle, CPosXrayPtr xray)
  41. {
  42. if (particle != nullptr && xray != nullptr)//process the particle with the xray data
  43. {
  44. auto& originalPartEles = xray->GetElementQuantifyData();//find all the elements containing in the particle xray.
  45. //zero element process,if satisfied the condition than set the particular element percentage to 0.and make it 100% of all the other element percentage.
  46. auto partEles = ZeroElementProcess(particle, xray);//
  47. std::map<std::string, CElementChemistryPtr> mapChemistrys;
  48. for (auto ch : partEles)
  49. {
  50. mapChemistrys[ch->GetName().GetBuffer()] = ch;
  51. }
  52. PartSTDRuleItemList ruleItems = m_std->GetSTDRuleItems();
  53. std::vector<PartSTDRuleItemPtr> matchedItems;
  54. for (auto itm : ruleItems)
  55. {
  56. //if the element quantity is not match the std item's keyelement num than they are unmatching.
  57. if (partEles.size() < itm->GetKeyElementList().size())
  58. {
  59. continue;
  60. }
  61. auto& mapStdEles = itm->GetMapElements();
  62. bool bMatch = true;
  63. // if the particle does not contain all the key elements of the item than they are unmatching.
  64. for (auto che : mapStdEles)
  65. {
  66. auto chemical = mapChemistrys.find(che.second->GetName().GetBuffer());
  67. if (chemical == mapChemistrys.end())
  68. {
  69. bMatch = false;
  70. break;
  71. }
  72. }
  73. if (!bMatch) continue;
  74. std::string exp = itm->GetExpressionStr();
  75. ProcessAllPropertiesWithParticleData(exp, mapChemistrys, itm, particle);
  76. //calculate the expression which has been processed.
  77. bool rst = CalcuExp(exp);
  78. if (rst)
  79. {
  80. matchedItems.push_back(itm);
  81. }
  82. else
  83. {
  84. continue;
  85. }
  86. }
  87. if (matchedItems.size() > 0)
  88. {
  89. auto matchedItem = matchedItems[0];
  90. for (auto itm : matchedItems)
  91. {
  92. if (itm->GetExpressionStr().size() > matchedItem->GetExpressionStr().size())
  93. {
  94. matchedItem = itm;
  95. }
  96. }
  97. particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
  98. particle->SetClassifyId(matchedItem->GetID());
  99. particle->SetColor(matchedItem->GetColor());
  100. particle->SetClassifyName(matchedItem->GetName());
  101. particle->SetHardness(matchedItem->GetHardness());
  102. particle->SetDensity(matchedItem->GetDensity());
  103. particle->SetConductivity(matchedItem->GetElectrical_conductivity());
  104. particle->SetGroupId(matchedItem->GetGrpID());
  105. particle->SetGroupColor(matchedItem->GetGrpColor());
  106. particle->SetGroupName(matchedItem->GetGrpName());
  107. if (matchedItem->GetIsElementAnalysis() == false)
  108. {
  109. matchedItem->AddXraySpectrum(particle->GetXrayInfo());
  110. }
  111. }
  112. else
  113. {
  114. particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
  115. particle->SetClassifyName("Not Identified");
  116. particle->SetColor("#000000");
  117. particle->SetGroupId((int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
  118. particle->SetGroupName("Not Identified");
  119. particle->SetGroupColor("#000000");
  120. }
  121. return true;
  122. }
  123. else if(particle != nullptr && xray == nullptr)//process particle without xray data
  124. {
  125. PartSTDRuleItemList stdItems = m_std->GetSTDRuleItems();
  126. for (auto itm : stdItems)
  127. {
  128. std::string exp = itm->GetExpressionStr();
  129. //if the rule demand any element infomation then they won't match.
  130. if (itm->GetKeyElementList().size() > 0 || itm->GetSubElementList().size() > 0)
  131. {
  132. continue;
  133. }
  134. ProcessImgPropertiesWithParticleData(exp, itm, particle);
  135. //calculate the expression which has been processed.
  136. bool rst = CalcuExp(exp);
  137. if (rst)
  138. {
  139. //int id = itm->GetID();
  140. particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
  141. particle->SetClassifyId(itm->GetID());
  142. particle->SetColor(itm->GetColor());
  143. particle->SetClassifyName(itm->GetName());
  144. particle->SetHardness(itm->GetHardness());
  145. particle->SetDensity(itm->GetDensity());
  146. particle->SetConductivity(itm->GetElectrical_conductivity());
  147. particle->SetGroupId(itm->GetGrpID());
  148. particle->SetGroupColor(itm->GetGrpColor());
  149. particle->SetGroupName(itm->GetGrpName());
  150. return true;
  151. }
  152. else
  153. {
  154. continue;
  155. }
  156. }
  157. particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
  158. particle->SetClassifyName("Not Identified");
  159. particle->SetColor("#000000");
  160. particle->SetGroupId((int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
  161. particle->SetGroupColor("#000000");
  162. particle->SetGroupName("Not Identified");
  163. return true;
  164. }
  165. }
  166. bool ExpressionClassifyEngine::IfNeedMaxEDS(COTSParticlePtr particle, CPosXrayPtr xray, double& MaxEDSTime)
  167. {
  168. if (particle == nullptr || xray == nullptr) return false;
  169. MaxEDSRuleList Rules = m_std->GetMaxEDSRules();
  170. for (auto rule : Rules)
  171. {
  172. std::string exp = rule->m_expressionStr;
  173. auto& partEles = xray->GetElementQuantifyData();//find all the elements containing in the particle xray.
  174. if (partEles.size() < rule->m_elementList.size())
  175. {
  176. continue;// if the size not match then continue.
  177. }
  178. std::map<CString, CElementChemistryPtr> mapChe;
  179. for (auto ch : partEles)
  180. {
  181. mapChe[ch->GetName()] = ch;
  182. }
  183. auto& usingEles = rule->m_elementList;
  184. bool bMatch=true;
  185. for (auto che : usingEles)
  186. {
  187. auto chemical = mapChe.find(che->GetName());
  188. if (chemical == mapChe.end())
  189. {
  190. bMatch = false;
  191. break;
  192. }
  193. }
  194. if (!bMatch) continue;//if cann't find the element in the particle's element,then continue.
  195. // all the rule's using element are contained in the particle then we replace the element with the percentage value
  196. for (std::string s : rule->m_OtherpropertyList)
  197. {
  198. if (s.find("_elem")!=std::string::npos)
  199. {
  200. auto val = GetAtomicNoBySortingPercentage(s.c_str(), xray);
  201. xmls::ReplaceAll(exp, s, std::to_string(val));
  202. }
  203. if (s.find("Element#")!=std::string::npos)
  204. {
  205. auto val = GetEleNameBySortingPercentage(s.c_str(), xray);//find the "Element#1" and replace it with the real element name.
  206. auto& elelist = rule->m_elementList;
  207. elelist.push_back(CElementPtr(new CElement(val)));// then replace it in the next step.
  208. xmls::ReplaceAll(exp, s, val.GetBuffer());
  209. }
  210. }
  211. for (auto eleChemistry : rule->m_elementList)
  212. {
  213. auto e = mapChe[eleChemistry->GetName()];
  214. std::string name = eleChemistry->GetName();
  215. xmls::ReplaceAll(exp, name, std::to_string(e->GetPercentage()));
  216. }
  217. for (std::string s : rule->m_ImgPropertyList)
  218. {
  219. auto val = particle->GetImgPropertyValueByName(s.c_str());
  220. xmls::ReplaceAll(exp, s, std::to_string(val));
  221. }
  222. bool rst = CalcuExp(exp);
  223. if (rst)
  224. {
  225. MaxEDSTime = rule->m_MaxEDSTime;
  226. return true;
  227. }
  228. else
  229. {
  230. continue;
  231. }
  232. }
  233. MaxEDSTime = 0;
  234. return false;
  235. }
  236. CString ExpressionClassifyEngine::GetEleNameBySortingPercentage(CString sortingNostr, CPosXrayPtr xrayInfo)
  237. {
  238. std::map<double, CElementChemistryPtr> mapPercent;
  239. std::map<int, CElementChemistryPtr> mapSorted;
  240. auto eles = xrayInfo->GetElementQuantifyData();
  241. for (auto e : eles)
  242. {
  243. mapPercent[e->GetPercentage()] = e;
  244. }
  245. auto itr = --mapPercent.end();
  246. for (int i=0;itr != mapPercent.begin();)
  247. {
  248. mapSorted.insert(std::pair<int, CElementChemistryPtr>(i, itr->second));
  249. itr--;
  250. i++;
  251. }
  252. std::string NoStr = sortingNostr;
  253. std::vector<string> strs;
  254. xmls::SplitString(NoStr, strs, "#");
  255. int No = std::stoi(strs[1]);
  256. if (mapSorted.size() > No)
  257. {
  258. return mapSorted[No]->GetName();
  259. }
  260. else
  261. {
  262. return _T("");
  263. }
  264. }
  265. double ExpressionClassifyEngine::GetMacValue(CString MacStr)
  266. {
  267. auto mapconstant = m_std->GetMapConstants();
  268. if (mapconstant.find(MacStr.GetBuffer()) != mapconstant.end())
  269. {
  270. return mapconstant[MacStr.GetBuffer()];
  271. }
  272. else
  273. {
  274. return 0.0;
  275. }
  276. }
  277. int ExpressionClassifyEngine::GetAtomicNoBySortingPercentage(CString sortingNostr, CPosXrayPtr xrayInfo)
  278. {
  279. std::map<double, CElementChemistryPtr> mapPercent;
  280. std::map<int, CElementChemistryPtr> mapSorted;
  281. auto eles = xrayInfo->GetElementQuantifyData();
  282. if (eles.size() == 0)
  283. {
  284. return 0;
  285. }
  286. for (auto e : eles)
  287. {
  288. mapPercent[e->GetPercentage()] = e;
  289. }
  290. auto itr = --mapPercent.end();
  291. for (int i = 0; itr != mapPercent.begin(); )
  292. {
  293. mapSorted.insert(std::pair<int, CElementChemistryPtr>(i, itr->second));
  294. itr--;
  295. i++;
  296. }
  297. std::string NoStr = sortingNostr;
  298. int No=10;
  299. if (sortingNostr == "first_elem") No = 0;
  300. if (sortingNostr == "second_elem") No = 1;
  301. if (sortingNostr == "third_elem") No = 2;
  302. if (sortingNostr == "fourth_elem") No = 3;
  303. if (sortingNostr == "fifth_elem") No = 4;
  304. if (sortingNostr == "sixth_elem") No = 5;
  305. if (sortingNostr == "seventh_elem") No =6;
  306. if (sortingNostr == "eighth_elem") No = 7;
  307. if (sortingNostr == "ninth_elem") No = 8;
  308. if (sortingNostr == "tenth_elem") No =9;
  309. if (mapSorted.size() > No)
  310. {
  311. std::string elename = mapSorted[No]->GetName();
  312. CElementPtr ele = CElementPtr(new CElement(elename.c_str()));
  313. return ele->GetAtomNum();
  314. }
  315. else
  316. {
  317. return 0;
  318. }
  319. }
  320. CElementChemistriesList ExpressionClassifyEngine::ZeroElementProcess(COTSParticlePtr particle, CPosXrayPtr xray)
  321. {
  322. auto& originalPartEles = xray->GetElementQuantifyData();//find all the elements containing in the particle xray.
  323. CElementChemistriesList partEles;
  324. for (auto che : originalPartEles)
  325. {
  326. auto newChe = CElementChemistryPtr(new CElementChemistry(che.get()));
  327. partEles.push_back(newChe);
  328. }
  329. //make it 100% in total.(so called the "Normalization")
  330. double rawPercentage = 0;
  331. for (auto ele : partEles)
  332. {
  333. rawPercentage += ele->GetPercentage();
  334. }
  335. for (auto ele : partEles)
  336. {
  337. ele->SetPercentage(ele->GetPercentage() / rawPercentage * 100);
  338. }
  339. //zero element process
  340. std::map<CString, CElementChemistryPtr> mapChe;
  341. for (auto ch : partEles)
  342. {
  343. mapChe[ch->GetName()] = ch;
  344. }
  345. ZeroElementRuleList Rules = m_std->GetZeroRules();
  346. for (auto rule : Rules)
  347. {
  348. std::string exp = rule->GetExpressionStr();
  349. if (partEles.size() < rule->GetUsingElementList().size())
  350. {
  351. continue;// if the size not match then continue.
  352. }
  353. auto& usingEles = rule->GetUsingElementList();
  354. bool bMatch = true;
  355. for (auto che : usingEles)
  356. {
  357. auto chemical = mapChe.find(che->GetName());
  358. if (chemical == mapChe.end())
  359. {
  360. bMatch = false;
  361. break;//if cann't find the element in the particle's element,then continue.
  362. }
  363. }
  364. if (bMatch == false) continue;
  365. // all the rule's using elements are contained in the particle then we replace the element with the percentage value
  366. for (std::string s : rule->GetOtherpropertyList())
  367. {
  368. if (s.find("_elem")!=std::string::npos)
  369. {
  370. auto val = GetAtomicNoBySortingPercentage(s.c_str(), xray);
  371. xmls::ReplaceAll(exp, s, std::to_string(val));
  372. }
  373. if (s.find("Element#")!=std::string::npos)
  374. {
  375. auto val = GetEleNameBySortingPercentage(s.c_str(), xray);//find the "Element#1" and replace it with the real element name.
  376. auto elelist = rule->GetUsingElementList();
  377. elelist.push_back(CElementPtr(new CElement(val)));// then replace it in the next step.
  378. rule->SetUsingElementList(elelist);
  379. xmls::ReplaceAll(exp, s, val.GetBuffer());
  380. }
  381. }
  382. for (auto eleChemistry : rule->GetUsingElementList())
  383. {
  384. auto e = mapChe.find(eleChemistry->GetName());
  385. if (e != mapChe.end())
  386. {
  387. std::string name = eleChemistry->GetName();
  388. xmls::ReplaceAll(exp, name, std::to_string((*e).second->GetPercentage()));
  389. }
  390. }
  391. for (std::string s : rule->GetImgPropertyList())
  392. {
  393. auto val = particle->GetImgPropertyValueByName(s.c_str());
  394. xmls::ReplaceAll(exp, s, std::to_string(val));
  395. }
  396. for (int i = 0; i < 10; i++)
  397. {
  398. std::string macStr = "MAC#" + std::to_string(i);
  399. if (exp.find(macStr) != std::string::npos)
  400. {
  401. auto val = GetMacValue(macStr.c_str());//find the "Mac#1" and replace it with the real element name.
  402. xmls::ReplaceAll(exp, macStr, std::to_string(val));
  403. }
  404. }
  405. bool rst = CalcuExp(exp);
  406. if (rst)
  407. {
  408. auto itr = std::find_if(partEles.begin(), partEles.end(), [rule](CElementChemistryPtr ele) {return ele->GetName() == CString(rule->GetZeroElementName().c_str()); });
  409. if (itr != partEles.end())
  410. {
  411. //partEles.erase(itr);//if satisfied the condition then erase the element(zero the element).
  412. (*itr)->SetPercentage(0);//if satisfied the condition then set element percentage to 0(zero the element).
  413. double sumPercentage=0;
  414. for (auto ele : partEles)
  415. {
  416. sumPercentage += ele->GetPercentage();
  417. }
  418. for (auto ele : partEles)
  419. {
  420. if (sumPercentage != 0)
  421. {
  422. ele->SetPercentage(ele->GetPercentage() / sumPercentage * 100);
  423. }
  424. }
  425. }
  426. }
  427. else
  428. {
  429. continue;
  430. }
  431. }
  432. particle->GetXrayInfo()->SetElementQuantifyData(partEles);//set the particle's xray element quantify data to the new partEles.
  433. return partEles;
  434. }
  435. void ExpressionClassifyEngine::ProcessAllPropertiesWithParticleData(std::string& exp,
  436. std::map<std::string, CElementChemistryPtr>& mapChemistrys,
  437. PartSTDRuleItemPtr itm,
  438. COTSParticlePtr particle
  439. )
  440. {
  441. // process the special property name such as "first_elem" and "Element#1" etc.
  442. auto xray = particle->GetXrayInfo();
  443. for (std::string s : itm->GetUsingOtherpropertyList())
  444. {
  445. if (s.find("_elem") != std::string::npos)
  446. {
  447. auto val = GetAtomicNoBySortingPercentage(s.c_str(), xray);
  448. xmls::ReplaceAll(exp, s, std::to_string(val));
  449. }
  450. if (s.find("Element#") != std::string::npos)
  451. {
  452. auto val = GetEleNameBySortingPercentage(s.c_str(), xray);//find the "Element#1" and replace it with the real element name.
  453. auto elelist = itm->GetKeyElementList();
  454. elelist.push_back(CElementPtr(new CElement(val)));// then replace it in the next step.
  455. itm->SetKeyElementList(elelist);
  456. xmls::ReplaceAll(exp, s, val.GetBuffer());
  457. }
  458. }
  459. //process the element property
  460. for (auto eleChemistry : itm->GetAllSortedEleList())
  461. {
  462. auto e = mapChemistrys.find(eleChemistry->GetName().GetBuffer());
  463. if (e != mapChemistrys.end())
  464. {
  465. std::string name = eleChemistry->GetName();
  466. xmls::ReplaceAll(exp, name, std::to_string(e->second->GetPercentage()));
  467. }
  468. else
  469. {
  470. std::string name = eleChemistry->GetName();
  471. xmls::ReplaceAll(exp, name, "0");
  472. }
  473. }
  474. //process the image property
  475. for (std::string s : itm->GetUsingImgPropertyNameList())
  476. {
  477. auto val = particle->GetImgPropertyValueByName(s.c_str());
  478. xmls::ReplaceAll(exp, s, std::to_string(val));
  479. }
  480. //process the "true" keyword.
  481. if (exp.find("true") != std::string::npos)
  482. {
  483. xmls::ReplaceAll(exp, "true", "(1=1)");
  484. }
  485. //process the "false" keyword.
  486. if (exp.find("false") != std::string::npos)
  487. {
  488. xmls::ReplaceAll(exp, "false", "(1=0)");
  489. }
  490. //process the contant value
  491. for (int i = 0; i < 10; i++)
  492. {
  493. std::string macStr = "MAC#" + std::to_string(i);
  494. if (exp.find(macStr) != std::string::npos)
  495. {
  496. auto val = GetMacValue(macStr.c_str());//find the "Mac#1" and replace it with the real element name.
  497. xmls::ReplaceAll(exp, macStr, std::to_string(val));
  498. }
  499. }
  500. }
  501. void ExpressionClassifyEngine::ProcessImgPropertiesWithParticleData(std::string& exp, PartSTDRuleItemPtr itm, COTSParticlePtr particle)
  502. {
  503. //process the image property
  504. for (std::string s : itm->GetUsingImgPropertyNameList())
  505. {
  506. auto val = particle->GetImgPropertyValueByName(s.c_str());
  507. xmls::ReplaceAll(exp, s, std::to_string(val));
  508. }
  509. //process the "true" keyword.
  510. if (exp.find("true") != std::string::npos)
  511. {
  512. xmls::ReplaceAll(exp, "true", "(1=1)");
  513. }
  514. //process the "false" keyword.
  515. if (exp.find("false") != std::string::npos)
  516. {
  517. xmls::ReplaceAll(exp, "false", "(1=0)");
  518. }
  519. //process the constant value
  520. for (int i = 0; i < 10; i++)
  521. {
  522. std::string macStr = "MAC#" + std::to_string(i);
  523. if (exp.find(macStr) != std::string::npos)
  524. {
  525. auto val = GetMacValue(macStr.c_str());//find the "Mac#1" and replace it with the real element name.
  526. xmls::ReplaceAll(exp, macStr, std::to_string(val));
  527. }
  528. }
  529. }
  530. bool ExpressionClassifyEngine::ZeroElementProcess(COTSParticlePtr particle)
  531. {
  532. auto chems = ZeroElementProcess(particle, particle->GetXrayInfo());
  533. particle->GetXrayInfo()->SetElementQuantifyData(chems);
  534. return true;
  535. }
  536. bool ExpressionClassifyEngine::ClassifyBySpectrum(COTSParticlePtr particle, CPosXrayPtr xray)
  537. {
  538. return false;
  539. }
  540. bool ExpressionClassifyEngine::ClassifyByExpressionTemporarySpectrum(COTSParticlePtr particle, CPosXrayPtr xray)
  541. {
  542. PartSTDRuleItemList ruleItems = m_std->GetSTDRuleItems();
  543. for (auto itm : ruleItems)
  544. {
  545. if (itm->GetIsElementAnalysis() == false)
  546. {
  547. auto sim = itm->CalculateSimilarity(xray);
  548. if (sim > 0.90)
  549. {
  550. particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
  551. particle->SetClassifyId(itm->GetID());
  552. particle->SetColor(itm->GetColor());
  553. particle->SetClassifyName(itm->GetName());
  554. particle->SetHardness(itm->GetHardness());
  555. particle->SetDensity(itm->GetDensity());
  556. particle->SetConductivity(itm->GetElectrical_conductivity());
  557. particle->SetGroupId(itm->GetGrpID());
  558. particle->SetGroupColor(itm->GetGrpColor());
  559. particle->SetGroupName(itm->GetGrpName());
  560. break;
  561. }
  562. }
  563. }
  564. return true;
  565. }
  566. bool ExpressionClassifyEngine::ClassifyIncA(COTSParticlePtr particle, int SteelTech, CPosXrayPtr xray)
  567. {
  568. return false;
  569. }
  570. OTSClassifyEngine::CLEEnginePtr GetParticleEngine(std::string a_libName)
  571. {
  572. static CLEEnginePtr engine;
  573. static std::string libName="";
  574. if (engine == NULL || libName != a_libName)
  575. {
  576. engine = CLEEnginePtr(new ExpressionClassifyEngine(a_libName));
  577. libName = a_libName;
  578. if (!engine->Init())
  579. {
  580. return NULL;
  581. }
  582. }
  583. return engine;
  584. }
  585. }