SmplMsrResultFile.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #include "stdafx.h"
  2. #include "SmplMsrResultFile.h"
  3. namespace OTSMODEL {
  4. using namespace OTSDATA;
  5. // constructor
  6. CSmplMsrResultFile::CSmplMsrResultFile()
  7. {
  8. Init();
  9. }
  10. // copy constructor
  11. CSmplMsrResultFile::CSmplMsrResultFile(const CSmplMsrResultFile& a_oSource)
  12. {
  13. // can't copy itself
  14. if (&a_oSource == this)
  15. {
  16. return;
  17. }
  18. // copy data over
  19. Duplicate(a_oSource);
  20. }
  21. CSmplMsrResultFile::CSmplMsrResultFile(CSmplMsrResultFile* a_poSource)
  22. {
  23. // can't copy itself
  24. if (a_poSource == this)
  25. {
  26. return;
  27. }
  28. // copy data over
  29. Duplicate(*a_poSource);
  30. }
  31. // =operator
  32. CSmplMsrResultFile& CSmplMsrResultFile::operator=(const CSmplMsrResultFile& a_oSource)
  33. {
  34. // cleanup
  35. Cleanup();
  36. // copy the class data over
  37. Duplicate(a_oSource);
  38. // return class
  39. return *this;
  40. }
  41. // ==operator
  42. BOOL CSmplMsrResultFile::operator==(const CSmplMsrResultFile& a_oSource)
  43. {
  44. return FALSE;
  45. }
  46. // destructor
  47. CSmplMsrResultFile::~CSmplMsrResultFile()
  48. {
  49. Cleanup();
  50. }
  51. // serialization
  52. void CSmplMsrResultFile::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  53. {
  54. xmls::xInt xnFileMark;
  55. xmls::xString xnVersion;
  56. xmls::xBool xbSwitch;
  57. //xmls::Collection<COTSFieldData> xfields;
  58. xmls::Slo slo;
  59. slo.Register("FileMark", &xnFileMark);
  60. slo.Register("Version", &xnVersion);
  61. slo.Register("Switch", &xbSwitch);
  62. slo.Register("SEMStageData", m_pSEMStageData.get());
  63. slo.Register("Stage", m_pStage.get());
  64. slo.Register("SEMData", m_pSEMData.get());
  65. slo.Register("Sample", m_pSample.get());
  66. //slo.Register("Fields", &xfields);
  67. if (isStoring)
  68. {
  69. xnFileMark = SMPL_MSR_RESULT_FILE_MARK;
  70. xnVersion = SMPL_MSR_RESULT_FILE_VERSION;
  71. xbSwitch = m_bSwitch;
  72. //xfields.Clear();
  73. /*for (auto pFildData : m_listFieldData)
  74. {
  75. xfields.addItem(pFildData.get());
  76. }*/
  77. slo.Serialize(true, classDoc, rootNode);
  78. }
  79. else
  80. {
  81. slo.Serialize(false, classDoc, rootNode);
  82. m_bSwitch = xbSwitch.value();
  83. m_strFileVersion = xnVersion.value().c_str();
  84. m_listFieldData.clear();
  85. /*for (unsigned int i = 0;i < xfields.size(); i++)
  86. {
  87. m_listFieldData.push_back(COTSFieldDataPtr(xfields.getItem(i)));
  88. }*/
  89. }
  90. }
  91. // SEM sample stage
  92. void CSmplMsrResultFile::SetSEMStageData(CSEMStageDataPtr a_pSEMStageData)
  93. {
  94. ASSERT(a_pSEMStageData);
  95. if(!a_pSEMStageData)
  96. {
  97. return;
  98. }
  99. m_pSEMStageData = a_pSEMStageData;
  100. }
  101. // sample stage
  102. void CSmplMsrResultFile::SetStage(CStagePtr a_pStage)
  103. {
  104. ASSERT(a_pStage);
  105. if (!a_pStage)
  106. {
  107. return;
  108. }
  109. m_pStage = a_pStage;
  110. }
  111. // SEM condition
  112. void CSmplMsrResultFile::SetSEMStage(CSEMDataGnrPtr a_pSEMData)
  113. {
  114. ASSERT(a_pSEMData);
  115. if (!a_pSEMData)
  116. {
  117. return;
  118. }
  119. m_pSEMData = a_pSEMData;
  120. }
  121. // sample setting
  122. void CSmplMsrResultFile::SetSample(COTSSamplePtr a_pSample)
  123. {
  124. ASSERT(a_pSample);
  125. if (!a_pSample)
  126. {
  127. return;
  128. }
  129. m_pSample = a_pSample;
  130. SetFieldData(a_pSample->GetFieldsData());
  131. }
  132. // fields
  133. void CSmplMsrResultFile::SetFieldData(COTSFieldDataList& a_listFieldData)
  134. {
  135. m_listFieldData.clear();
  136. for (auto pFieldData : a_listFieldData)
  137. {
  138. //COTSFieldDataPtr pFieldDataNew = COTSFieldDataPtr(new COTSFieldData(*pFieldData.get()));
  139. COTSFieldDataPtr pFieldDataNew = pFieldData;
  140. m_listFieldData.push_back(pFieldDataNew);
  141. }
  142. }
  143. COTSParticleList CSmplMsrResultFile::GetAllParticles()
  144. {
  145. COTSParticleList listParticle;
  146. COTSFieldDataList& listFieldData = GetFieldData();
  147. for (auto pFieldData : listFieldData)
  148. {
  149. COTSParticleList listParticlenew = pFieldData->GetParticleList();
  150. for (auto pParticle : listParticlenew)
  151. {
  152. listParticle.push_back(pParticle);
  153. }
  154. }
  155. return listParticle;
  156. }
  157. bool CSmplMsrResultFile::GetSTDMapedParticleList(std::map<std::string, COTSParticleList>* mapSameSTDPartList)
  158. {
  159. //把颗粒根据类型分组,类型 ID做key,颗粒列表做value
  160. std::map<std::string, COTSParticleList>::iterator partListIter;
  161. auto listParticle = GetAllParticles();
  162. //get the same type particle together
  163. for (auto pParticle : listParticle)
  164. {
  165. std::string sType = pParticle->TypeName();
  166. int nType = (int)pParticle->GetType();
  167. //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
  168. if (nType >= (int)OTS_PARTCLE_TYPE::ISNOT_INCLUTION)
  169. {
  170. partListIter = mapSameSTDPartList->find(sType);
  171. if (partListIter == mapSameSTDPartList->end())
  172. {
  173. COTSParticleList listParticle;
  174. listParticle.push_back(pParticle);
  175. mapSameSTDPartList->insert(std::pair<std::string, COTSParticleList>(sType, listParticle));
  176. }
  177. else
  178. {
  179. partListIter->second.push_back(pParticle);
  180. }
  181. }
  182. }
  183. return true;
  184. }
  185. // protected
  186. // cleanup
  187. void CSmplMsrResultFile::Cleanup()
  188. {
  189. m_listFieldData.clear();
  190. }
  191. // initialization
  192. void CSmplMsrResultFile::Init()
  193. {
  194. // file version string
  195. m_strFileVersion = _T("");
  196. // SEM sample stage
  197. m_pSEMStageData = CSEMStageDataPtr(new CSEMStageData());
  198. // sample stage
  199. m_pStage = CStagePtr(new CStage());
  200. // SEM condition??
  201. //CSEMStageDataPtr m_pSEMData;
  202. m_pSEMData = CSEMDataGnrPtr(new CSEMDataGnr());
  203. // sample setting
  204. m_pSample = COTSSamplePtr(new COTSSample());
  205. // switch
  206. m_bSwitch = FALSE;
  207. // fields
  208. m_listFieldData.clear();
  209. }
  210. // duplication
  211. void CSmplMsrResultFile::Duplicate(const CSmplMsrResultFile& a_oSource)
  212. {
  213. // initialization
  214. Init();
  215. // copy data over
  216. // file version string
  217. m_strFileVersion = a_oSource.m_strFileVersion;
  218. // SEM sample stage
  219. m_pSEMStageData = a_oSource.m_pSEMStageData;
  220. // sample stage
  221. m_pStage = a_oSource.m_pStage;
  222. // SEM condition??
  223. //CSEMStageDataPtr m_pSEMData;
  224. m_pSEMData = a_oSource.m_pSEMData;
  225. // sample setting
  226. m_pSample = a_oSource.m_pSample;
  227. // switch
  228. m_bSwitch = a_oSource.m_bSwitch;
  229. // fields
  230. m_listFieldData.clear();
  231. for (auto pFieldData : a_oSource.m_listFieldData)
  232. {
  233. COTSFieldDataPtr pFieldDataNew = COTSFieldDataPtr(new COTSFieldData(*pFieldData.get()));
  234. m_listFieldData.push_back(pFieldDataNew);
  235. }
  236. }
  237. }