using OTSCLRINTERFACE; using OTSDataType; using System.Collections.Generic; using System.Drawing; using static OTSDataType.otsdataconst; namespace OTSModelSharp {//provide fieldpos calculate service public class CFieldPositionMgr { enum SORTING_DIRECTION { LEFT = 1, DOWN = 2, RIGHT = 3, UP = 4 } // measure area CDomain m_pMeasureArea; // measured field centre points list List m_listMeasuredFieldCentrePoints; // image scan parameter COTSImgScanPrm m_poImageScanParam; const int RESOLUTION_ID_FIRST_TIE = 0; // field centre points list List m_listFieldCentrePoints; // SEM data (measurement) CSEMDataMsr m_poSEMDataMsr; int overLap; // unmeasured field centre points list List m_listUnmeasuredFieldCentrePoints; CFieldMgrClr fieldmgrclr; public bool Init(CDomain a_pMeasureArea, COTSImgScanPrm a_poImageScanParam,int overlap, CSEMDataMsr a_poSEMDataMsr, List a_listMeasuredFieldCentrePoints) { // assign class member m_pMeasureArea = a_pMeasureArea; m_poImageScanParam = a_poImageScanParam; m_poSEMDataMsr = a_poSEMDataMsr; overLap = overlap; if (m_listFieldCentrePoints == null) { m_listFieldCentrePoints = new List(); } if (m_listUnmeasuredFieldCentrePoints == null) { m_listUnmeasuredFieldCentrePoints = new List(); } var scanfieldsize = m_poSEMDataMsr.GetScanFieldSize(); OTS_IMAGE_RESULOTION_OPTIONS nImageSizeId = m_poImageScanParam.GetImageResulotion(); long nResulotionId = RESOLUTION_ID_FIRST_TIE + (long)nImageSizeId; fieldmgrclr = new CFieldMgrClr(scanfieldsize, RESOLUTION_VALUE[nResulotionId]); CDomain domainclr = new CDomain(a_pMeasureArea.GetShape(),a_pMeasureArea.GetRectDomain()); domainclr.SetPolygonPoint(a_pMeasureArea.GetPolygonPoint()); System.Drawing.Size sizePixelImage = RESOLUTION_VALUE[nResulotionId]; fieldmgrclr.Init(domainclr.GetClrDomainObj(), sizePixelImage,scanfieldsize, (int)m_poImageScanParam.GetFieldStartMode()); fieldmgrclr.SetOverlap(overlap); List fieldpoints = new List(); for(int i=0;i GetFieldCentrePoints() { return m_listFieldCentrePoints; } // field centre points list public bool GetFieldRectByIndex(int a_nIndex, ref System.Drawing.Rectangle a_rectField) { // check input if (a_nIndex < 0 || a_nIndex > (int)m_listFieldCentrePoints.Count) { return false; } // get image size OTS_IMAGE_RESULOTION_OPTIONS nImageSizeId = m_poImageScanParam.GetImageResulotion(); int nResulotionId = RESOLUTION_ID_FIRST_TIE + (int)nImageSizeId; System.Drawing.Size sizePixelImage = RESOLUTION_VALUE[nResulotionId]; // scan field size (x, y) System.Drawing.Size sizeImage = new System.Drawing.Size(); sizeImage.Width = m_poSEMDataMsr.GetScanFieldSize() - overLap; sizeImage.Height = m_poSEMDataMsr.GetScanFieldSize() * sizePixelImage.Height/ sizePixelImage.Width-overLap; // get left top System.Drawing.Point ptcenter = m_listFieldCentrePoints[a_nIndex]; Point ptLt = new Point(ptcenter.X - sizeImage.Width / 2, ptcenter.Y + sizeImage.Height / 2); // get field rectangle a_rectField =new System.Drawing.Rectangle(ptLt, sizeImage); return true; } // unmeasured field centre points list public List GetUnmeasuredFieldCentrePoints() { return m_listUnmeasuredFieldCentrePoints; } public void CalculateBorderParticleBias(List previousFields,COTSField currentfld) { List allFldPoints = new List(); Dictionary allflds = new Dictionary(); foreach (var f in previousFields) { PointF p = f.GetOTSPosition(); Point p1 = new Point((int)p.X, (int)p.Y); allFldPoints.Add(p1); allflds.Add(p1, f); } PointF curPos = currentfld.GetOTSPosition(); Point curFld = new Point((int)curPos.X, (int)curPos.Y); Point neighbor = new Point(); if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, neighbor, (int)SORTING_DIRECTION.LEFT)) { if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence()) { currentfld.SetLeftBorderParticlesBiasDefine(false); } } if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, neighbor, (int)SORTING_DIRECTION.RIGHT)) { if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence()) { currentfld.SetRightBorderParticlesBiasDefine(false); } } if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, neighbor, (int)SORTING_DIRECTION.UP)) { if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence()) { currentfld.SetUpBorderParticlesBiasDefine(false); } } if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, neighbor, (int)SORTING_DIRECTION.DOWN)) { if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence()) { currentfld.SetDownBorderParticlesBiasDefine(false); } } } } }