OTSFieldMgrClr.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #include "stdafx.h"
  2. #include "OTSFieldMgrClr.h"
  3. namespace OTSINTERFACE {
  4. COTSFieldMgrClr::COTSFieldMgrClr()
  5. {
  6. mFieldMgr =new COTSFieldMgrPtr( new COTSFieldMgr());
  7. }
  8. COTSFieldMgrClr::COTSFieldMgrClr(COTSFieldMgrPtr a_pOTSFieldMgr)
  9. {
  10. mFieldMgr = new COTSFieldMgrPtr(a_pOTSFieldMgr);
  11. }
  12. COTSFieldMgrPtr COTSFieldMgrClr::GetCFiledMgrPtr()
  13. {
  14. return *mFieldMgr;
  15. }
  16. COTSFieldMgrClr::~COTSFieldMgrClr()
  17. {
  18. if (mFieldMgr != nullptr)
  19. {
  20. delete mFieldMgr;
  21. mFieldMgr = nullptr;
  22. }
  23. }
  24. COTSFieldMgrClr::!COTSFieldMgrClr()
  25. {
  26. if (mFieldMgr != nullptr)
  27. {
  28. delete mFieldMgr;
  29. mFieldMgr = nullptr;
  30. }
  31. }
  32. void COTSFieldMgrClr::SetOTSFieldData(COTSFieldDataClr^ a_pOTSFieldData)
  33. {
  34. ASSERT(a_pOTSFieldData);
  35. if (!a_pOTSFieldData)
  36. {
  37. LogErrorTrace(__FILE__, __LINE__, _T("SetOTSFieldData: invalid OTS field data pointer."));
  38. return;
  39. }
  40. mFieldMgr->get()->SetOTSFieldData( a_pOTSFieldData->GetOTSFieldDataPtr());
  41. }
  42. void COTSFieldMgrClr::SetBSEImage(CBSEImgClr^ a_pBSEImg)
  43. {
  44. ASSERT(a_pBSEImg);
  45. if (!a_pBSEImg)
  46. {
  47. LogErrorTrace(__FILE__, __LINE__, _T("SetOTSFieldData: invalid OTS field data pointer."));
  48. return;
  49. }
  50. mFieldMgr->get()->SetBSEImage( a_pBSEImg->GetBSEImgPtr ());
  51. }
  52. // delete BackGround
  53. bool COTSFieldMgrClr::RemoveBSEImageBG(COTSImgProcPrmClr^ a_pImageProcessParam, CBSEImgClr^% a_pBSEImg)
  54. {
  55. COTSFieldMgrPtr pOTSFieldMgr = GetCFiledMgrPtr();
  56. ASSERT(pOTSFieldMgr);
  57. if (!pOTSFieldMgr)
  58. {
  59. LogErrorTrace(__FILE__, __LINE__, _T("DeleteBSEBackGround: invalid field mgr pointer."));
  60. return false;
  61. }
  62. ASSERT(a_pImageProcessParam);
  63. if (!a_pImageProcessParam)
  64. {
  65. LogErrorTrace(__FILE__, __LINE__, _T("DeleteBSEBackGround: invalide image process pointer."));
  66. return false;
  67. }
  68. COTSImageProcessParamPtr pImgProc = a_pImageProcessParam->GetImgPrcPrmPtr();
  69. ASSERT(pImgProc);
  70. if (!pImgProc)
  71. {
  72. LogErrorTrace(__FILE__, __LINE__, _T("DeleteBSEBackGround: can't get image process param pointer."));
  73. return false;
  74. }
  75. bool bRet = pOTSFieldMgr->RemoveBSEImageBG(pImgProc);
  76. return bRet;
  77. }
  78. bool COTSFieldMgrClr::IdentifyParticle(COTSImgProcPrmClr^ a_pImageProcessParam, System::Collections::Generic::List<Point>^% a_listXRayPos)
  79. {
  80. COTSFieldMgrPtr pOTSFieldMgr = GetCFiledMgrPtr();
  81. ASSERT(pOTSFieldMgr);
  82. if (!pOTSFieldMgr)
  83. {
  84. LogErrorTrace(__FILE__, __LINE__, _T("IdentifySmlOrBigParticle: invalid field mgr pointer."));
  85. return false;
  86. }
  87. ASSERT(a_pImageProcessParam);
  88. if (!a_pImageProcessParam)
  89. {
  90. LogErrorTrace(__FILE__, __LINE__, _T("IdentifySmlOrBigParticle: invalide image process pointer."));
  91. return false;
  92. }
  93. COTSImageProcessParamPtr pImgProc = a_pImageProcessParam->GetImgPrcPrmPtr();
  94. ASSERT(pImgProc);
  95. if (!pImgProc)
  96. {
  97. LogErrorTrace(__FILE__, __LINE__, _T("IdentifySmlOrBigParticle: can't get image process param pointer."));
  98. return false;
  99. }
  100. CPosXraysList listXRayPos;
  101. a_listXRayPos->Clear();
  102. bool bRet = pOTSFieldMgr->IdentifyParticle(pImgProc, listXRayPos);
  103. for (auto ptXRay : listXRayPos)
  104. {
  105. Point pt;
  106. pt.X = ptXRay->GetPosition().x;
  107. pt.Y = ptXRay->GetPosition().y;
  108. a_listXRayPos->Add(pt);
  109. }
  110. return bRet;
  111. }
  112. CPosXrayListClr ^ COTSFieldMgrClr::GetSearchPosXrayList()
  113. {
  114. auto xlist = gcnew CPosXrayListClr();
  115. auto xrayList = mFieldMgr->get()->GetSearchPosXrayList();
  116. for each(auto xray in xrayList)
  117. {
  118. xlist->Add(gcnew CPosXrayClr(xray));
  119. }
  120. return xlist;
  121. }
  122. void COTSFieldMgrClr::SetSearchPosXayList(CPosXrayListClr^ a_listPosXray, bool a_bClear)
  123. {
  124. ASSERT(a_listPosXray);
  125. if (!a_listPosXray)
  126. {
  127. LogErrorTrace(__FILE__, __LINE__, _T("SetSearchPosXayList: invalid pos xray list."));
  128. return;
  129. }
  130. CPosXraysList xList;
  131. for(int i = 0; i< (int)a_listPosXray->Count; i++)
  132. {
  133. xList.push_back (a_listPosXray[i]->GetPosXrayPtr());
  134. }
  135. mFieldMgr->get()->SetAnalysisPosXayList(xList,a_bClear);
  136. }
  137. CPosXrayListClr ^ COTSFieldMgrClr::GetAnalysisPosXrayList()
  138. {
  139. CPosXrayListClr^ xList = gcnew CPosXrayListClr();
  140. auto xrayList = mFieldMgr->get()->GetAnalysisPosXrayList();
  141. for each (auto x in xrayList)
  142. {
  143. xList->Add(gcnew CPosXrayClr(x));
  144. }
  145. return xList;
  146. }
  147. // analysis x ray list
  148. void COTSFieldMgrClr::SetAnalysisPosXayList(CPosXrayListClr^ a_listPosXray, bool a_bClear)
  149. {
  150. ASSERT(a_listPosXray);
  151. if (!a_listPosXray)
  152. {
  153. LogErrorTrace(__FILE__, __LINE__, _T("SetAnalysisPosXayList: invalid pos xray list."));
  154. return;
  155. }
  156. CPosXraysList xList;
  157. for (int i = 0; i < (int)a_listPosXray->Count; i++)
  158. {
  159. xList.push_back(a_listPosXray[i]->GetPosXrayPtr());
  160. }
  161. mFieldMgr->get()->SetAnalysisPosXayList(xList);
  162. }
  163. }