瀏覽代碼

improve the RemoveDuplicateOverlapParticles algorithm

gsp 1 年之前
父節點
當前提交
3c73dafd6d

+ 25 - 16
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

@@ -197,9 +197,9 @@ namespace OTSDataType
             if (m_pBSEImg == null)
                 return;
             CImageHandler imghandler = new CImageHandler();
-            List<COTSParticleClr> xrayParts = new List<COTSParticleClr>();
-            imghandler.RemoveBGAndGetParts(this, a_pImageProcessParam, ref xrayParts);
-            foreach (var p in xrayParts)
+            List<COTSParticleClr> allParts = new List<COTSParticleClr>();
+            imghandler.RemoveBGAndGetParts(this, a_pImageProcessParam, ref allParts);
+            foreach (var p in allParts)
             {
                 p.SetIsXrayParticle(ifXray);
                 m_listAllParticles.Add(p);
@@ -213,7 +213,9 @@ namespace OTSDataType
             List<COTSParticleClr> finalparts = new List<COTSParticleClr>();
             if (leftField != null && leftField.measureSequence < this.measureSequence)
             {
-                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.LEFT, overlap))
+                var leftparts = this.GetSideParticlesByOverlap(SORTING_DIRECTION.LEFT, overlap);
+                log.Info("left side particles num:" + leftparts.Count.ToString());
+                foreach (var p in leftparts )
                 {
                     int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
                     p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
@@ -256,7 +258,9 @@ namespace OTSDataType
             }
             if (upField != null && upField.measureSequence < this.measureSequence)
             {
-                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap))
+                var upparts = this.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap);
+                log.Info("up side particles num:" + upparts.Count.ToString());
+                foreach (var p in upparts)
                 {
                     int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
                     p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
@@ -299,7 +303,9 @@ namespace OTSDataType
             }
             if (rightField != null && rightField.measureSequence < this.measureSequence)
             {
-                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.RIGHT, overlap))
+                var rightparts = this.GetSideParticlesByOverlap(SORTING_DIRECTION.RIGHT, overlap);
+                log.Info("right side particles num:" + rightparts.Count.ToString());
+                foreach (var p in rightparts)
                 {
                     int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
                     p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
@@ -342,7 +348,9 @@ namespace OTSDataType
             }
             if (downField != null && downField.measureSequence < this.measureSequence)
             {
-                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.DOWN, overlap))
+                var downparts = this.GetSideParticlesByOverlap(SORTING_DIRECTION.DOWN, overlap);
+                log.Info("down side particles num:" + downparts.Count.ToString());
+                foreach (var p in downparts)
                 {
                     int pleft = 0, pright = 0, ptop = 0, pbottom = 0;
                     p.GetOTSRect(ref pleft, ref ptop, ref pright, ref pbottom);
@@ -400,9 +408,10 @@ namespace OTSDataType
                 {
                     int left = 0, top = 0, right = 0, bottom = 0;
                     p.GetOTSRect(ref left, ref top, ref right, ref bottom);
+
                     if ((right - this.GetOTSRect().GetTopLeft().X) < 2 * overlap)
                     {
-                        if (left != this.GetOTSRect().GetTopLeft().X)//not on the border
+                        if (left != this.GetOTSRect().GetTopLeft().X || Math.Abs(left-right)>2*overlap )//not on the border or it's a big particle
                         {
                             sideparts.Add(p);
                         }
@@ -420,7 +429,7 @@ namespace OTSDataType
                     p.GetOTSRect(ref left, ref top, ref right, ref bottom);
                     if ((this.GetOTSRect().GetBottomRight().X-left) < 2 * overlap)
                     {
-                        if (right != this.GetOTSRect().GetBottomRight().X)//not on the border
+                        if (right != this.GetOTSRect().GetBottomRight().X || Math.Abs(left - right) > 2 * overlap)//not on the border
                         {
                             sideparts.Add(p);
                         }
@@ -437,7 +446,7 @@ namespace OTSDataType
                     p.GetOTSRect(ref left, ref top, ref right, ref bottom);
                     if ((this.GetOTSRect().GetTopLeft().Y - bottom) < 2 * overlap)
                     {
-                        if (top != this.GetOTSRect().GetTopLeft().Y)//not on the border
+                        if (top != this.GetOTSRect().GetTopLeft().Y || Math.Abs(top - bottom) > 2 * overlap)//not on the border
                         {
                             sideparts.Add(p);
                         }
@@ -454,7 +463,7 @@ namespace OTSDataType
                     p.GetOTSRect(ref left, ref top, ref right, ref bottom);
                     if ((top-this.GetOTSRect().GetBottomRight().Y ) < 2 * overlap)
                     {
-                        if (bottom != this.GetOTSRect().GetBottomRight().Y)//not on the border
+                        if (bottom != this.GetOTSRect().GetBottomRight().Y || Math.Abs(top - bottom) > 2 * overlap)//not on the border
                         {
                             sideparts.Add(p);
                         }
@@ -512,17 +521,17 @@ namespace OTSDataType
             return true;
         }
      
-        public void InitParticles(COTSImageProcParam a_pImageProcessParam,double a_dPixelSize)
+        public void InitParticles(COTSImageProcParam a_pImageProcessParam)
         {
-            m_listAnalysisParticles = new List<COTSParticleClr>();
+          
             // get area range
             CDoubleRange oAreaRange = a_pImageProcessParam.GetIncAreaRange();
             double rMin = oAreaRange.GetStart() / 2.0;
             double rMax = oAreaRange.GetEnd() / 2.0;
-  
+
             int nTagId = 0;
        
-            foreach (COTSParticleClr pParticle in m_listAllParticles)//m_listAllParticles memorize all the particles .
+            foreach (COTSParticleClr pParticle in m_listAnalysisParticles)//m_listAllParticles memorize all the particles .
             {
                
                 pParticle.SetParticleId(nTagId);//give all the conforming particles a unified sequence no.
@@ -537,7 +546,7 @@ namespace OTSDataType
                
                
             }
-            log.Info("Total Particles: (>" + oAreaRange.GetStart().ToString("f2") + "): "+ "<" + oAreaRange.GetEnd().ToString("f2") + "): " + m_listAllParticles.Count);
+            log.Info("Total Particles: (>" + rMin.ToString("f2") + "): "+ "<" + rMax.ToString("f2") + "): " + m_listAllParticles.Count);
            
 
      

+ 14 - 6
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -834,15 +834,24 @@ namespace OTSModelSharp
             GetOriginalParticles(ref curFldData);
 
             log.Info("Begin to Calculate the image property of every particle!");
-            var analysisparts = curFldData.GetListAnalysisParticles();
+            var analysisparts = curFldData.GetAllParticles();
             curFldData.CalParticleImageProp(analysisparts);//calculate particle image property such as feret diameter, DMAX etc.
             CSampleParam pMsrParam = m_Sample.GetMsrParams();
             COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
-            curFldData.RemoveDuplicateOverlapParticles(pImgProcessParam.GetOverlapParam());
+            var overlap = pImgProcessParam.GetOverlapParam();
+            if (overlap > 0)
+            {
+                curFldData.RemoveDuplicateOverlapParticles(overlap);
+            }
+           
             log.Info("Begin to filter particles!");
-            FilterParticles(ref curFldData);
+
+            FilterParticles(ref curFldData);//filter according to the xraylimit
 
             CalculateParticleAbsolutPos(ref curFldData);
+           
+            curFldData.InitParticles(pImgProcessParam);
+
             return ;
 
         }
@@ -850,7 +859,7 @@ namespace OTSModelSharp
         private void FilterParticles(ref COTSField curFldData)
         {
           
-            var listXray = curFldData.GetAllParticles().OrderByDescending(x => x.GetActualArea()).ToList();
+            var listXray = curFldData.GetListAnalysisParticles().OrderByDescending(x => x.GetActualArea()).ToList();
             var listXray1 = new List<COTSParticleClr>();
             var pXRayParam =m_Sample.GetMsrParams().GetXRayParam();
             if (listXray.Count > pXRayParam.GetXrayLimit())
@@ -905,8 +914,7 @@ namespace OTSModelSharp
             }
 
           
-            double dPixelSize = m_Sample.CalculatePixelSize();
-            curFldData.InitParticles(pImgProcessParam, dPixelSize);
+           
             return;
         }
        

+ 195 - 224
OTSIncAMeasureApp/1-OTSMeasure/Measure/ParamData/COTSMsrPrjResultData.cs

@@ -1,17 +1,14 @@
-using OTSDataType;
+using OTSCLRINTERFACE;
+using OTSDataType;
 using OTSModelSharp.ServiceCenter;
-
 using System;
 using System.Collections.Generic;
+using System.Data;
 using System.Drawing;
 using System.IO;
-
 using System.Windows.Forms;
-using static OTSDataType.otsdataconst;
 using System.Xml;
-using OTSCLRINTERFACE;
-
-using System.Data;
+using static OTSDataType.otsdataconst;
 
 namespace OTSModelSharp
 {
@@ -43,7 +40,7 @@ namespace OTSModelSharp
 
         const String UNTITLED_FILE_NAME = "Untitled";
 
- 
+
         const String SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER = "FIELD_FILES";
 
         // Inclusion file name
@@ -73,14 +70,14 @@ namespace OTSModelSharp
 
         }
 
-      
+
 
         public void SetPathName(String a_strPathName) { m_strPathName = a_strPathName; }
 
         public bool Load(string strPathName)
         {
 
-           
+
             Cleanup();
 
             // check if the file exist 
@@ -93,54 +90,38 @@ namespace OTSModelSharp
             //获取测量项目文件
             XmlDocument doc = new XmlDocument();
             //载入xml文件
-            doc.Load(strPathName); 
+            doc.Load(strPathName);
             XmlNode root = doc.SelectSingleNode("XMLData");
             Serialize(false, doc, root);
 
             //设置测量项目文件路径
-            m_strPathName = strPathName;
+            SetPathName(strPathName);
+           
             //-------------
             foreach (var smpl in m_listSamples)
             {
                 // get path of the pathname
-                String strFilePath = GetFolderName(strPathName);
-                if (strFilePath == "")
-                {
-                    // file path string is an empty string 
-                    return false;
-                }
-
-                // field file sub folder string
-                String strFieldFileSubFolder = strFilePath + "\\" + smpl.GetName() + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER + "\\";
-
-                // check if the field file sub folder exists
-                if (!DirectoryExists(strFieldFileSubFolder))
-                {// field files folder doesn't exist
-
-                    continue;
-                }
+                
 
-                String strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
-              
                 List<COTSField> allMeasuredFlds = new List<COTSField>();
                 CMsrSampleStatus poMsrStatus = new CMsrSampleStatus();
-               
+
                 CMsrResultItems poMsrResults = smpl.GetMsrResults();
                 double aFldArea = smpl.CalculateAFieldArea();
-                SetPathName(strIncAFilename);
+               
 
                 int w, h;
                 smpl.GetBSESize(out w, out h);
                 double pixelsize = smpl.CalculatePixelSize();
-                var overlap=smpl.GetMsrParams().GetImageProcessParam().GetOverlapParam();
+                var overlap = smpl.GetMsrParams().GetImageProcessParam().GetOverlapParam();
+
+                var noParticledataFields = smpl.GetFieldsData();//there's only the field postion info in the xml file,so the initial filed has only postion info.
+                List<COTSField> allflddata = new List<COTSField>();//contains all the field 
 
-                if (GetAllFieldsFromDB(ref allMeasuredFlds,ref poMsrStatus, poMsrResults, aFldArea,new Size(w,h),pixelsize))
+                if (GetAllFieldsFromDB(ref allMeasuredFlds, ref poMsrStatus,smpl.GetName(), poMsrResults, aFldArea, new Size(w, h), pixelsize))
                 {
-                  
-                    var nodataFields = smpl.GetFieldsData();//there's only the field postion info in the xml file,so the initial filed has only postion info.
-                    List<COTSField> allflddata = new List<COTSField>() ;//contains all the field 
                     //------------complete the infomation that doesn't contain in database-----
-                   
+
                     foreach (var f in allMeasuredFlds)
                     {
                         f.SetPixelSize(pixelsize);
@@ -149,79 +130,58 @@ namespace OTSModelSharp
                         double effectiveWidth = f.ImgWidth * pixelsize - 2 * overlap;
                         double effectiveHeight = f.ImgHeight * pixelsize - 2 * overlap;
                         PointF fldPos = f.GetOTSPosition();
-                        Point lt = new Point((int)fldPos.X - (int)effectiveWidth / 2,(int)fldPos.Y-(int)effectiveHeight /2);
+                        Point lt = new Point((int)fldPos.X - (int)effectiveWidth / 2, (int)fldPos.Y - (int)effectiveHeight / 2);
                         Point rb = new Point((int)fldPos.X + (int)effectiveWidth / 2, (int)fldPos.Y + (int)effectiveHeight / 2);
                         f.SetOTSRect(new OTSMeasureApp._0_OTSModel.OTSDataType.COTSRect(lt, rb));
                         f.SetIsMeasureComplete(true);
 
                     }
-                  //------------------------------
-                    foreach (var emptyfld in nodataFields)
+                }
+                //------------------------------
+                foreach (var emptyfld in noParticledataFields)
+                {
+                    bool isMeasured = false;
+                    foreach (var measuredField in allMeasuredFlds)
                     {
-                        bool isMeasured = false;
-                        foreach (var measuredField in allMeasuredFlds)
+                        if (measuredField.PositionEquals(emptyfld))
                         {
-                            if (measuredField.PositionEquals(emptyfld))
-                            {
-                               
-                                allflddata.Add(measuredField);
-                                isMeasured = true;
-                                break;
-                            }
-                        
-                        }
-                        if (!isMeasured)
-                        {
-                            emptyfld.SetPixelSize(pixelsize);
-                            emptyfld.ImgWidth = w;
-                            emptyfld.ImgHeight = h;
-                            double effectiveWidth = emptyfld.ImgWidth * pixelsize - 2 * overlap;
-                            double effectiveHeight = emptyfld.ImgHeight * pixelsize - 2 * overlap;
-                            PointF fldPos = emptyfld.GetOTSPosition();
-                            Point lt = new Point((int)fldPos.X - (int)effectiveWidth / 2, (int)fldPos.Y - (int)effectiveHeight / 2);
-                            Point rb = new Point((int)fldPos.X + (int)effectiveWidth / 2, (int)fldPos.Y + (int)effectiveHeight / 2);
-                            emptyfld.SetOTSRect(new OTSMeasureApp._0_OTSModel.OTSDataType.COTSRect(lt, rb));
-                            emptyfld.SetIsMeasureComplete(false);
-
-                            allflddata.Add(emptyfld);
-                        }
-
-
-                    }
-                    smpl.SetFieldsData(allflddata);
-                    // file validation
-                    smpl.SetMsrStatus(poMsrStatus);
-                    smpl.SetMsrResults(poMsrResults);
-
-                
 
-                    // set pathname
-                    SetPathName(strPathName);
+                            allflddata.Add(measuredField);
+                            isMeasured = true;
+                            break;
+                        }
 
-                    // set working sample
-                    if (m_listSamples.Count > 0)
-                    {
-                        m_nWorkingSampeIndex = 0;
                     }
-                    else
+                    if (!isMeasured)
                     {
-                        m_nWorkingSampeIndex = -1;
+                        emptyfld.SetPixelSize(pixelsize);
+                        emptyfld.ImgWidth = w;
+                        emptyfld.ImgHeight = h;
+                        double effectiveWidth = emptyfld.ImgWidth * pixelsize - 2 * overlap;
+                        double effectiveHeight = emptyfld.ImgHeight * pixelsize - 2 * overlap;
+                        PointF fldPos = emptyfld.GetOTSPosition();
+                        Point lt = new Point((int)fldPos.X - (int)effectiveWidth / 2, (int)fldPos.Y - (int)effectiveHeight / 2);
+                        Point rb = new Point((int)fldPos.X + (int)effectiveWidth / 2, (int)fldPos.Y + (int)effectiveHeight / 2);
+                        emptyfld.SetOTSRect(new OTSMeasureApp._0_OTSModel.OTSDataType.COTSRect(lt, rb));
+                        emptyfld.SetIsMeasureComplete(false);
+
+                        allflddata.Add(emptyfld);
                     }
 
 
                 }
-                else
-                {
-                    return false;
-                }
+                smpl.SetFieldsData(allflddata);
+                // file validation
+                smpl.SetMsrStatus(poMsrStatus);
+                smpl.SetMsrResults(poMsrResults);
+
             }
-            if (m_listSamples != null)
+
+            if (m_listSamples.Count > 0)
             {
-                if (m_listSamples.Count > 0)
-                {
-                    m_nWorkingSampeIndex = 0;
-                }
+                m_nWorkingSampeIndex = 0;
             }
+
             //-----------------------------------------
             return true;
 
@@ -265,23 +225,34 @@ namespace OTSModelSharp
         // file pathname
         public String GetPathName() { return m_strPathName; }
 
-        public bool GetAllFieldsFromDB(ref List<COTSField> allFlds, ref CMsrSampleStatus status, CMsrResultItems rst, double aFieldArea,Size picSize,double pixelSize)
+        public bool GetAllFieldsFromDB(ref List<COTSField> allFlds, ref CMsrSampleStatus status,string sampleName, CMsrResultItems rst, double aFieldArea, Size picSize, double pixelSize)
         {
-            String sDatabaseName = m_strPathName;
+          
+            String strFilePath = GetFolderName(m_strPathName);
+            if (strFilePath == "")
+            {
+                // file path string is an empty string 
+                return false;
+            }
 
-            if (!FileExists(sDatabaseName))
+            // field file sub folder string
+            String strFieldFileSubFolder = strFilePath + "\\" + sampleName + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER + "\\";
+
+
+            String strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
+            if (!FileExists(strIncAFilename))
             {
                 return false;
 
             }
             List<System.Drawing.PointF> completedFldPositions = new List<System.Drawing.PointF>();
-            CIncAFileMgr incAFileMgr = new CIncAFileMgr(sDatabaseName);
+            CIncAFileMgr incAFileMgr = new CIncAFileMgr(strIncAFilename);
             var m_IncADataDB = incAFileMgr.GetIncADB();
-            List<COTSField> allFldsWithdata=new List<COTSField>();
-            m_IncADataDB.GetAllFieldsRecord(pixelSize,ref allFldsWithdata);
+            List<COTSField> allFldsWithdata = new List<COTSField>();
+            m_IncADataDB.GetAllFieldsRecord(pixelSize, ref allFldsWithdata);
 
             var eleChemistryDB = incAFileMgr.GetPosXrayDBMgr().GetElementChemistryDB();
-             Dictionary<string, CPosXrayClr> mapXrayInfo=new Dictionary<string, CPosXrayClr>();
+            Dictionary<string, CPosXrayClr> mapXrayInfo = new Dictionary<string, CPosXrayClr>();
             eleChemistryDB.GetAllMapedXrayInfo(ref mapXrayInfo);
             foreach (var f in allFldsWithdata)
             {
@@ -289,15 +260,15 @@ namespace OTSModelSharp
                 {
                     int curFldId = f.GetId();
                     int xrayId = p.GetAnalysisId();
-                    string fldvec="";
-                    fldvec+=curFldId.ToString();
-                    fldvec+="_";
+                    string fldvec = "";
+                    fldvec += curFldId.ToString();
+                    fldvec += "_";
                     fldvec += xrayId.ToString();
-                    
+
                     if (mapXrayInfo.ContainsKey(fldvec))
                     {
                         var xray = mapXrayInfo[fldvec];
-                     
+
                         p.SetXray(xray);
                     }
                 }
@@ -305,7 +276,7 @@ namespace OTSModelSharp
 
 
             var xrayDataDBDB = incAFileMgr.GetPosXrayDBMgr().GetXrayDataDB();
-            Dictionary<string, CPosXrayClr> mapXrayData=new Dictionary<string, CPosXrayClr>();// map structure:[(fieldId,xrayId),CPosXrayPtr],every element of this map represent one unique xraydata.
+            Dictionary<string, CPosXrayClr> mapXrayData = new Dictionary<string, CPosXrayClr>();// map structure:[(fieldId,xrayId),CPosXrayPtr],every element of this map represent one unique xraydata.
             xrayDataDBDB.GetAllMapedXrayData(ref mapXrayData);
             foreach (var f in allFldsWithdata)
             {
@@ -313,18 +284,18 @@ namespace OTSModelSharp
                 {
                     int curFldId = f.GetId();
                     int xrayId = p.GetAnalysisId();
-                    string fldvec="";
-                    fldvec+=curFldId.ToString();
+                    string fldvec = "";
+                    fldvec += curFldId.ToString();
                     fldvec += "_";
                     fldvec += xrayId.ToString();
-                  
+
                     if (mapXrayData.ContainsKey(fldvec))
                     {
                         var xray = mapXrayData[fldvec];
                         CPosXrayClr t2 = p.GetXray();
                         if (t2 == null)
                         {
-                            t2 =new CPosXrayClr();
+                            t2 = new CPosXrayClr();
                             p.SetXray(t2);
                         }
                         t2.SetXrayData(xray.GetXrayData());
@@ -336,13 +307,13 @@ namespace OTSModelSharp
 
             CSegmentDB SegmentDB = incAFileMgr.GetSegmentDB();
             double msrFldsArea = 0;
-           Dictionary<int, List<COTSParticleClr>> mapTypeParticles = new Dictionary<int,List<COTSParticleClr>>();//record typeId relevants particlelist;
+            Dictionary<int, List<COTSParticleClr>> mapTypeParticles = new Dictionary<int, List<COTSParticleClr>>();//record typeId relevants particlelist;
 
-            List<COTSSegmentClr> AllSegments ;
+            List<COTSSegmentClr> AllSegments;
             Dictionary<string, List<COTSSegmentClr>> mapSegments = new Dictionary<string, List<COTSSegmentClr>>();
             if (SegmentDB.GetAllSegmentsRecord(mapSegments))
             {
-               
+
                 foreach (var fld in allFldsWithdata)
                 {
                     int fldId = fld.GetId();
@@ -350,140 +321,140 @@ namespace OTSModelSharp
                     foreach (var part in parts)
                     {
                         string fldvec = "";
-                        fldvec+=fldId.ToString();
+                        fldvec += fldId.ToString();
                         fldvec += "_";
-                        fldvec+=part.GetParticleId().ToString();
+                        fldvec += part.GetParticleId().ToString();
+
 
-                       
                         if (mapSegments.ContainsKey(fldvec))
                         {
                             COTSFeatureClr f = new COTSFeatureClr();
                             AllSegments = mapSegments[fldvec];
                             f.SetSegmentsList(AllSegments, true);
                             part.SetFeature(f);
-                         
+
                             if (mapTypeParticles.ContainsKey(part.GetType()))
                             {
                                 mapTypeParticles[part.GetType()].Add(part);
                             }
-                            else 
+                            else
                             {
                                 List<COTSParticleClr> ps = new List<COTSParticleClr>();
                                 ps.Add(part);
                                 mapTypeParticles.Add(part.GetType(), ps);
                             }
-                           
+
                         }
-                       
+
                         msrFldsArea += aFieldArea;
                     }
-                
+
 
 
                 }
             }
 
             var fielddb = incAFileMgr.GetFieldDB();
-                var fielddata = fielddb.GetTableQueryForDataTable();
+            var fielddata = fielddb.GetTableQueryForDataTable();
 
-                foreach (DataRow r in fielddata.Rows)
-                {
-                    var p = new Point(Convert.ToInt32(r[(int)CFieldTable.ColumnID.N_FIELDPOS_X]), Convert.ToInt32(r[(int)CFieldTable.ColumnID.N_FIELDPOS_Y]));
-                    completedFldPositions.Add(p);
-                }
+            foreach (DataRow r in fielddata.Rows)
+            {
+                var p = new Point(Convert.ToInt32(r[(int)CFieldTable.ColumnID.N_FIELDPOS_X]), Convert.ToInt32(r[(int)CFieldTable.ColumnID.N_FIELDPOS_Y]));
+                completedFldPositions.Add(p);
+            }
 
-                status.SetCompletedFieldsCenter(completedFldPositions);
+            status.SetCompletedFieldsCenter(completedFldPositions);
 
 
             //add the empty field(there's no any particle in the bse image,so the field is empty)
             foreach (var p in completedFldPositions)
             {
-                bool haveData=false;
-                var emptyFld = new COTSField(p,pixelSize);
+                bool haveData = false;
+                var emptyFld = new COTSField(p, pixelSize);
                 emptyFld.SetOTSPosition(p);
                 foreach (var fld in allFldsWithdata)
                 {
-                    
+
                     if (fld.PositionEquals(emptyFld))
                     {
                         haveData = true;
                         allFlds.Add(fld);
                         break;
                     }
-                
+
                 }
                 if (!haveData)
                 {
                     allFlds.Add(emptyFld);
                 }
-            
-            
+
+
             }
 
-                // get MsrStatus info from DB.
-                var m_GenInfoDB = incAFileMgr.GetGeneralInfoDB();//DBStoreFile类
-                String strTimeStart = "";
-                String strTimeEnd = "";
-                String strRstStatus = "";
+            // get MsrStatus info from DB.
+            var m_GenInfoDB = incAFileMgr.GetGeneralInfoDB();//DBStoreFile类
+            String strTimeStart = "";
+            String strTimeEnd = "";
+            String strRstStatus = "";
 
-                m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeStart(), ref strTimeStart);
-                m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeEnd(), ref strTimeEnd);
-                m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameResultStatus(), ref strRstStatus);
-               
-              
+            m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeStart(), ref strTimeStart);
+            m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeEnd(), ref strTimeEnd);
+            m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameResultStatus(), ref strRstStatus);
 
-                DateTime timeStart, timeEnd;
-                try
-                {
-                    timeStart = Convert.ToDateTime(ConvertFormatOfDateString(strTimeStart)); //此处为兼容之前得测量得结果可以打开,故在此进行数据格式变换
-                    timeEnd = Convert.ToDateTime(ConvertFormatOfDateString(strTimeEnd));
-                }
-                catch
-                {
-                    timeStart = Convert.ToDateTime(strTimeStart); //此处为兼容之前得测量得结果可以打开,故在此进行数据格式变换
-                    timeEnd = Convert.ToDateTime(strTimeEnd);
-                }
-                status.SetStartTime(timeStart);
-                status.SetEndTime(timeEnd);
-                status.SetUsedTime(timeEnd - timeStart);
-                status.SetStatus((OTS_MSR_SAMPLE_STATUS)Convert.ToInt32(strRstStatus));
-
-                //get MsrResults data from map.
-                List<CMsrResultItem> rstItms = new List<CMsrResultItem>();
-                double allPartArea = 0;
-                int typeNum;
-                double typeArea = 0;
-                foreach (var typeParticles in mapTypeParticles)
+
+
+            DateTime timeStart, timeEnd;
+            try
+            {
+                timeStart = Convert.ToDateTime(ConvertFormatOfDateString(strTimeStart)); //此处为兼容之前得测量得结果可以打开,故在此进行数据格式变换
+                timeEnd = Convert.ToDateTime(ConvertFormatOfDateString(strTimeEnd));
+            }
+            catch
+            {
+                timeStart = Convert.ToDateTime(strTimeStart); //此处为兼容之前得测量得结果可以打开,故在此进行数据格式变换
+                timeEnd = Convert.ToDateTime(strTimeEnd);
+            }
+            status.SetStartTime(timeStart);
+            status.SetEndTime(timeEnd);
+            status.SetUsedTime(timeEnd - timeStart);
+            status.SetStatus((OTS_MSR_SAMPLE_STATUS)Convert.ToInt32(strRstStatus));
+
+            //get MsrResults data from map.
+            List<CMsrResultItem> rstItms = new List<CMsrResultItem>();
+            double allPartArea = 0;
+            int typeNum;
+            double typeArea = 0;
+            foreach (var typeParticles in mapTypeParticles)
+            {
+                typeNum = 0;
+                CMsrResultItem rstItm = new CMsrResultItem();
+                foreach (var p in typeParticles.Value)
                 {
-                    typeNum = 0;
-                    CMsrResultItem rstItm = new CMsrResultItem();
-                    foreach (var p in typeParticles.Value)
-                    {
-                        typeNum += 1;
-                        typeArea +=p.GetActualArea();
-                    }
-                    rstItm.SetTypeId(typeParticles.Key);
-                    rstItm.SetNumber((uint)typeNum);
-                    rstItm.SetArea((uint)typeArea);
-                    rstItm.SetName(typeParticles.Value[0].GetTypeName());
-                    rstItms.Add(rstItm);
-                    allPartArea += typeArea;
+                    typeNum += 1;
+                    typeArea += p.GetActualArea();
                 }
-                rst.SetResultItems(rstItms);
-                rst.SetMeasuredArea(Convert.ToUInt64(msrFldsArea * 1000000));
-                rst.SetRatio(allPartArea / (msrFldsArea * 1000000));
-                return true;
-            
+                rstItm.SetTypeId(typeParticles.Key);
+                rstItm.SetNumber((uint)typeNum);
+                rstItm.SetArea((uint)typeArea);
+                rstItm.SetName(typeParticles.Value[0].GetTypeName());
+                rstItms.Add(rstItm);
+                allPartArea += typeArea;
+            }
+            rst.SetResultItems(rstItms);
+            rst.SetMeasuredArea(Convert.ToUInt64(msrFldsArea * 1000000));
+            rst.SetRatio(allPartArea / (msrFldsArea * 1000000));
+            return true;
+
             //return false;
         }
 
         string ConvertFormatOfDateString(string Time)
         {
-            
+
             string[] str1 = Time.Split(' ');
-           
+
             string[] str2 = str1[0].Split('/');
-            return str2[2] + "/" + str2[1] + "/" + str2[0] +" "+ str1[1];
+            return str2[2] + "/" + str2[1] + "/" + str2[0] + " " + str1[1];
         }
         public string GetSampleWorkingFolder(string sampleName)
         {
@@ -497,7 +468,7 @@ namespace OTSModelSharp
             // Save or Save As, if strPathName is not empty, it is exist in the computer, this is a save action
             String strPathName = GetPathName();
 
-            
+
             if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0)
             {
                 // this is a new file 
@@ -542,7 +513,7 @@ namespace OTSModelSharp
             SaveFileDialog saveFileDialog = new SaveFileDialog();
             saveFileDialog.FileName = m_strPathName.Split('\\')[m_strPathName.Split('\\').Length - 1];
             saveFileDialog.Filter = "Directory (*.*)|*.*";
-            saveFileDialog.AddExtension=false;
+            saveFileDialog.AddExtension = false;
             if (saveFileDialog.ShowDialog() != DialogResult.OK)
             {
                 return false;
@@ -560,7 +531,7 @@ namespace OTSModelSharp
                 MessageBox.Show("CreateDirectoryFailed!");
                 return false;
             }
-            strPathName += "\\"+Path.GetFileNameWithoutExtension(strPathName) + ".prj";
+            strPathName += "\\" + Path.GetFileNameWithoutExtension(strPathName) + ".prj";
             //保存测量项目文件 .prj
             XmlDocument doc = new XmlDocument();
             //添加xml文件头申明
@@ -609,7 +580,7 @@ namespace OTSModelSharp
         // samples list
         public List<COTSSample> GetSampleList() { return m_listSamples; }
 
- 
+
 
         public COTSSample GetSampleByIndex(int a_nIndex)
         {
@@ -1036,11 +1007,11 @@ namespace OTSModelSharp
 
         public COTSSample GetWorkingSample()
         {
-         
+
             return GetSampleByIndex(m_nWorkingSampeIndex);
         }
 
-  
+
 
         public bool SetWorkingSampleByIndex(int a_nIndex)
         {
@@ -1121,7 +1092,7 @@ namespace OTSModelSharp
 
             m_listHoleBSEImg = a_listHoleBSEImg;
 
-           
+
         }
 
         // get modify flag
@@ -1160,22 +1131,22 @@ namespace OTSModelSharp
         {
             foreach (var pSample in m_listSamples)
             {
-               
+
 
                 String sSampleName = pSample.GetName();
                 if (a_sName.Equals(sSampleName))
                 {
-                    
 
-                        return false;
-                   
+
+                    return false;
+
                 }
             }
 
             return true;
         }
 
-      
+
 
         static String FindFile(String filename, String path)
         {
@@ -1194,7 +1165,7 @@ namespace OTSModelSharp
             return null;
         }
 
-       
+
 
         // get measured sample list
         public bool GetMsredSampleList(ref List<COTSSample> a_listMsredSample)
@@ -1227,10 +1198,10 @@ namespace OTSModelSharp
             // reset measurement area 
             // measurement area should smaller than the sample hole
             RectangleF rectMsrArea = pMsrArea.GetDomainRect();
-            float  nWidth = rectMsrArea.Width;
-            float  nHeight = rectMsrArea.Height;
-            float  nDeflateX = CalculateDeflateValue(nWidth);
-            float  nDeflateY = CalculateDeflateValue(nHeight);
+            float nWidth = rectMsrArea.Width;
+            float nHeight = rectMsrArea.Height;
+            float nDeflateX = CalculateDeflateValue(nWidth);
+            float nDeflateY = CalculateDeflateValue(nHeight);
             rectMsrArea.Offset(nDeflateX, nDeflateY);
             pMsrArea.SetDomainRect(rectMsrArea);
 
@@ -1239,7 +1210,7 @@ namespace OTSModelSharp
         }
 
         // calculate deflate value
-        public float  CalculateDeflateValue(float  a_nWitchOrHeight)
+        public float CalculateDeflateValue(float a_nWitchOrHeight)
         {
             const long LENGTH_THRESHOLD = 150000;
             const long LENGTH_THRESHOLD_MIN = 10000;
@@ -1267,9 +1238,9 @@ namespace OTSModelSharp
 
         public bool Reclassify()
         {
-            
+
             string strFilePath = FileHelper.GetFolderName(m_strPathName);
-            if(strFilePath==null)
+            if (strFilePath == null)
             {
                 return false;
             }
@@ -1286,33 +1257,33 @@ namespace OTSModelSharp
                 }
 
                 string filename = strFilePath + "\\" + spl.GetName() + "\\" + spl.GetName() + ".rst";
-               
-                XmlDocument doc=new XmlDocument();
+
+                XmlDocument doc = new XmlDocument();
                 doc.Load(filename);
 
-                XmlNode  root = doc.SelectSingleNode("XMLData");
-               var members = root.SelectNodes("Member");
+                XmlNode root = doc.SelectSingleNode("XMLData");
+                var members = root.SelectNodes("Member");
                 foreach (XmlNode member1 in members)
                 {
-                    if(member1.Attributes["RegName"].Value== "Sample")
+                    if (member1.Attributes["RegName"].Value == "Sample")
                     {
                         var paramNode = member1.SelectNodes("Member");
                         foreach (XmlNode member2 in paramNode)
                         {
-                            if(member2.Attributes["RegName"].Value == "MsrParams")
+                            if (member2.Attributes["RegName"].Value == "MsrParams")
                             {
                                 ((XmlElement)member2).SetAttribute("STDName", stdFileName);
                             }
                         }
                     }
                 }
-                
-                doc.Save(filename);
+
+                doc.Save(filename);//save the new std db name
                 foreach (var fld in spl.GetFieldsData())
                 {
                     foreach (var part in fld.GetListAnalysisParticles())
                     {
-                        
+
                         part.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED);
                         part.SetTypeName("Not Identified");
                         part.SetTypeColor("#000000");
@@ -1336,7 +1307,7 @@ namespace OTSModelSharp
                                     if (IsLowCounts(part))
                                     {
                                         continue;
-                                    
+
                                     }
                                     if (!partEngine.ClassifyByExpression(part))
                                     {
@@ -1454,7 +1425,7 @@ namespace OTSModelSharp
                     }
                     catch (Exception ex)
                     {
-                        MessageBox.Show(stdFileName+" copy failed:" + ex.ToString());
+                        MessageBox.Show(stdFileName + " copy failed:" + ex.ToString());
                         return false;
                     }
                 }
@@ -1502,7 +1473,7 @@ namespace OTSModelSharp
 
         void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
         {
-           
+
             // copy data over
             if (m_pSEMStageData == null)
             {
@@ -1519,7 +1490,7 @@ namespace OTSModelSharp
             Collection<CHoleBSEImg> xholeBSEImgs = new Collection<CHoleBSEImg>();
             Collection<COTSSample> xsamples = new Collection<COTSSample>();
             Slo slo = new Slo();
-            
+
             slo.Register("ProjMgrFileMark", xProjMgrFileMark);
             slo.Register("ProjMgrFileVersion", xProjMgrFileVersion);
             slo.Register("strPathName", xstrPathName);
@@ -1536,7 +1507,7 @@ namespace OTSModelSharp
                 xSystype.AssignValue(systemTypeId.ToString());
                 xstrPathName.AssignValue(m_strPathName);
                 xholeBSEImgs.Clear();
-             
+
                 xsamples.Clear();
                 foreach (var sample in m_listSamples)
                 {
@@ -1550,17 +1521,17 @@ namespace OTSModelSharp
                 slo.Serialize(false, classDoc, rootNode);
                 m_strPathName = xstrPathName.value();
                 m_listHoleBSEImg.Clear();
-              
+
                 m_listSamples.Clear();
                 for (int i = 0; i < (int)xsamples.size(); i++)
                 {
                     m_listSamples.Add(xsamples.getItem(i));
                 }
-                if(xSystype.value()== "IncA")
+                if (xSystype.value() == "IncA")
                 {
                     systemTypeId = otsdataconst.OTS_SysType_ID.IncA;
                 }
-                else 
+                else
                 {
                     systemTypeId = otsdataconst.OTS_SysType_ID.CleannessA;
                 }

+ 1 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.Designer.cs

@@ -160,7 +160,7 @@ namespace OTSMeasureApp
             this.DeleteSampleData.Image = global::OTSMeasureApp.Properties.Resources.deletefile321;
             this.DeleteSampleData.Name = "DeleteSampleData";
             this.DeleteSampleData.Size = new System.Drawing.Size(194, 30);
-            this.DeleteSampleData.Text = "删除已测数据";
+            this.DeleteSampleData.Text = "初始化样品测量";
             this.DeleteSampleData.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
             // 
             // SlopFocusMenuItem

+ 1 - 1
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -2622,7 +2622,7 @@ namespace OTSIncAReportGraph.Controls
                     var otherpartclrObj = GetParticleclrObjFromParticleData(otherP);
 
                    var sim= selpartclrobj.CalculateSimilarity(otherpartclrObj);
-                    if (sim > 0.97)
+                    if (sim > 0.95)
                     {
                         otherP.IsSelect = true;
                     }