ExpressionClassifyEngine.cpp 18 KB

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