123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- #include "stdafx.h"
- #include "SmplMsrResultFile.h"
- namespace OTSMODEL {
- using namespace OTSDATA;
-
- // constructor
- CSmplMsrResultFile::CSmplMsrResultFile()
- {
- Init();
- }
- // copy constructor
- CSmplMsrResultFile::CSmplMsrResultFile(const CSmplMsrResultFile& a_oSource)
- {
- // can't copy itself
- if (&a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- CSmplMsrResultFile::CSmplMsrResultFile(CSmplMsrResultFile* a_poSource)
- {
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(*a_poSource);
- }
- // =operator
- CSmplMsrResultFile& CSmplMsrResultFile::operator=(const CSmplMsrResultFile& a_oSource)
- {
- // cleanup
- Cleanup();
- // copy the class data over
- Duplicate(a_oSource);
- // return class
- return *this;
- }
- // ==operator
- BOOL CSmplMsrResultFile::operator==(const CSmplMsrResultFile& a_oSource)
- {
- return FALSE;
- }
- // destructor
- CSmplMsrResultFile::~CSmplMsrResultFile()
- {
- Cleanup();
- }
- // serialization
-
- void CSmplMsrResultFile::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
- {
- xmls::xInt xnFileMark;
- xmls::xString xnVersion;
- xmls::xBool xbSwitch;
- //xmls::Collection<COTSFieldData> xfields;
- xmls::Slo slo;
- slo.Register("FileMark", &xnFileMark);
- slo.Register("Version", &xnVersion);
- slo.Register("Switch", &xbSwitch);
- slo.Register("SEMStageData", m_pSEMStageData.get());
- slo.Register("Stage", m_pStage.get());
- slo.Register("SEMData", m_pSEMData.get());
- slo.Register("Sample", m_pSample.get());
- //slo.Register("Fields", &xfields);
- if (isStoring)
- {
- xnFileMark = SMPL_MSR_RESULT_FILE_MARK;
- xnVersion = SMPL_MSR_RESULT_FILE_VERSION;
- xbSwitch = m_bSwitch;
- //xfields.Clear();
- /*for (auto pFildData : m_listFieldData)
- {
- xfields.addItem(pFildData.get());
- }*/
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- m_bSwitch = xbSwitch.value();
- m_strFileVersion = xnVersion.value().c_str();
- m_listFieldData.clear();
- /*for (unsigned int i = 0;i < xfields.size(); i++)
- {
- m_listFieldData.push_back(COTSFieldDataPtr(xfields.getItem(i)));
- }*/
- }
- }
- // SEM sample stage
- void CSmplMsrResultFile::SetSEMStageData(CSEMStageDataPtr a_pSEMStageData)
- {
- ASSERT(a_pSEMStageData);
- if(!a_pSEMStageData)
- {
- return;
- }
- m_pSEMStageData = a_pSEMStageData;
- }
- // sample stage
- void CSmplMsrResultFile::SetStage(CStagePtr a_pStage)
- {
- ASSERT(a_pStage);
- if (!a_pStage)
- {
- return;
- }
- m_pStage = a_pStage;
- }
- // SEM condition
- void CSmplMsrResultFile::SetSEMStage(CSEMDataGnrPtr a_pSEMData)
- {
- ASSERT(a_pSEMData);
- if (!a_pSEMData)
- {
- return;
- }
- m_pSEMData = a_pSEMData;
- }
- // sample setting
- void CSmplMsrResultFile::SetSample(COTSSamplePtr a_pSample)
- {
- ASSERT(a_pSample);
- if (!a_pSample)
- {
- return;
- }
- m_pSample = a_pSample;
- SetFieldData(a_pSample->GetFieldsData());
- }
- // fields
- void CSmplMsrResultFile::SetFieldData(COTSFieldDataList& a_listFieldData)
- {
- m_listFieldData.clear();
- for (auto pFieldData : a_listFieldData)
- {
- //COTSFieldDataPtr pFieldDataNew = COTSFieldDataPtr(new COTSFieldData(*pFieldData.get()));
- COTSFieldDataPtr pFieldDataNew = pFieldData;
- m_listFieldData.push_back(pFieldDataNew);
- }
- }
- COTSParticleList CSmplMsrResultFile::GetAllParticles()
- {
- COTSParticleList listParticle;
- COTSFieldDataList& listFieldData = GetFieldData();
- for (auto pFieldData : listFieldData)
- {
- COTSParticleList listParticlenew = pFieldData->GetParticleList();
- for (auto pParticle : listParticlenew)
- {
- listParticle.push_back(pParticle);
- }
- }
- return listParticle;
- }
- bool CSmplMsrResultFile::GetSTDMapedParticleList(std::map<std::string, COTSParticleList>* mapSameSTDPartList)
- {
- //把颗粒根据类型分组,类型 ID做key,颗粒列表做value
- std::map<std::string, COTSParticleList>::iterator partListIter;
- auto listParticle = GetAllParticles();
- //get the same type particle together
- for (auto pParticle : listParticle)
- {
- std::string sType = pParticle->TypeName();
- int nType = (int)pParticle->GetType();
- //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
- if (nType >= (int)OTS_PARTCLE_TYPE::ISNOT_INCLUTION)
- {
- partListIter = mapSameSTDPartList->find(sType);
- if (partListIter == mapSameSTDPartList->end())
- {
- COTSParticleList listParticle;
- listParticle.push_back(pParticle);
- mapSameSTDPartList->insert(std::pair<std::string, COTSParticleList>(sType, listParticle));
- }
- else
- {
- partListIter->second.push_back(pParticle);
- }
- }
- }
- return true;
- }
- // protected
- // cleanup
- void CSmplMsrResultFile::Cleanup()
- {
- m_listFieldData.clear();
- }
- // initialization
- void CSmplMsrResultFile::Init()
- {
- // file version string
- m_strFileVersion = _T("");
- // SEM sample stage
- m_pSEMStageData = CSEMStageDataPtr(new CSEMStageData());
- // sample stage
- m_pStage = CStagePtr(new CStage());
- // SEM condition??
- //CSEMStageDataPtr m_pSEMData;
- m_pSEMData = CSEMDataGnrPtr(new CSEMDataGnr());
- // sample setting
- m_pSample = COTSSamplePtr(new COTSSample());
- // switch
- m_bSwitch = FALSE;
- // fields
- m_listFieldData.clear();
- }
- // duplication
- void CSmplMsrResultFile::Duplicate(const CSmplMsrResultFile& a_oSource)
- {
- // initialization
- Init();
- // copy data over
- // file version string
- m_strFileVersion = a_oSource.m_strFileVersion;
- // SEM sample stage
- m_pSEMStageData = a_oSource.m_pSEMStageData;
- // sample stage
- m_pStage = a_oSource.m_pStage;
- // SEM condition??
- //CSEMStageDataPtr m_pSEMData;
- m_pSEMData = a_oSource.m_pSEMData;
- // sample setting
- m_pSample = a_oSource.m_pSample;
- // switch
- m_bSwitch = a_oSource.m_bSwitch;
- // fields
- m_listFieldData.clear();
- for (auto pFieldData : a_oSource.m_listFieldData)
- {
- COTSFieldDataPtr pFieldDataNew = COTSFieldDataPtr(new COTSFieldData(*pFieldData.get()));
- m_listFieldData.push_back(pFieldDataNew);
- }
- }
- }
|