#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, int a_FieldStartMode); // unmeasured field centre points list std::vector GetUnmeasuredFieldCentrePoints(std::vector a_listHaveMeasuredFieldCentrePoints); // field centre points list std::vector GetFieldCentrePoints(); BOOL IsThisPointInMeasureArea(CPoint a_position); int GetTotalFields(); //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; } int GetEffectiveFieldWidth(); int GetEffectiveFieldHeight(); COTSFieldDataPtr FindNeighborField(const COTSFieldDataList a_flds, COTSFieldDataPtr centerField, SORTING_DIRECTION a_direction); bool FindNeighborField(const std::vector a_flds, CPoint a_centerField, CPoint& neighbor,SORTING_DIRECTION a_direction); protected: // measure area CDomainPtr m_pMeasureArea; int m_overlap=0; int m_ScanFieldSize; CSize m_ResolutionSize; int m_fieldStartMode; // calculate field centre points list std::vector CalculateFieldCentrePoints(); // 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); // 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; }