FieldMgr.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #pragma once
  2. #include "Domain.h"
  3. #include "OTSImageScanParam.h"
  4. #include "SEMDataMsr.h"
  5. namespace OTSMODEL {
  6. // CFieldMgr command target
  7. typedef enum class __declspec(dllexport) SORTING_DIRECTION
  8. {
  9. LEFT = 1,
  10. DOWN = 2,
  11. RIGHT = 3,
  12. UP = 4
  13. }SORTING_DIRECTION;
  14. class __declspec(dllexport) CFieldMgr
  15. {
  16. public:
  17. CFieldMgr(); // constructor
  18. virtual ~CFieldMgr(); // destructor
  19. // initialization
  20. BOOL Init(CDomainPtr a_pMeasureArea,
  21. COTSImageScanParamPtr a_poImageScanParam,
  22. CSEMDataMsrPtr a_poSEMDataMsr,
  23. std::vector<CPoint>& a_listMeasuredFieldCentrePoints);
  24. // reset
  25. BOOL Reset(CDomainPtr a_pMeasureArea,
  26. COTSImageScanParamPtr a_poImageScanParam,
  27. CSEMDataMsrPtr a_poSEMDataMsr,
  28. std::vector<CPoint>& a_listMeasuredFieldCentrePoints);
  29. // calculate estimate total fields
  30. static long CalculateTotalFields(CDomainPtr a_poMeasureArea, double a_dScanFieldSizeX, CSize a_sizeResolution);
  31. // field centre points list
  32. std::vector<CPoint>& GetFieldCentrePoints() { return m_listFieldCentrePoints; }
  33. BOOL GetFieldRectByIndex(int a_nIndex, CRect& a_rctField);
  34. int GetTotalFields() { return (int)m_listFieldCentrePoints.size(); }
  35. void SetFieldCentrePoints(std::vector<CPoint> listPoint);
  36. // unmeasured field centre points list
  37. std::vector<CPoint>& GetUnmeasuredFieldCentrePoints() { return m_listUnmeasuredFieldCentrePoints; }
  38. BOOL UnmeasuredGetNextField(CRect& a_rectField);
  39. BOOL GetUnmeasuredRandemField(CRect& a_rectField);
  40. void SetUnmeasuredFieldCentrePoints(std::vector<CPoint> listPoint);
  41. // measured field centre points list
  42. std::vector<CPoint>& GetMeasuredFieldCentrePoints() { return m_listMeasuredFieldCentrePoints; }
  43. void GetMeasuredFieldCentrePoints(std::vector<CPoint>& a_listMeasuredFieldCentrePoints) { m_listMeasuredFieldCentrePoints = a_listMeasuredFieldCentrePoints; }
  44. void SetMeasuredFieldCentrePoints(std::vector<CPoint> listPoint);
  45. // measure area
  46. CDomainPtr GetMeasureArea() { return m_pMeasureArea; }
  47. void SetMeasureArea(CDomainPtr a_pMeasureArea);
  48. // image scan parameter
  49. COTSImageScanParamPtr GetImageScanParam() { return m_poImageScanParam; }
  50. void SetImageScanParam(COTSImageScanParamPtr a_poImageScanParam);
  51. // SEM data (measurement)
  52. CSEMDataMsrPtr GetSEMDataMsr() { return m_poSEMDataMsr; }
  53. void SetSEMDataMsr(CSEMDataMsrPtr a_poSEMDataMsr);
  54. protected:
  55. // field centre points list
  56. std::vector<CPoint> m_listFieldCentrePoints;
  57. // unmeasured field centre points list
  58. std::vector<CPoint> m_listUnmeasuredFieldCentrePoints;
  59. // measured field centre points list
  60. std::vector<CPoint> m_listMeasuredFieldCentrePoints;
  61. // measure area
  62. CDomainPtr m_pMeasureArea;
  63. // image scan parameter
  64. COTSImageScanParamPtr m_poImageScanParam;
  65. // SEM data (measurement)
  66. CSEMDataMsrPtr m_poSEMDataMsr;
  67. // calculate field centre points list
  68. BOOL CalculateFieldCentrePoints1(std::vector<CPoint>& a_listMeasuredFieldCentrePoints);
  69. // test if field is in or partly in the measure domain area
  70. BOOL IsInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize);
  71. // test if field is in the measured field centre points list
  72. BOOL IsInMeasuredFieldList(CPoint a_poiField);
  73. // find the next field centre
  74. BOOL FindNeighborFieldCentre(const std::vector<CPoint>& a_listFieldCentres,
  75. double a_dScanFieldSizeX,
  76. double a_dScanFieldSizeY,
  77. CPoint a_poiCurrent,
  78. SORTING_DIRECTION& a_nDirection,
  79. CPoint& a_poiNeighbor);
  80. // find field centre closest to measure domain point
  81. BOOL FindFieldCentreClosestMeasureDomainCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint a_poiMeasureDomain, CPoint& a_poi);
  82. // find right far side field centre
  83. void FindRightFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  84. // find left far side field centre
  85. void FindLeftFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  86. // find top far side field centre
  87. void FindTopFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  88. // find below far side field centre
  89. void FindBottomFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  90. // test if this is a neighbor point
  91. BOOL IsNeighborFieldCentre(CPoint a_poiFieldCentre,
  92. CPoint a_poiCurrent,
  93. double a_dScanFieldSizeX,
  94. double a_dScanFieldSizeY,
  95. SORTING_DIRECTION& a_nDirection);
  96. // get a random number in a given range
  97. int GetRangedRandNumber(int a_nRange_min, int a_nRange_max);
  98. // test if field is in or partly in the measure domain area
  99. BOOL IsInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon);
  100. BOOL PtInPolygon(CPoint p, const std::vector<CPoint> ptPolygon);
  101. };
  102. typedef std::shared_ptr<CFieldMgr> __declspec(dllexport) CFieldMgrPtr;
  103. }