#include "stdafx.h" #include "OTSFieldMgrClr.h" namespace OTSINTERFACE { COTSFieldMgrClr::COTSFieldMgrClr() { mFieldMgr =new COTSFieldMgrPtr( new COTSFieldMgr()); } COTSFieldMgrClr::COTSFieldMgrClr(COTSFieldMgrPtr a_pOTSFieldMgr) { mFieldMgr = new COTSFieldMgrPtr(a_pOTSFieldMgr); } COTSFieldMgrPtr COTSFieldMgrClr::GetCFiledMgrPtr() { return *mFieldMgr; } COTSFieldMgrClr::~COTSFieldMgrClr() { if (mFieldMgr != nullptr) { delete mFieldMgr; mFieldMgr = nullptr; } } COTSFieldMgrClr::!COTSFieldMgrClr() { if (mFieldMgr != nullptr) { delete mFieldMgr; mFieldMgr = nullptr; } } void COTSFieldMgrClr::SetOTSFieldData(COTSFieldDataClr^ a_pOTSFieldData) { ASSERT(a_pOTSFieldData); if (!a_pOTSFieldData) { LogErrorTrace(__FILE__, __LINE__, _T("SetOTSFieldData: invalid OTS field data pointer.")); return; } mFieldMgr->get()->SetOTSFieldData( a_pOTSFieldData->GetOTSFieldDataPtr()); } void COTSFieldMgrClr::SetBSEImage(CBSEImgClr^ a_pBSEImg) { ASSERT(a_pBSEImg); if (!a_pBSEImg) { LogErrorTrace(__FILE__, __LINE__, _T("SetOTSFieldData: invalid OTS field data pointer.")); return; } mFieldMgr->get()->SetBSEImage( a_pBSEImg->GetBSEImgPtr ()); } // delete BackGround bool COTSFieldMgrClr::RemoveBSEImageBG(COTSImgProcPrmClr^ a_pImageProcessParam, CBSEImgClr^% a_pBSEImg) { COTSFieldMgrPtr pOTSFieldMgr = GetCFiledMgrPtr(); ASSERT(pOTSFieldMgr); if (!pOTSFieldMgr) { LogErrorTrace(__FILE__, __LINE__, _T("DeleteBSEBackGround: invalid field mgr pointer.")); return false; } ASSERT(a_pImageProcessParam); if (!a_pImageProcessParam) { LogErrorTrace(__FILE__, __LINE__, _T("DeleteBSEBackGround: invalide image process pointer.")); return false; } COTSImageProcessParamPtr pImgProc = a_pImageProcessParam->GetImgPrcPrmPtr(); ASSERT(pImgProc); if (!pImgProc) { LogErrorTrace(__FILE__, __LINE__, _T("DeleteBSEBackGround: can't get image process param pointer.")); return false; } bool bRet = pOTSFieldMgr->RemoveBSEImageBG(pImgProc); return bRet; } bool COTSFieldMgrClr::IdentifyParticle(COTSImgProcPrmClr^ a_pImageProcessParam, System::Collections::Generic::List^% a_listXRayPos) { COTSFieldMgrPtr pOTSFieldMgr = GetCFiledMgrPtr(); ASSERT(pOTSFieldMgr); if (!pOTSFieldMgr) { LogErrorTrace(__FILE__, __LINE__, _T("IdentifySmlOrBigParticle: invalid field mgr pointer.")); return false; } ASSERT(a_pImageProcessParam); if (!a_pImageProcessParam) { LogErrorTrace(__FILE__, __LINE__, _T("IdentifySmlOrBigParticle: invalide image process pointer.")); return false; } COTSImageProcessParamPtr pImgProc = a_pImageProcessParam->GetImgPrcPrmPtr(); ASSERT(pImgProc); if (!pImgProc) { LogErrorTrace(__FILE__, __LINE__, _T("IdentifySmlOrBigParticle: can't get image process param pointer.")); return false; } CPosXraysList listXRayPos; a_listXRayPos->Clear(); bool bRet = pOTSFieldMgr->IdentifyParticle(pImgProc, listXRayPos); for (auto ptXRay : listXRayPos) { Point pt; pt.X = ptXRay->GetPosition().x; pt.Y = ptXRay->GetPosition().y; a_listXRayPos->Add(pt); } return bRet; } CPosXrayListClr ^ COTSFieldMgrClr::GetSearchPosXrayList() { auto xlist = gcnew CPosXrayListClr(); auto xrayList = mFieldMgr->get()->GetSearchPosXrayList(); for each(auto xray in xrayList) { xlist->Add(gcnew CPosXrayClr(xray)); } return xlist; } void COTSFieldMgrClr::SetSearchPosXayList(CPosXrayListClr^ a_listPosXray, bool a_bClear) { ASSERT(a_listPosXray); if (!a_listPosXray) { LogErrorTrace(__FILE__, __LINE__, _T("SetSearchPosXayList: invalid pos xray list.")); return; } CPosXraysList xList; for(int i = 0; i< (int)a_listPosXray->Count; i++) { xList.push_back (a_listPosXray[i]->GetPosXrayPtr()); } mFieldMgr->get()->SetAnalysisPosXayList(xList,a_bClear); } CPosXrayListClr ^ COTSFieldMgrClr::GetAnalysisPosXrayList() { CPosXrayListClr^ xList = gcnew CPosXrayListClr(); auto xrayList = mFieldMgr->get()->GetAnalysisPosXrayList(); for each (auto x in xrayList) { xList->Add(gcnew CPosXrayClr(x)); } return xList; } // analysis x ray list void COTSFieldMgrClr::SetAnalysisPosXayList(CPosXrayListClr^ a_listPosXray, bool a_bClear) { ASSERT(a_listPosXray); if (!a_listPosXray) { LogErrorTrace(__FILE__, __LINE__, _T("SetAnalysisPosXayList: invalid pos xray list.")); return; } CPosXraysList xList; for (int i = 0; i < (int)a_listPosXray->Count; i++) { xList.push_back(a_listPosXray[i]->GetPosXrayPtr()); } mFieldMgr->get()->SetAnalysisPosXayList(xList); } }