소스 검색

添加类中缺失方法

sunyi 5 년 전
부모
커밋
11a316a248

+ 11 - 1
OTS/OTSModelSharp/Measure/GetBSEPic/BSEImgFileMgr.cs

@@ -421,5 +421,15 @@ namespace OTSDataType
                 slo.Serialize(false, classDoc, rootNode);
             }
         }
-    }
+
+        // duplication 
+       public void Duplicate( CBSEImageFileMgr a_oSource)
+	   {
+		// initialization
+		Init();
+
+        // copy data over
+        m_poBSE = new CBSEImg(a_oSource.m_poBSE);
+	   }
+}
 }

+ 543 - 5
OTS/OTSModelSharp/Measure/GetBSEPic/MsrThread.cs

@@ -6,6 +6,7 @@ using OTSIncAMeasureApp.OTSMeasureControl;
 using static OTSDataType.otsdataconst;
 using OTSIncAMeasureApp.OTSMesureControl;
 using OTSModelSharp.MeasureControl;
+using System.Windows.Forms;
 
 namespace OTSModelSharp
 {
@@ -13,6 +14,8 @@ namespace OTSModelSharp
    
     using COTSSampleList = List<COTSSample>;
 
+   
+
     // enum and struct used for send message to App
    public  enum ENUM_MSG_TYPE 
     {
@@ -40,7 +43,33 @@ namespace OTSModelSharp
         //	MSR_START_TIME = 2,
         //	MSR_END_TIME = 3
     };
-    
+
+    public enum SAMPLE_FAULT_WARN_CODE
+    {
+        INVALID = -1,
+		MIN = 0,
+		SEM_DATA_ERROR = 0,
+		AREA_OUTSIDE_HOLE = 1,
+		RESOLUTION_LOW = 2,
+		FINISHED = 3,
+		NO_ERROR_WARNING = 4,
+		FILE_NOT_SAVED = 5,
+		MAX = 5
+	}
+
+   public enum SAMPLE_CHECK_RESULT_TYPE
+    {
+        INVALID = -1,
+		MIN = 0,
+		SWITCH_ON = 0,
+		FINISHED = 1,
+		SETTING_ERROR = 2,
+		SETTING_WARNING = 3,
+		MEASURABLE = 4,
+		NO_ERROR_WARNING = 5,		
+		MAX = 5
+	}
+
 
     public  struct ST_MSTMsg
     {
@@ -103,7 +132,9 @@ namespace OTSModelSharp
     
     public class MsrThread 
     {
-       // const CString UNTITLED_FILE_NAME = _T("Untitled");
+        int m_hWnd;
+        COTSHardwareMgr m_pHardwareMgr;
+        // const CString UNTITLED_FILE_NAME = _T("Untitled");
         private const string UNTITLED_FILE_NAME = "Untitled";
         public delegate void   ProgressEventHandler(ST_MSTMsg msg);
         public event ProgressEventHandler ProgressEvent;
@@ -120,6 +151,10 @@ namespace OTSModelSharp
 
        public COTSImgScanPrm ImageScanParam = new COTSImgScanPrm();
 
+       public int IDS_ERROR_WARNING = 12322;
+
+       public int  IDS_SAMPLE_CHECK_RESULT  =  12311;
+
         // measure loop status
 
         public MsrThread()
@@ -141,6 +176,24 @@ namespace OTSModelSharp
         {
             return m_pProjMgrFile;
         }
+
+       public  void SetProjMgrFile(COTSProjMgrFile a_pProjMgrFile)
+        {            
+            m_pProjMgrFile = a_pProjMgrFile;
+        }
+
+        // measurable sample list
+       public List<COTSSample> GetMeasurableSamples() { return m_listMeasurableSamples; }
+
+        // measurable sample list
+       public void SetMeasurableSamples(List<COTSSample> a_listMeasurableSamples)
+        {
+            foreach (var pSample in a_listMeasurableSamples)
+            {
+
+                m_listMeasurableSamples.Add(pSample);
+            }
+        }
         public IMeasureHardware GetMeasureHardWare()
         {
             return m_HardwareMgr;
@@ -162,6 +215,41 @@ namespace OTSModelSharp
         }
 
         public CMsrThreadStatus GetMsrThreadStatus() { return m_pThreadStatus; }
+
+        public  void SetMsrThreadStatus(CMsrThreadStatus a_pThreadStatus)
+        {
+            
+            m_pThreadStatus = a_pThreadStatus;
+        }
+
+        //MeasureAppFormName
+      public  String GetMsrAppFormName() { return m_strMAppFormName; }
+
+      public  void SetMsrAppFormName(String a_MAppFormName) { m_strMAppFormName = a_MAppFormName; }
+
+        int GetWnd() { return m_hWnd; }
+
+        void SetHWND(int a_hWnd) { m_hWnd = a_hWnd; }
+
+       public bool CheckProjFileSave()
+        {
+            
+            // Save or Save As, if strPathName is not empty, it is exist in the computer, this is a save action
+            String strPathName = m_pProjMgrFile.GetPathName();
+
+            // is this a file no saved?
+            strPathName.Trim();
+            if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0 || strPathName=="")
+            {
+
+                // return save as result
+                return false;
+            }
+
+            return true;
+
+        }
+
         bool Init(COTSProjMgrFile a_pProjMgrFile)
         {
             m_pProjMgrFile = a_pProjMgrFile;
@@ -180,6 +268,67 @@ namespace OTSModelSharp
             m_HardwareMgr.DisconnectHardware();
             ProgressEvent(MsrMsg);
         }
+
+       public bool GetClassifyParticleId(bool usingSyslib, string libname, int steelTech, COTSParticle part, int a_nIncId)
+        {
+
+            if (usingSyslib)
+            {
+                var IncAen = GetInclutionEngine();//OTSClassifyEngine::GetInclutionEngine();
+                //if (!IncAen.Classify(part, steelTech, part.GetXrayInfo()))
+                //{
+
+                //    return false;
+                //}
+                if (part.GetType() == (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED)
+                {
+                    var ExpEn = GetParticleEngine(libname);//OTSClassifyEngine::GetParticleEngine(libname);
+                    //if (!ExpEn.Classify(part, part.GetXrayInfo()))
+                    //{
+
+                    //    return false;
+                    //}
+                }
+            }
+            else
+            {
+                var ExpEn = GetParticleEngine(libname);//OTSClassifyEngine::GetParticleEngine(libname);
+                //if (!ExpEn.Classify(part, part.GetXrayInfo()))
+                //{
+
+                //    return false;
+                //}
+            }
+
+            if (a_nIncId < 8)
+            {
+                a_nIncId = (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED;
+            }
+            a_nIncId = part.GetType();
+            // ok, return TRUE
+            return true;
+        }
+
+       public bool Classify(COTSParticle particle, int SteelTech, CPosXray xray)
+        {
+            // throw std::logic_error("The method or operation is not implemented.");
+            return false;
+        }
+
+        public string GetInclutionEngine()
+        {
+            //static CLEEngine engine;
+            //if (engine == null)
+            //{
+            //    engine = new InclutionClassifyEngine();
+            //    engine->Init();
+            //}
+            //return engine;
+            return "";
+        }
+        string libname = "";
+        public string GetParticleEngine(string libname) { return ""; }
+       
         bool SetWorkingFolderStr()
         {
             // get project file pathname
@@ -216,6 +365,19 @@ namespace OTSModelSharp
             return m_pThreadStatus.GetStatus() == OTSIncAMeasureApp.OTSMesureControl.OTS_MSR_THREAD_STATUS.STOPPED;
         }
 
+        // SEM data general
+       public CSEMDataGnr GetSEMDataGnr() { return m_pSEMDataGnr; }
+
+        // SEM data general
+       public void SetSEMDataGnr(CSEMDataGnr a_pSEMDataGnr)
+        {        
+
+            m_pSEMDataGnr = a_pSEMDataGnr;
+        }
+
+        // working folder 
+      public  String GetWorkingFolder() { return m_strWorkingFolder; }
+
         public bool  IsMeasureRunning() { return m_pThreadStatus.GetStatus() == OTSIncAMeasureApp.OTSMesureControl.OTS_MSR_THREAD_STATUS.INPROCESS; }
         public bool  IsMeasureFailed() { return m_pThreadStatus.GetStatus() == OTSIncAMeasureApp.OTSMesureControl.OTS_MSR_THREAD_STATUS.FAILED; }
         public bool  IsMeasureCompleted() { return m_pThreadStatus.GetStatus() == OTSIncAMeasureApp.OTSMesureControl.OTS_MSR_THREAD_STATUS.COMPLETED; }
@@ -565,10 +727,15 @@ namespace OTSModelSharp
 
             return true;
         }
-        public bool GetMeasureAppFormName(string name) { return false; }
+        // public bool GetMeasureAppFormName(string name) { return false; }
 
-        // measure status
-       public void SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS a_nMsrLoopStatus)
+     public void GetMeasureAppFormName( String csFormName)
+	 {
+		m_strMAppFormName = csFormName;
+	 }
+
+    // measure status
+    public void SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS a_nMsrLoopStatus)
         {
             if (a_nMsrLoopStatus >= otsdataconst.OTS_MSR_THREAD_STATUS.MIN && a_nMsrLoopStatus <= otsdataconst.OTS_MSR_THREAD_STATUS.MAX)
             {
@@ -577,5 +744,376 @@ namespace OTSModelSharp
         }
 
       public  void SetStatus(otsdataconst.OTS_MSR_THREAD_STATUS a_nStatus) { m_nStatus = a_nStatus; }
+
+        // x-ray controller
+      public OTSEDSBase GetEDSController()
+        {
+           
+
+            // get SEM, scanner and x-ray controller via hardware manager
+            OTSEDSBase pEDSCtrlPtr = m_pHardwareMgr.GetEDSControllerPtr();
+           
+
+            return pEDSCtrlPtr;
+        }
+
+        // BSE controller
+       public COTSScanBase GetScanController()
+        {
+            
+
+            // get SEM, scanner and x-ray controller via hardware manager
+            COTSScanBase pScanCtrlPtr = m_pHardwareMgr.GetScanControllerPtr();
+           
+
+            return pScanCtrlPtr;
+        }
+
+        //check measure param
+        //input: COTSProjMgrFilePtr  a_pProjMgrFile : work file
+        //		 COTSSamplesList& a_listMeasuableSamples : out put -- measure samples list
+        //		 BOOL a_bCheckSetting : TRUE check settings
+      public  bool CheckMeasureParam(COTSProjMgrFile a_pProjMgrFile, List<COTSSample> a_listMeasuableSamples, bool a_bCheckSetting /*=TRUE*/)
+        {
+            // use the dll resource
+           // AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+          
+            // go through the sample list to check setting parameters 
+            int nSwitchSmplNo = 0;
+            int nCompletedSmplNo = 0;
+            int nErrorSmplNo = 0;
+            int nWarningSmplNo = 0;
+            List<String> listSamplMessages = new List<string>();
+            List<COTSSample> listSamples = a_pProjMgrFile.GetSampleList();
+            List<COTSSample> listMeasurableSamples = new List<COTSSample>();
+            List<COTSSample> listWithWarningMeasurableSamples = new List<COTSSample>();
+            foreach (var pSample in listSamples)
+            {
+                // is the sample switch on
+                if (pSample.GetSwitch())
+                {
+                    ++nSwitchSmplNo;
+                    String strSmplMessage;
+                    strSmplMessage = pSample.GetName() + ":" + "\r\n";
+
+                    // is this a measurement completed sample
+                    if (IsMeasureCompletedSmpl(pSample))
+                    {   // measurement completed sample
+                        ++nCompletedSmplNo;
+                        string str2 = GetSampleErrorWarnString(SAMPLE_FAULT_WARN_CODE.FINISHED);
+                        strSmplMessage += str2;
+                        strSmplMessage += "\r\n";
+                    }
+                    else
+                    {
+                        // errors
+                        List<SAMPLE_FAULT_WARN_CODE> a_listErrorCodes = new List<SAMPLE_FAULT_WARN_CODE>();
+                        GetSampleErrorCodes(a_pProjMgrFile, pSample, a_listErrorCodes);
+                        if (a_listErrorCodes!=null)
+                        {
+                            // has error, this is not a measurable sample
+                            ++nErrorSmplNo;
+                            foreach (var  nErrorCode in a_listErrorCodes)
+                            {
+                                String strs = GetSampleErrorWarnString(nErrorCode);
+                                strSmplMessage += strs;
+                                strSmplMessage += "\r\n";
+                            }
+                        }
+                        else
+                        {
+                            // no error, this is a measurable sample
+                            listMeasurableSamples.Add(pSample);
+                        }
+
+                        // warnings
+                        List<SAMPLE_FAULT_WARN_CODE> a_listWarningCodes = new List<SAMPLE_FAULT_WARN_CODE>();
+                        GetSampleWarningCodes(a_pProjMgrFile, pSample, a_listWarningCodes);
+                        if (a_listWarningCodes!=null)
+                        {
+                            ++nWarningSmplNo;
+                            foreach (var  nWarningCode in a_listWarningCodes)
+                            {
+                                String strt = GetSampleErrorWarnString(nWarningCode);
+                                strSmplMessage += strt;
+                                strSmplMessage += "\r\n";
+                            }
+
+                            // has no error?
+                            if (a_listErrorCodes==null)
+                            {
+                                // this is a measurable sample but with setting warnings
+                                listWithWarningMeasurableSamples.Add(pSample);
+                            }
+                        }
+
+                        // no error and warning
+                        if (a_listErrorCodes==null && a_listWarningCodes==null)
+                        {
+                            String strd = GetSampleErrorWarnString(SAMPLE_FAULT_WARN_CODE.NO_ERROR_WARNING);
+                            strSmplMessage += strd;
+                            strSmplMessage += "\r\n";
+                        }
+                    }
+
+                    // add 
+                    listSamplMessages.Add(strSmplMessage);
+                }
+            }
+
+            // dlg message string
+            String strDlgMessage = "";
+            String str = "";
+            String str1;
+            str1 = MultiLang.GetInstance().GetStringByKey(IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.SWITCH_ON,0);
+            string.Format(str1, nSwitchSmplNo);
+            strDlgMessage += str1;
+            strDlgMessage += "\r\n";
+
+            // add more string if there switch on sample
+            if (nSwitchSmplNo > 0)
+            {
+                // completed sample number (optional)
+                if (nCompletedSmplNo > 0)
+                {
+                    str1 = MultiLang.GetInstance().GetStringByKey(IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.FINISHED,0);
+                    string.Format(str1, nCompletedSmplNo);
+                    strDlgMessage += str1;
+                    strDlgMessage += "\r\n";
+                }
+
+                // any unmeasured switch on samples?
+                if (nSwitchSmplNo > nCompletedSmplNo)
+                {
+                    // with setting error sample number
+                    str1 = MultiLang.GetInstance().GetStringByKey(IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.SETTING_ERROR,0);
+                    string.Format(str1, nErrorSmplNo);
+                    strDlgMessage += str1;
+                    strDlgMessage += "\r\n";
+
+                    // with setting warning sample number
+                    str1 = MultiLang.GetInstance().GetStringByKey(IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.SETTING_WARNING,0);
+                    string.Format(str1, nWarningSmplNo);
+                    strDlgMessage += str1;
+                    strDlgMessage += "\r\n";
+
+                }
+
+                // measurable sample numbers (has %d there)
+                str = MultiLang.GetInstance().GetStringByKey(IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.MEASURABLE,0);
+                strDlgMessage += str;
+                strDlgMessage += "\r\n";
+            }
+
+            // add an empty line strDlgMessage
+            strDlgMessage += "\r\n";
+
+            // add sample messages
+            foreach (var strSmplMessage in listSamplMessages)
+            {
+                strDlgMessage += strSmplMessage;
+                strDlgMessage += "\r\n";
+            }
+
+            // do we need to show dialog box?
+            if (nSwitchSmplNo == 0)
+            {
+
+                return false;
+            }
+
+            // measure button clicked?
+            if (a_bCheckSetting)
+            {
+                // there are measurable samples but no setting warnings samples
+                if ((int)listMeasurableSamples.Count > 0 && (int)listWithWarningMeasurableSamples.Count == 0)
+                {
+                    // set output measurable samples list
+                    foreach (var pSample in listMeasurableSamples)
+                    {
+                        a_listMeasuableSamples.Add(pSample);
+                    }
+                    return true;
+                }
+
+            }
+            //when there is sample setting error, and setting with no error and no warning samples, the dlg will not be show.??
+
+            //show the result dlg
+            DIALOG_CHECK_PARAM_RESULT dlg = new DIALOG_CHECK_PARAM_RESULT();
+            int nTatolMeasuableSmplNo = (int)listMeasurableSamples.Count;
+            int nWithWarningMeasuableSmplNo = (int)listWithWarningMeasurableSamples.Count;
+
+            // set the dlg parameters
+            dlg.SetCheckOnlyFlag(a_bCheckSetting);
+            dlg.SetMessageBase(strDlgMessage);
+            dlg.SetTatolMeasuableSmplNo(nTatolMeasuableSmplNo);
+            dlg.SetWithWarningMeasuableSmplNo(nWithWarningMeasuableSmplNo);
+
+            //show dlg
+
+           // if (dlg.ShowDialog != DialogResult.OK)
+            //{
+                // do something here
+             //   return false;
+           // }
+           // else
+           // {
+                //if warnDo, back the listMeasuableSample
+                if (dlg.GetWarnDo())
+                {
+                    foreach (var pSample in listMeasurableSamples)
+                    {
+                        a_listMeasuableSamples.Add(pSample);
+                    }
+                }
+                else // back with no warn sample
+                {
+                    foreach (var pSample in listMeasurableSamples)
+                    {
+                        // auto itr = std::find(listWithWarningMeasurableSamples.begin(), listWithWarningMeasurableSamples.end(), pSample);
+                        //if (itr == listWithWarningMeasurableSamples.end())
+                        //{
+                        //    a_listMeasuableSamples.Add(pSample);
+                        //}
+                        bool IsChanged = false;
+                        for (int itr = 0; itr < listMeasurableSamples.Count; itr++)
+                        {
+                            if (listMeasurableSamples[itr].GetName() == str)
+                            {
+                                COTSSample oTSSample = listMeasurableSamples[itr];                               
+                                listMeasurableSamples.RemoveAt(itr);
+                                IsChanged = true;
+                            }
+                        }
+
+                        if (!IsChanged)
+                        {
+                            return false;
+                        }
+                    }
+                }
+           // }
+
+            m_listMeasurableSamples = a_listMeasuableSamples;//set the measureable samples to the member variable,so we can use it later. gsp.
+
+
+            return true;
+        }
+
+        // get error codes list of a sample
+      public  void GetSampleErrorCodes(COTSProjMgrFile a_pProjMgrFile, COTSSample a_pSample, List<SAMPLE_FAULT_WARN_CODE> a_listErrorCodes)
+        {
+
+            // check setting error
+            if ((a_pSample.GetSEMDataMsr()) == new CSEMDataMsr())
+            {
+                a_listErrorCodes.Add(SAMPLE_FAULT_WARN_CODE.SEM_DATA_ERROR);
+            }
+
+            // file has not been saved
+            String strPathName = a_pProjMgrFile.GetPathName();
+
+            // is this a file no saved?
+            strPathName.Trim();
+            if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0 || strPathName=="")
+            {
+               
+                a_listErrorCodes.Add(SAMPLE_FAULT_WARN_CODE.FILE_NOT_SAVED);
+            }
+
+            // more error checking...
+        }
+
+        // check sample a measurement completed
+        public  bool IsMeasureCompletedSmpl(COTSSample a_pSample)
+        {
+            
+            if (a_pSample.GetMsrStatus().GetStatus() != OTS_MSR_SAMPLE_STATUS.SUCCESSED)
+            {
+
+                return false;
+            }
+            return true;
+        }
+
+        // error/waring string
+       public String GetSampleErrorWarnString(SAMPLE_FAULT_WARN_CODE a_nSampleFaultWarn)
+        {
+            // switch to dll resource
+         //   AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+            // check input
+            if (a_nSampleFaultWarn < SAMPLE_FAULT_WARN_CODE.MIN && a_nSampleFaultWarn > SAMPLE_FAULT_WARN_CODE.MAX)
+            {
+                
+                return "";
+            }
+            // error/waring string
+            String strErrorWarn;
+            string error = "";
+            strErrorWarn = MultiLang.GetInstance().GetStringByKey(IDS_ERROR_WARNING + (int)a_nSampleFaultWarn,0);
+                //GetStringByKey(IDS_ERROR_WARNING + (int)a_nSampleFaultWarn);
+            return strErrorWarn;
+        }
+
+        // get warning codes list of a sample
+       public void GetSampleWarningCodes(COTSProjMgrFile a_pProjMgrFile, COTSSample a_pSample, List<SAMPLE_FAULT_WARN_CODE> a_listWarningCodes)
+        {
+            
+
+            // check if the file is valid
+            if (!a_pProjMgrFile.IsValid())
+            {
+                // invalid project file 
+               
+                return;
+            }
+
+            // check if the measure domain is cross the sample hole
+            // get the work stage
+            CStage pStage = a_pProjMgrFile.GetStage();
+
+            //get hole
+            String sHoleName = a_pSample.GetSampleHoleName();
+
+            //look for the hole Domain
+            CHole pSampleHole = pStage.GetHoleByName(sHoleName);
+            if (pSampleHole!=null)
+            {
+                // failed to get the sample hole
+               
+                return;
+            }
+
+            //// get the measure domain  2019-05-05 注释测量区域是否超越样品
+            //CDomainPtr pDomain = a_pSample->GetMsrArea();
+            //if (!pSampleHole->DomainInDomain(*pDomain.get()))
+            //{
+            //	//sample measure area has part outside the sample hole
+            //	a_listWarningCodes.push_back(SAMPLE_FAULT_WARN_CODE::AREA_OUTSIDE_HOLE);
+            //}
+
+            // resolution 
+            // can only check this if SEM measure data is set
+            if (!((a_pSample.GetSEMDataMsr()) ==new CSEMDataMsr()))
+            {
+                // compute pixel size
+                double dPixleSize = a_pSample.CalculatePixelSize();
+
+                // get min size
+                COTSImageProcessParam pImageProcParam = a_pSample.GetMsrParams().GetImageProcessParam();
+                double dMinSize = (double)pImageProcParam.GetIncArea().GetStart();
+
+                // if pixel size bigger than 1/2 of the min size, current magnification can't see clear of the object
+                if (dPixleSize >= dMinSize * 0.5)
+                {
+                    // resolution low
+                    a_listWarningCodes.Add(SAMPLE_FAULT_WARN_CODE.RESOLUTION_LOW);
+                }
+            }
+
+        }
     }
 }

