FieldMgr.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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, int a_FieldStartMode);
  22. // unmeasured field centre points list
  23. std::vector<CPoint> GetUnmeasuredFieldCentrePoints(std::vector<CPoint> a_listHaveMeasuredFieldCentrePoints);
  24. // field centre points list
  25. std::vector<CPoint> GetFieldCentrePoints();
  26. BOOL IsThisPointInMeasureArea(CPoint a_position);
  27. int GetTotalFields();
  28. //overlap
  29. int GetOverlap() { return m_overlap; }
  30. void SetOverlap(int a_Overlap)
  31. {
  32. m_overlap = a_Overlap;
  33. }
  34. // measure area
  35. CDomainPtr GetMeasureArea() { return m_pMeasureArea; }
  36. void SetMeasureArea(CDomainPtr a_pMeasureArea);
  37. // SEM data (measurement)
  38. int GetScanFieldSize() { return m_ScanFieldSize; }
  39. void SetScanFieldSize(int a_FieldSize)
  40. {
  41. m_ScanFieldSize = a_FieldSize;
  42. }
  43. int GetEffectiveFieldWidth();
  44. int GetEffectiveFieldHeight();
  45. COTSFieldDataPtr FindNeighborField(const COTSFieldDataList a_flds, COTSFieldDataPtr centerField, SORTING_DIRECTION a_direction);
  46. bool FindNeighborField(const std::vector<CPoint> a_flds, CPoint a_centerField, CPoint& neighbor,SORTING_DIRECTION a_direction);
  47. protected:
  48. // measure area
  49. CDomainPtr m_pMeasureArea;
  50. int m_overlap=0;
  51. int m_ScanFieldSize;
  52. CSize m_ResolutionSize;
  53. int m_fieldStartMode;
  54. // calculate field centre points list
  55. std::vector<CPoint> CalculateFieldCentrePoints();
  56. // test if field is in or partly in the measure domain area
  57. BOOL IsInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize);
  58. // test if field is in the measured field centre points list
  59. BOOL IsInMeasuredFieldList(CPoint a_poiField ,std::vector<CPoint> m_listHaveMeasuredFieldCentrePoints);
  60. // find the next field centre
  61. BOOL FindNeighborFieldCentre(const std::vector<CPoint>& a_listFieldCentres,
  62. double a_dScanFieldSizeX,
  63. double a_dScanFieldSizeY,
  64. CPoint a_poiCurrent,
  65. SORTING_DIRECTION& a_nDirection,
  66. CPoint& a_poiNeighbor);
  67. // find field centre closest to measure domain point
  68. BOOL FindFieldCentreClosestMeasureDomainCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint a_poiMeasureDomain, CPoint& a_poi);
  69. // find right far side field centre
  70. void FindRightMostFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  71. // find left far side field centre
  72. void FindLeftMostFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  73. // find top far side field centre
  74. void FindHeighestFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  75. // find below far side field centre
  76. void FindLowestFieldCentre(const std::vector<CPoint>& a_listFieldCentres, CPoint& a_poi);
  77. // test if this is a neighbor point
  78. BOOL IsNeighborFieldCentre(CPoint a_poiFieldCentre,
  79. CPoint a_poiCurrent,
  80. double a_dScanFieldSizeX,
  81. double a_dScanFieldSizeY,
  82. SORTING_DIRECTION& a_nDirection);
  83. // test if field is in or partly in the measure domain area
  84. BOOL IsInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon);
  85. BOOL PtInPolygon(CPoint p, const std::vector<CPoint> ptPolygon);
  86. };
  87. typedef std::shared_ptr<CFieldMgr> __declspec(dllexport) CFieldMgrPtr;
  88. }