#pragma once #include "stdafx.h" #include "OTSFieldMgr.h" #include "OTSImageProcess.h" #include "otsdataconst.h" #include "BSEImgFileMgr.h" #include "SmplMsrResultFile.h" #include "PosXrayFileMgr.h" #include "IncAFileMgr.h" #include "DBConst.h" //#include "IClassifyEngine.h" namespace OTSMODEL { using namespace OTSSQLITE; //using namespace OTSClassifyEngine; COTSFieldMgr::COTSFieldMgr() : m_pFieldData(nullptr) { } COTSFieldMgr::~COTSFieldMgr() { } // init BOOL COTSFieldMgr::Init(COTSFieldDataPtr a_pFieldData, CBSEImgPtr a_pBSEImg) { ASSERT(a_pFieldData); if (!a_pFieldData) { // invalid field data. LogErrorTrace(__FILE__, __LINE__, _T("Init: invalid field data.")); return FALSE; } ASSERT(a_pBSEImg); if (!a_pBSEImg) { // invalid BSE image. LogErrorTrace(__FILE__, __LINE__, _T("SetBSEImage: invalid BSE image.")); return FALSE; } // keep the original field data pointer m_pFieldData = a_pFieldData; // make a copy of the BSE image //m_pBSEImg = CBSEImgPtr(new CBSEImg(a_pBSEImg.get())); m_pBSEImg = a_pBSEImg; // create measure result m_pMsrResults = CMsrResultsPtr(new CMsrResults()); // ok, return TRUE return TRUE; } // field data void COTSFieldMgr::SetOTSFieldData(COTSFieldDataPtr a_pOTSFieldData) { ASSERT(a_pOTSFieldData); if (!a_pOTSFieldData) { // invalid field data. LogErrorTrace(__FILE__, __LINE__, _T("SetOTSFieldData: invalid field data.")); return; } m_pFieldData = a_pOTSFieldData; } // BSE image void COTSFieldMgr::SetBSEImage(CBSEImgPtr a_pBSEImg) { ASSERT(a_pBSEImg); if (!a_pBSEImg) { // invalid BSE image. LogErrorTrace(__FILE__, __LINE__, _T("SetBSEImage: invalid BSE image.")); return; } m_pBSEImg = a_pBSEImg; } void COTSFieldMgr::SetAnalysisPosXayList(CPosXrayList& a_listPosXray, BOOL a_bClear) { if (a_bClear) { m_listAnalysisPosXray.clear(); } for (auto pPosXray : a_listPosXray) { m_listAnalysisPosXray.push_back(pPosXray); } } void COTSFieldMgr::SetMsrResult(CMsrResultsPtr a_pMsrResults) { ASSERT(a_pMsrResults); if (!a_pMsrResults) { LogErrorTrace(__FILE__, __LINE__, _T("SetMsrResult: invalid pointer.")); return; } m_pMsrResults = a_pMsrResults; } BOOL COTSFieldMgr::GetIncAParticleList(COTSParticleList& a_listParticleOut) { // field data ASSERT(m_pFieldData); if (!m_pFieldData) { LogErrorTrace(__FILE__, __LINE__, _T("GetIncAParticleList: empty filed data pointer.")); return FALSE; } COTSParticleList listParticleIn = m_pFieldData->GetParticleList(); a_listParticleOut.clear(); for (auto pParticle : listParticleIn) { int nType = (int)pParticle->GetType(); if (nType > (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY) { a_listParticleOut.push_back(pParticle); } } return TRUE; } }