+ 259 - 4
OTS/OTSModelSharp/Measure/GetBSEPic/OTSFieldMgr.cs

@@ -749,9 +749,127 @@ namespace OTSModelSharp
             m_listSmallParticles = val;
             m_smallParticlePercentage = percentageOfWhole;
         }
+
+        public  bool GetFeatureList1(List<COTSSegment> a_listSegments, List<COTSFeature> a_listFeatures)
+        {
+            List<COTSSegment> listSegmentNew = new List<COTSSegment>();
+            Dictionary<List<long>, List<COTSSegment>> mapOneLineSegments;
+            foreach(var s in a_listSegments)    
+            {
+                mapOneLineSegments[s.GetHeight()].Add(s);//sorting all the segments base on the line number.
+            }
+            Dictionary<List<long>, List<COTSSegment>> lineItr = mapOneLineSegments.;//find the highest line
+            while (lineItr != mapOneLineSegments.)
+            {
+                for (var s = lineItr.second.begin(); s < lineItr.second.end();)//find  one segment of this line.
+                {
+                    COTSSegment bottomSeg = *s;
+                    listSegmentNew.Clear();
+                    listSegmentNew.Add(s);
+                    s = lineItr.second.erase(s);
+                    Dictionary<List<long>, List<COTSSegment>> tempItr = lineItr;
+                    tempItr++;
+                    for (; tempItr != mapOneLineSegments.end(); tempItr++)//find all other lines of segments
+                    {
+                        if (tempItr.first - bottomSeg.GetHeight() > 1)
+                        {
+                            break;
+                        }
+
+                        for (var nextLineSegment = tempItr.second.begin(); nextLineSegment < tempItr.second.end();)//find next line's all segments
+                        {
+                            if (((*nextLineSegment)->GetStart() - (bottomSeg.GetStart() + bottomSeg.GetLength())) > 1)
+                            {
+                                break;
+                            }
+
+                            if (bottomSeg.UpDownConection(**nextLineSegment))
+                            {
+                                listSegmentNew.Add(*nextLineSegment);
+                                bottomSeg = *nextLineSegment;
+                                nextLineSegment = tempItr.second.erase(nextLineSegment);
+                                break;
+                            }
+
+                            if (tempItr.second.size() > 0)
+                            {
+                                nextLineSegment++;
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
+
+                    }
+                    COTSFeature pFeature = new COTSFeature();
+                    pFeature.SetSegmentsList(listSegmentNew);
+                    //check if this new feature is connected with other found feature.
+                    COTSSegment topSeg = listSegmentNew[0];//find the toppest segment of this new feature.
+                    COTSSegment bottomSegment = listSegmentNew[listSegmentNew.Count - 1];//find the lowest segment of this new feature.
+
+                    bool haveMerged = false;
+                    foreach(var f in a_listFeatures)
+    
+                {
+                        foreach (var seg in f.GetSegmentsList())
+                        {
+                            if (bottomSegment.UpDownConection(seg) || topSeg.UpDownConection(seg))
+                            {
+                                List<COTSSegment> segs = f.GetSegmentsList();
+                                foreach (var s in listSegmentNew)
+                                {
+                                    segs.Add(s);
+
+                                }
+
+                                f.SetSegmentsList(segs);
+                                haveMerged = true;
+                                break;
+                            }
+                        }
+                        if (haveMerged)
+                        {
+                            break;
+                        }
+
+                    }
+                    if (!haveMerged)
+                    {
+                        a_listFeatures.Add(pFeature);
+                    }
+
+                    if (lineItr.second.size() == 0)
+                    {
+                        break;
+                    }
+                }
+                lineItr++;
+            }
+            return true;
+        }
+
+       public bool GetIncAParticleList(List<COTSParticle> a_listParticleOut)
+        {
+           
+
+            List<COTSParticle>  listParticleIn = m_pFieldData.GetParticleList();
+            a_listParticleOut.Clear();
+
+            foreach (var pParticle in listParticleIn)
+            {
+                int nType = pParticle.GetType();
+                if (nType > (int)otsdataconst.OTS_PARTCLE_TYPE.NO_ANALYSIS_X_RAY)
+                {
+                    a_listParticleOut.Add(pParticle);
+                }
+            }
+
+            return true;
+        }
         //--------------------protected--------------------------------
         //get segment list of a image
-       // protected bool GetSegmentList(long a_nWidth,long a_nHeight, byte a_pPixel,List<COTSSegment> a_listSegments)
+        // protected bool GetSegmentList(long a_nWidth,long a_nHeight, byte a_pPixel,List<COTSSegment> a_listSegments)
         //{
         //    if (a_pPixel==null)
         //    {
@@ -808,7 +926,7 @@ namespace OTSModelSharp
 
         //protected bool GetFeatureList1(List<COTSSegment> a_listSegments,List<COTSFeature> a_listFeatures)
         //{
-            
+
         //    return true;
         //}
 
@@ -890,7 +1008,144 @@ namespace OTSModelSharp
         //        buf[i] = val;
         //    }
         //}
-       
-        
+        public bool ChangeFeaturelist(List<COTSFeature> a_listFeatures, List<COTSParticle> a_listParticle)
+        {
+            if (a_listFeatures.Count == 0)
+            {
+                return false;
+            }
+            // compute Rect
+            foreach (var pFeature in a_listFeatures)
+            {
+                COTSParticle pParticle = new COTSParticle();
+                pParticle.SetFeature(pFeature);
+                if (!pParticle.CalCoverRect())
+                {
+
+                    return false;
+                }
+                a_listParticle.Add(pParticle);
+            }
+
+            if ((int)a_listParticle.Count== 0)
+            {
+
+                return false;
+            }
+
+            return true;
+        }
+
+       public bool GetParticles(long a_nWidth, long a_nHeight,  uint a_pPixel, List<COTSParticle> a_listParticles)
+	{
+
+            a_listParticles.Clear();
+
+            List<COTSSegment> listSegment = new List<COTSSegment>();
+            listSegment.Clear();
+
+		//1. get segment line by line	
+		if(!GetSegmentList(a_nWidth, a_nHeight, a_pPixel, listSegment))
+		{
+
+                return false;
+		}
+	
+
+		if ((int) listSegment.Count == 0)
+		{
+
+
+                return false;
+		}
+
+
+            //2. save the temp feature
+            List<COTSFeature> listFeature = new List<COTSFeature>();
+            listFeature.Clear();
+		if (!GetFeatureList1(listSegment, listFeature))
+		{
+
+                return false;
+		}
+
+
+		if ((int) listFeature.Count == 0)
+		{
+
+                return false;
+		}
+
+        List<COTSParticle> listParticles = new List<COTSParticle>();
+        listParticles.Clear();
+		if (!ChangeFeaturelist(listFeature, a_listParticles))
+		{
+
+                return false;
+		}
+
+
+            return true;
+		
+
+	}
+
+       public bool GetSegmentList(long a_nWidth, long a_nHeight,  uint a_pPixel, List<COTSSegment> a_listSegments)
+	   {
+		
+         long nImgSize = a_nWidth * a_nHeight;
+
+            a_listSegments.Clear();
+
+		//1. get segment line by line
+		long nLine, nm, nn;
+        long nStart, nLength;
+		for (nLine = 0; nLine<a_nHeight; nLine++)
+		{
+			for (nm = 0; nm<a_nWidth; nm += (nLength + 1))
+			{
+				nLength = 0;
+				// get start
+				if ((a_pPixel + nLine* a_nWidth + nm) != 0)
+				{
+					nStart = nm;
+					nLength++;
+					//get length
+					for (nn = nm + 1; nn<a_nWidth; nn++)
+					{
+						// check if segment is over, break
+						if (nLength != 0)
+						{
+							if ((a_pPixel + nLine* a_nWidth + nn) == 0)
+								break;
+						}
+
+						if ((a_pPixel + nLine* a_nWidth + nn) != 0)
+						{
+							nLength++;
+						}
+					}
+
+					// generate segment
+					COTSSegment pSegment = new COTSSegment((int)nLine, (int)nStart, (int)nLength);
+                    a_listSegments.Add(pSegment);
+
+				}
+				else
+				{
+					continue;
+				}
+			}
+		}
+
+		if ((int) a_listSegments.Count == 0)
+		{
+
+                return false;
+		}
+
+            return true;
+	}
+
     }
 }

