ExpressionClassifyEngine.cpp 18 KB

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