FieldMgr.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. // measure area
  36. CDomainPtr GetMeasureArea() { return m_pMeasureArea; }
  37. void SetMeasureArea(CDomainPtr a_pMeasureArea);
  38. // SEM data (measurement)
  39. int GetScanFieldSize() { return m_ScanFieldSize; }
  40. void SetScanFieldSize(int a_FieldSize)
  41. {
  42. m_ScanFieldSize = a_FieldSize;
  43. }
  44. COTSFieldDataPtr FindNeighborField(const COTSFieldDataList a_flds, COTSFieldDataPtr centerField, SORTING_DIRECTION a_direction);
  45. protected:
  46. // measure area
  47. CDomainPtr m_pMeasureArea;
  48. int m_ScanFieldSize;
  49. CSize m_ResolutionSize;
  50. int m_fieldStartMode;
  51. // calculate field centre points list
  52. std::vector<CPoint> CalculateFieldCentrePoints1();
  53. // test if field is in or partly in the measure domain area
  54. BOOL IsInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize);
  55. // test if field is in the measured field centre points list
  56. BOOL IsInMeasuredFieldList(CPoint a_poiField ,std::vector<CPoint> m_listHaveMeasuredFieldCentrePoints);
  57. // find the next field centre
  58. BOOL FindNeighborFieldCentre(const std::vector<CPoint>& a_listFieldCentres,
  59. double a_dScanFieldSizeX,
  60. double a_dScanFieldSizeY,
  61. CPoint a_poiCurrent,
  62. SORTING_DIRECTION& a_nDirection,
  63. CPoint& a_poiNeighbor);
  64. // find field centre closest to measure domain point
  65. BOOL FindFieldCentreClosestMeasureDomainCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint a_poiMeasureDomain, CPoint& a_poi);
  66. // find right far side field centre
  67. void FindRightMostFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  68. // find left far side field centre
  69. void FindLeftMostFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  70. // find top far side field centre
  71. void FindHeighestFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  72. // find below far side field centre
  73. void FindLowestFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  74. // test if this is a neighbor point
  75. BOOL IsNeighborFieldCentre(CPoint a_poiFieldCentre,
  76. CPoint a_poiCurrent,
  77. double a_dScanFieldSizeX,
  78. double a_dScanFieldSizeY,
  79. SORTING_DIRECTION& a_nDirection);
  80. // get a random number in a given range
  81. int GetRangedRandNumber(int a_nRange_min, int a_nRange_max);
  82. // test if field is in or partly in the measure domain area
  83. BOOL IsInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon);
  84. BOOL PtInPolygon(CPoint p, const std::vector<CPoint> ptPolygon);
  85. };
  86. typedef std::shared_ptr<CFieldMgr> __declspec(dllexport) CFieldMgrPtr;
  87. }