+ 3 - 1
OTS/OTSModelSharp/OTSDataType/COTSImageProcessParam.cs

@@ -55,7 +55,9 @@ public void SetBGRemoveType(OTS_BGREMOVE_TYPE a_oVal) { m_BGRemoveType = a_oVal;
 public OTS_AUTOBGREMOVE_TYPE GetAutoBGRemoveType()  { return  m_autoBGRemoveType; }
 
 		public void SetAutoBGRemoveType(OTS_AUTOBGREMOVE_TYPE a_oVal) { m_autoBGRemoveType = a_oVal; }
-public void Duplicate( COTSImageProcessParam  a_oSource)
+
+       public CDoubleRange GetIncArea()  { return m_oIncArea; }
+    public void Duplicate( COTSImageProcessParam  a_oSource)
 	{
 
         // copy data over

+ 2 - 1
OTS/OTSModelSharp/OTSDataType/MultiLang.cs

@@ -73,7 +73,8 @@ namespace OTSDataType
                 xml.Load(".\\Resources\\XMLData\\ResourceForCpp-ZH.xml");
             }
             XmlDocument xml1 = new XmlDocument();
-            XmlNode root3 = xml1.SelectSingleNode("collection");
+            XmlNode root5 = xml1.SelectSingleNode("XMLData");
+            XmlNode root3 = root5.SelectSingleNode("collection");
             XmlNode root4 = root3.SelectSingleNode("member");
             XmlNodeList childlist = root2.ChildNodes;
             for (int i = 0; i < childlist.Count; i++)

+ 4 - 0
OTS/OTSModelSharp/OTSModelSharp.csproj

@@ -87,6 +87,8 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ARACrypt.cs" />
+    <Compile Include="COTSEDSBrucker.cs" />
+    <Compile Include="COTSHardwareMgr.cs" />
     <Compile Include="CProjMgr.cs" />
     <Compile Include="CSmallParticleInfo.cs" />
     <Compile Include="CStdioFile.cs" />
@@ -195,6 +197,7 @@
     <Compile Include="OTSDataType\SEMStageData.cs" />
     <Compile Include="OTSDataType\stage.cs" />
     <Compile Include="OTSDataType\XMLSerialization.cs" />
+    <Compile Include="OTSEDSBase.cs" />
     <Compile Include="OTSFileSys.cs" />
     <Compile Include="OTSLicMgr.cs" />
     <Compile Include="OTSModelresource.cs" />
@@ -203,6 +206,7 @@
     <Compile Include="MeasureControl\IMeasureHardware.cs" />
     <Compile Include="MeasureControl\MeasureHardware.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="SEMCommonConst.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Measure\GetParam\DIALOG_CHECK_PARAM_RESULT.resx">