FieldMgr.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "Domain.h"
  3. #include "OTSImageScanParam.h"
  4. #include "SEMDataMsr.h"
  5. #include "OTSFieldData.h"
  6. namespace OTSIMGPROC {
  7. // CFieldMgr command target
  8. typedef enum class __declspec(dllexport) SORTING_DIRECTION
  9. {
  10. LEFT = 1,
  11. DOWN = 2,
  12. RIGHT = 3,
  13. UP = 4
  14. }SORTING_DIRECTION;
  15. class __declspec(dllexport) CFieldMgr
  16. {
  17. public:
  18. CFieldMgr(int scanfieldsize, CSize a_ResolutionSize); // constructor
  19. virtual ~CFieldMgr(); // destructor
  20. // initialization
  21. BOOL Init(CDomainPtr a_pMeasureArea,CSize a_ResolutionSize,int a_scanfieldsize, int a_FieldStartMode);
  22. // unmeasured field centre points list
  23. std::vector<CPoint> GetUnmeasuredFieldCentrePoints(std::vector<CPoint> a_listHaveMeasuredFieldCentrePoints);
  24. // reset
  25. BOOL Reset(CDomainPtr a_pMeasureArea,
  26. CSize a_ResolutionSize, int a_FieldStartMode,
  27. int a_scanFieldSize,
  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() { auto m_listFieldCentrePoints = CalculateFieldCentrePoints1(); return m_listFieldCentrePoints; }
  33. BOOL GetFieldRectByIndex(int a_nIndex, CRect& a_rctField);
  34. int GetTotalFields() { auto m_listFieldCentrePoints = CalculateFieldCentrePoints1(); return (int)m_listFieldCentrePoints.size(); }
  35. //overlap
  36. int GetOverlap() { return m_Overlap; }
  37. void SetOverlap(int a_Overlap)
  38. {
  39. m_Overlap = a_Overlap;
  40. }
  41. // measure area
  42. CDomainPtr GetMeasureArea() { return m_pMeasureArea; }
  43. void SetMeasureArea(CDomainPtr a_pMeasureArea);
  44. // SEM data (measurement)
  45. int GetScanFieldSize() { return m_ScanFieldSize; }
  46. void SetScanFieldSize(int a_FieldSize)
  47. {
  48. m_ScanFieldSize = a_FieldSize;
  49. }
  50. COTSFieldDataPtr FindNeighborField(const COTSFieldDataList a_flds, COTSFieldDataPtr centerField, SORTING_DIRECTION a_direction);
  51. protected:
  52. // measure area
  53. CDomainPtr m_pMeasureArea;
  54. int m_Overlap;
  55. int m_ScanFieldSize;
  56. CSize m_ResolutionSize;
  57. int m_fieldStartMode;
  58. // calculate field centre points list
  59. std::vector<CPoint> CalculateFieldCentrePoints1();
  60. // test if field is in or partly in the measure domain area
  61. BOOL IsInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize);
  62. // test if field is in the measured field centre points list
  63. BOOL IsInMeasuredFieldList(CPoint a_poiField ,std::vector<CPoint> m_listHaveMeasuredFieldCentrePoints);
  64. // find the next field centre
  65. BOOL FindNeighborFieldCentre(const std::vector<CPoint>& a_listFieldCentres,
  66. double a_dScanFieldSizeX,
  67. double a_dScanFieldSizeY,
  68. CPoint a_poiCurrent,
  69. SORTING_DIRECTION& a_nDirection,
  70. CPoint& a_poiNeighbor);
  71. // find field centre closest to measure domain point
  72. BOOL FindFieldCentreClosestMeasureDomainCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint a_poiMeasureDomain, CPoint& a_poi);
  73. // find right far side field centre
  74. void FindRightMostFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  75. // find left far side field centre
  76. void FindLeftMostFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  77. // find top far side field centre
  78. void FindHeighestFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  79. // find below far side field centre
  80. void FindLowestFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  81. // test if this is a neighbor point
  82. BOOL IsNeighborFieldCentre(CPoint a_poiFieldCentre,
  83. CPoint a_poiCurrent,
  84. double a_dScanFieldSizeX,
  85. double a_dScanFieldSizeY,
  86. SORTING_DIRECTION& a_nDirection);
  87. // get a random number in a given range
  88. int GetRangedRandNumber(int a_nRange_min, int a_nRange_max);
  89. // test if field is in or partly in the measure domain area
  90. BOOL IsInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon);
  91. BOOL PtInPolygon(CPoint p, const std::vector<CPoint> ptPolygon);
  92. };
  93. typedef std::shared_ptr<CFieldMgr> __declspec(dllexport) CFieldMgrPtr;
  94. }