OTSFieldMgr.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "OTSFieldMgr.h"
  4. #include "OTSImageProcess.h"
  5. #include "otsdataconst.h"
  6. #include "BSEImgFileMgr.h"
  7. #include "SmplMsrResultFile.h"
  8. #include "PosXrayFileMgr.h"
  9. #include "IncAFileMgr.h"
  10. #include "DBConst.h"
  11. //#include "IClassifyEngine.h"
  12. namespace OTSMODEL {
  13. using namespace OTSSQLITE;
  14. //using namespace OTSClassifyEngine;
  15. COTSFieldMgr::COTSFieldMgr()
  16. : m_pFieldData(nullptr)
  17. {
  18. }
  19. COTSFieldMgr::~COTSFieldMgr()
  20. {
  21. }
  22. // init
  23. BOOL COTSFieldMgr::Init(COTSFieldDataPtr a_pFieldData, CBSEImgPtr a_pBSEImg)
  24. {
  25. ASSERT(a_pFieldData);
  26. if (!a_pFieldData)
  27. {
  28. // invalid field data.
  29. LogErrorTrace(__FILE__, __LINE__, _T("Init: invalid field data."));
  30. return FALSE;
  31. }
  32. ASSERT(a_pBSEImg);
  33. if (!a_pBSEImg)
  34. {
  35. // invalid BSE image.
  36. LogErrorTrace(__FILE__, __LINE__, _T("SetBSEImage: invalid BSE image."));
  37. return FALSE;
  38. }
  39. // keep the original field data pointer
  40. m_pFieldData = a_pFieldData;
  41. // make a copy of the BSE image
  42. //m_pBSEImg = CBSEImgPtr(new CBSEImg(a_pBSEImg.get()));
  43. m_pBSEImg = a_pBSEImg;
  44. // create measure result
  45. m_pMsrResults = CMsrResultsPtr(new CMsrResults());
  46. // ok, return TRUE
  47. return TRUE;
  48. }
  49. // field data
  50. void COTSFieldMgr::SetOTSFieldData(COTSFieldDataPtr a_pOTSFieldData)
  51. {
  52. ASSERT(a_pOTSFieldData);
  53. if (!a_pOTSFieldData)
  54. {
  55. // invalid field data.
  56. LogErrorTrace(__FILE__, __LINE__, _T("SetOTSFieldData: invalid field data."));
  57. return;
  58. }
  59. m_pFieldData = a_pOTSFieldData;
  60. }
  61. // BSE image
  62. void COTSFieldMgr::SetBSEImage(CBSEImgPtr a_pBSEImg)
  63. {
  64. ASSERT(a_pBSEImg);
  65. if (!a_pBSEImg)
  66. {
  67. // invalid BSE image.
  68. LogErrorTrace(__FILE__, __LINE__, _T("SetBSEImage: invalid BSE image."));
  69. return;
  70. }
  71. m_pBSEImg = a_pBSEImg;
  72. }
  73. void COTSFieldMgr::SetAnalysisPosXayList(CPosXrayList& a_listPosXray, BOOL a_bClear)
  74. {
  75. if (a_bClear)
  76. {
  77. m_listAnalysisPosXray.clear();
  78. }
  79. for (auto pPosXray : a_listPosXray)
  80. {
  81. m_listAnalysisPosXray.push_back(pPosXray);
  82. }
  83. }
  84. void COTSFieldMgr::SetMsrResult(CMsrResultsPtr a_pMsrResults)
  85. {
  86. ASSERT(a_pMsrResults);
  87. if (!a_pMsrResults)
  88. {
  89. LogErrorTrace(__FILE__, __LINE__, _T("SetMsrResult: invalid pointer."));
  90. return;
  91. }
  92. m_pMsrResults = a_pMsrResults;
  93. }
  94. BOOL COTSFieldMgr::GetIncAParticleList(COTSParticleList& a_listParticleOut)
  95. {
  96. // field data
  97. ASSERT(m_pFieldData);
  98. if (!m_pFieldData)
  99. {
  100. LogErrorTrace(__FILE__, __LINE__, _T("GetIncAParticleList: empty filed data pointer."));
  101. return FALSE;
  102. }
  103. COTSParticleList listParticleIn = m_pFieldData->GetParticleList();
  104. a_listParticleOut.clear();
  105. for (auto pParticle : listParticleIn)
  106. {
  107. int nType = (int)pParticle->GetType();
  108. if (nType > (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY)
  109. {
  110. a_listParticleOut.push_back(pParticle);
  111. }
  112. }
  113. return TRUE;
  114. }
  115. }