#pragma once #include "Domain.h" #include "OTSImageScanParam.h" #include "SEMDataMsr.h" #include "OTSFieldData.h" namespace OTSIMGPROC { // CFieldMgr command target typedef enum class __declspec(dllexport) SORTING_DIRECTION { LEFT = 1, DOWN = 2, RIGHT = 3, UP = 4 }SORTING_DIRECTION; class __declspec(dllexport) CFieldMgr { public: CFieldMgr(int scanfieldsize, CSize a_ResolutionSize); // constructor virtual ~CFieldMgr(); // destructor // initialization BOOL Init(CDomainPtr a_pMeasureArea,CSize a_ResolutionSize,int a_scanfieldsize, int a_FieldStartMode); // unmeasured field centre points list std::vector GetUnmeasuredFieldCentrePoints(std::vector a_listHaveMeasuredFieldCentrePoints); // reset BOOL Reset(CDomainPtr a_pMeasureArea, CSize a_ResolutionSize, int a_FieldStartMode, int a_scanFieldSize, std::vector& a_listMeasuredFieldCentrePoints); // calculate estimate total fields static long CalculateTotalFields(CDomainPtr a_poMeasureArea, double a_dScanFieldSizeX, CSize a_sizeResolution); // field centre points list std::vector GetFieldCentrePoints() { auto m_listFieldCentrePoints = CalculateFieldCentrePoints1(); return m_listFieldCentrePoints; } BOOL GetFieldRectByIndex(int a_nIndex, CRect& a_rctField); int GetTotalFields() { auto m_listFieldCentrePoints = CalculateFieldCentrePoints1(); return (int)m_listFieldCentrePoints.size(); } //overlap int GetOverlap() { return m_Overlap; } void SetOverlap(int a_Overlap) { m_Overlap = a_Overlap; } // measure area CDomainPtr GetMeasureArea() { return m_pMeasureArea; } void SetMeasureArea(CDomainPtr a_pMeasureArea); // SEM data (measurement) int GetScanFieldSize() { return m_ScanFieldSize; } void SetScanFieldSize(int a_FieldSize) { m_ScanFieldSize = a_FieldSize; } COTSFieldDataPtr FindNeighborField(const COTSFieldDataList a_flds, COTSFieldDataPtr centerField, SORTING_DIRECTION a_direction); protected: // measure area CDomainPtr m_pMeasureArea; int m_Overlap; int m_ScanFieldSize; CSize m_ResolutionSize; int m_fieldStartMode; // calculate field centre points list std::vector CalculateFieldCentrePoints1(); // test if field is in or partly in the measure domain area BOOL IsInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize); // test if field is in the measured field centre points list BOOL IsInMeasuredFieldList(CPoint a_poiField ,std::vector m_listHaveMeasuredFieldCentrePoints); // find the next field centre BOOL FindNeighborFieldCentre(const std::vector& a_listFieldCentres, double a_dScanFieldSizeX, double a_dScanFieldSizeY, CPoint a_poiCurrent, SORTING_DIRECTION& a_nDirection, CPoint& a_poiNeighbor); // find field centre closest to measure domain point BOOL FindFieldCentreClosestMeasureDomainCentre(const std::vector& a_listFieldCentres, CPoint a_poiMeasureDomain, CPoint& a_poi); // find right far side field centre void FindRightMostFieldCentre(const std::vector& a_listFieldCentres, CPoint& a_poi); // find left far side field centre void FindLeftMostFieldCentre(const std::vector& a_listFieldCentres, CPoint& a_poi); // find top far side field centre void FindHeighestFieldCentre(const std::vector& a_listFieldCentres, CPoint& a_poi); // find below far side field centre void FindLowestFieldCentre(const std::vector& a_listFieldCentres, CPoint& a_poi); // test if this is a neighbor point BOOL IsNeighborFieldCentre(CPoint a_poiFieldCentre, CPoint a_poiCurrent, double a_dScanFieldSizeX, double a_dScanFieldSizeY, SORTING_DIRECTION& a_nDirection); // get a random number in a given range int GetRangedRandNumber(int a_nRange_min, int a_nRange_max); // test if field is in or partly in the measure domain area BOOL IsInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector ptPolygon); BOOL PtInPolygon(CPoint p, const std::vector ptPolygon); }; typedef std::shared_ptr __declspec(dllexport) CFieldMgrPtr; }