FieldMgr.h 3.5 KB

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