浏览代码

添加修改类SmplMeasure

sunyi 5 年之前
父节点
当前提交
aa2e2f3f95

+ 29 - 27
OTS/OTSModelSharp/Measure/GetBSEPic/SmplMeasure.cs

@@ -1303,7 +1303,7 @@ namespace OTSModelSharp
                 areaPercentage = p;
                 eleData = e;
             }
-            double areaPercentage;
+           public double areaPercentage;
             CElementChemistry eleData;
         };
         public bool MergeBigBoundaryParticles(List<COTSParticle> mergedParts)
@@ -1315,7 +1315,7 @@ namespace OTSModelSharp
             var FldMgr = new CFieldMgr();
             FldMgr.SetSEMDataMsr(this.GetSample().GetSEMDataMsr());
 
-            Dictionary<List<COTSParticle>, List<COTSParticle>> mapMergeParticles = new Dictionary<List<COTSParticle>, List<COTSParticle>>();//hold up all the boundary connected particles. the pair's first is also the member of these particles.
+            Dictionary<COTSParticle, List<COTSParticle>> mapMergeParticles = new Dictionary<COTSParticle, List<COTSParticle>>();//hold up all the boundary connected particles. the pair's first is also the member of these particles.
             Dictionary<COTSParticle, List<COTSSegment>> mapMergedSegments;//hold up all the segment's corresponding clone in the connected particles.
 
             foreach (var centerfld in allFields)
@@ -1347,7 +1347,7 @@ namespace OTSModelSharp
                                     {
                                         leftp.headerParticle = rightp;
 
-                                        mapMergeParticles[rightp].push_back(leftp);
+                                        mapMergeParticles[rightp].Add(leftp);
                                     }
                                     else
                                     {
@@ -1379,18 +1379,18 @@ namespace OTSModelSharp
 
                                 if (upprt.headerParticle != null)
                                 {
-                                    if (downprt[0].headerParticle == null)
+                                    if (downprt.headerParticle == null)
                                     {
-                                        downprt[0].headerParticle = upprt.headerParticle;
-                                        mapMergeParticles[upprt.headerParticle].Add(downprt[0]);
+                                        downprt.headerParticle = upprt.headerParticle;
+                                        mapMergeParticles[upprt.headerParticle].Add(downprt);
                                     }
 
                                 }
                                 else
                                 {
-                                    if (downprt[0].headerParticle != null)
+                                    if (downprt.headerParticle != null)
                                     {
-                                        upprt.headerParticle = downprt[0].headerParticle;
+                                        upprt.headerParticle = downprt.headerParticle;
                                         mapMergeParticles[downprt].Add(upprt);
                                     }
                                     else
@@ -1441,7 +1441,7 @@ namespace OTSModelSharp
                                     {
                                         downprt.headerParticle = downprt;
                                         upprt.headerParticle = downprt;
-                                        mapMergeParticles[downprt].push_back(upprt);
+                                        mapMergeParticles[downprt].Add(upprt);
                                     }
 
                                 }
@@ -1479,7 +1479,7 @@ namespace OTSModelSharp
                                     if (leftprt.headerParticle != null)
                                     {
                                         rightprt.headerParticle = leftprt.headerParticle;
-                                        mapMergeParticles[leftprt.headerParticle].Add(rightprt[0]);
+                                        mapMergeParticles[leftprt.headerParticle].Add(rightprt);
                                     }
                                     else
                                     {
@@ -1503,25 +1503,28 @@ namespace OTSModelSharp
 
                 var newPart = new COTSParticle();
                 List<COTSSegment> newSegs = new List<COTSSegment>();
-                var p = pair.First();
+                int[] aa = { 100, 229, 44, 3, 2, 1 };
+                aa.First();
+
+                var p = pair.Key;
 
                 //firstly,we sum up all the merged particles's area and get the represent string.
-                List<string> partsStr = p.GetFieldId() + ":" + p->GetAnalysisId();
+                string partsStr = p.GetFieldId() + ":" + p.GetAnalysisId();
                 double allPartArea = p.GetArea();//Get the first particle's area.
 
 
-                foreach (var other in pair.second)// Get the total area of all these particles for  the use of ele calcu.
+                foreach (var other in pair.Value)// Get the total area of all these particles for  the use of ele calcu.
                 {
-                    partsStr += "," + other->GetFieldId() + ":" + other->GetAnalysisId();//Get the subparticles string such as "1:1,2:1" etc.
-                    allPartArea += other->GetArea();//Get other particle's area
+                    partsStr += "," + other.GetFieldId() + ":" + other.GetAnalysisId();//Get the subparticles string such as "1:1,2:1" etc.
+                    allPartArea += other.GetArea();//Get other particle's area
 
                 }
                 // calculate all the new segment's position.
                 List<COTSParticle> allSubParts = new List<COTSParticle>();
                 allSubParts.Add(p);
-                foreach (var other in pair.second)// Get the total area of all these particles for  the use of ele calcu.
+                foreach (var other in pair.Value)// Get the total area of all these particles for  the use of ele calcu.
                 {
-                    allSubParts.Add(other.get());
+                    allSubParts.Add(other);
                 }
                 foreach (var subp in allSubParts)
                 {
@@ -1562,16 +1565,15 @@ namespace OTSModelSharp
                 CPosXray pXray1 = p.GetXrayInfo();
                 foreach (var ele in pXray1.GetElementQuantifyData())
                 {
-                    mapEleData[ele.GetName()].Add(EleAreaPercentage(p.GetArea() / allPartArea, ele));
+                    mapEleData[ele.GetName()].Add(EleAreaPercentage(p.GetArea() / allPartArea, ele));                   
                 }
 
-                foreach (var other in pair.second)
+                foreach (var other in pair.Value)
                 {
                     var otherXray = other.GetXrayInfo();
-                    foreach (var eledata in otherXray->GetElementQuantifyData())
+                    foreach (var eledata in otherXray.GetElementQuantifyData())
                     {
-                        mapEleData[eledata.GetName().GetBuffer()].Add(EleAreaPercentage(other.GetArea() / allPartArea, eledata));
-
+                        mapEleData[eledata.GetName()].Add(EleAreaPercentage(other.GetArea() / allPartArea, eledata));
                     }
                 }
                 // third,we calculate all the element's new percentage data and get a new element chemistry list.
@@ -1580,9 +1582,9 @@ namespace OTSModelSharp
                 foreach (var eledata in mapEleData)
                 {
                     CElementChemistry newEleche = new CElementChemistry();
-                    newEleche.SetName(eledata.first);
+                    newEleche.SetName(eledata.Key);
                     double newPercentage = 0;
-                    foreach (var d in eledata.second)
+                    foreach (var d in eledata.Value)
                     {
                         newPercentage += d.areaPercentage;
                     }
@@ -1593,12 +1595,12 @@ namespace OTSModelSharp
                 CPosXray xray = new CPosXray();
                 xray.SetElementQuantifyData(newCheList);
                 newPart.SetXrayInfo(xray);
-                newPart.SetSubParticles(partsStr[0]);
+                newPart.SetSubParticles(partsStr);
                 newPart.SetArea(allPartArea);
                 newPart.SetTagId(mergedParts.Count);
                 newPart.SetAnalysisId(mergedParts.Count);
-                List<string> name = p.TypeName();
-                newPart.TypeName(name[0]);
+                string name = p.TypeName();
+                newPart.TypeName(name);
                 newPart.TypeColor(p.TypeColor());
                 mergedParts.Add(newPart);
             }

+ 92 - 3
OTS/OTSModelSharp/Measure/GetBSEPic/SmplMeasureInc.cs

@@ -5,20 +5,23 @@ using System.Text;
 using System.Threading.Tasks;
 using OTSDataType;
 using OTSIncAMeasureApp.OTSMeasureControl;
+using static OTSDataType.otsdataconst;
 
 namespace OTSModelSharp.MeasureControl
 {
     class CSmplMeasureInc : SmplMeasure
     {
+        // system STD
+        bool m_bSysSTD;
         public CSmplMeasureInc()
         {
 
         }
         //双参数的构造函数在基类中不存在,故此处没有转换成c#
-        //public CSmplMeasureInc(string a_strWorkingFolder, COTSSample a_pSample) : base(a_strWorkingFolder, a_pSample)
-        //{
+        public CSmplMeasureInc(string a_strWorkingFolder, COTSSample a_pSample) : base(a_strWorkingFolder, a_pSample)
+        {
 
-        //}
+        }
 
         public void Dispose()
         {
@@ -471,5 +474,91 @@ namespace OTSModelSharp.MeasureControl
                 }
             }
         }
+
+        // classify particles
+       public bool ClassifyParticles(List<COTSParticle> a_listAnalysisParticles, List<CPosXray> a_listAnalysisXRay)
+        {
+            // make sure the two lists are same size
+            int nSize = (int)a_listAnalysisParticles.Count;
+            if (nSize != (int)a_listAnalysisXRay.Count)
+            {
+                // particles list size is different with x-ray size
+                loger.Error("ClassifyParticles: particles list size is different with x-ray size.");
+                return false;
+            }
+
+            // go through all analysis particles
+            for (int i = 0; i < nSize; ++i)
+            {
+                COTSParticle pParticle = a_listAnalysisParticles[i];
+                CPosXray pXray = a_listAnalysisXRay[i];
+
+                if (!ClassifyParticle(pParticle, pXray))
+                {
+                    // failed to call ClassifyParticle method
+                    loger.Error("ClassifyParticles: failed to call ClassifyParticle method.");
+                    return false;
+                }
+            }
+
+            // ok, return TRUE
+            return true;
+        }
+
+      public  bool ClassifyParticle(COTSParticle a_pParticle, CPosXray a_pXRay)
+        {
+            //set the particle type to NOT_IDENTIFIED
+            int nInclusionID = (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED;
+
+            //// 1.get elementChemistries
+           List< CElementChemistry> listElementChemistriesOld = a_pXRay.GetElementQuantifyData();
+
+
+            //get the parameter MsrParam object
+            CMsrParams pMsrParam = m_pSample.GetMsrParams();
+            //get the steel technology parameter
+            STEEL_TECHNOLOGY steelTech = pMsrParam.GetSteelTechnology();
+            //get standard database item which will be used when classify.
+            //CPartSTDDataPtr pPartSTDData = pMsrParam->GetPartSTDData();
+            //int listSize = pPartSTDData->GetSTDItemsList().size();
+            if (m_pSample.IfUsingSysSTD())
+            {
+
+                var IncAen = OTSClassifyEngine.GetInclutionEngine();
+                if (!IncAen->Classify(a_pParticle, (int)steelTech, a_pXRay))
+                {
+                    loger.Error("ClassifyParticle: can't identify the particle as any inclusion.");
+                    return false;
+                }
+                if (a_pParticle.GetType() == (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED)
+                {
+                    var ExpEn = OTSClassifyEngine.GetParticleEngine(m_pSample.GetMsrParams().GetSTDName());
+                    if (!ExpEn->Classify(a_pParticle, a_pXRay))
+                    {
+                        loger.Error("ClassifyParticle: can't identify the particle as any inclusion.");
+                        return false;
+                    }
+                }
+            }
+            else
+            {
+                var ExpEn = OTSClassifyEngine.GetParticleEngine(m_pSample.GetMsrParams().GetSTDName());
+                if (!ExpEn->Classify(a_pParticle, a_pXRay))
+                {
+                    loger.Error("ClassifyParticle: can't identify the particle as any inclusion.");
+                    return false;
+                }
+            }
+
+            nInclusionID = a_pParticle.GetType();
+
+
+            return true;
+
+        }
+
+        // system STD
+        bool IfUsingSysSTD() { return m_bSysSTD; }
+
     }
 }

+ 58 - 4
OTS/OTSModelSharp/Measure/GetBSEPic/SmplMsrResultFile.cs

@@ -5,6 +5,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Xml;
 using OTSDataType;
+using static OTSDataType.otsdataconst;
 
 namespace OTSModelSharp
 {
@@ -72,8 +73,16 @@ namespace OTSModelSharp
         }
         public bool Equals(CSmplMsrResultFile a_oSource)
         {
+            Duplicate(a_oSource);
+            
             return false;
         }
+
+        // cleanup
+       public  void Cleanup()
+        {
+            m_listFieldData.Clear();
+        }
         // file version string
         public string GetFileVersion()
         {
@@ -158,12 +167,23 @@ namespace OTSModelSharp
                 m_listFieldData.Add(pFieldData);
             }
         }
-        //----------protected----------------
-        // cleanup
-        protected void Cleanup()
+
+      public  List<COTSParticle> GetAllParticles()
         {
-            m_listFieldData.Clear();
+            List<COTSParticle> listParticle = new List<COTSParticle>();
+           List< COTSFieldData> listFieldData = GetFieldData();
+            foreach (var pFieldData in listFieldData)
+            {
+               List< COTSParticle> listParticlenew = pFieldData.GetParticleList();
+                foreach (var pParticle in listParticlenew)
+                {
+                    listParticle.Add(pParticle);
+                }
+            }
+            return listParticle;
         }
+        //----------protected----------------
+
         // initialization
         protected void Init()
         {
@@ -257,5 +277,39 @@ namespace OTSModelSharp
             }
         }
 
+       public bool GetSTDMapedParticleList(Dictionary<string, List<COTSParticle>> mapSameSTDPartList)
+        {
+            //把颗粒根据类型分组,类型 ID做key,颗粒列表做value
+
+            Dictionary < string, List<COTSParticle>> partListIter;
+            var listParticle = GetAllParticles();
+            //get the same type particle together
+            foreach (var pParticle in listParticle)
+            {
+                string sType = pParticle.TypeName();
+                int nType = pParticle.GetType();
+                //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
+                if (nType >= (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED_SIC)
+                {
+
+                    partListIter = mapSameSTDPartList;                       
+                    if (partListIter == mapSameSTDPartList)
+                    {
+                        List<COTSParticle> listParticles = new List<COTSParticle>();
+                        listParticles.Add(pParticle);
+                        mapSameSTDPartList.Insert(new KeyValuePair<string, List<COTSParticle>>(sType, listParticles));
+                           
+                    }
+                    else
+                    {
+                        partListIter.second.Add(pParticle);
+                    }
+
+                }
+
+            }
+            return true;
+        }
+
     }
 }

+ 2 - 0
OTS/OTSModelSharp/Measure/GetParam/COTSProjMgrFile.cs

@@ -1879,5 +1879,7 @@ namespace OTSModelSharp
 
         public COTSImgScanPrm  GetImageScanParam() { return null; }
 
+       
+
     }
 }

+ 15 - 0
OTS/OTSModelSharp/Measure/GetParam/OTSGeneralParameters.cs

@@ -28,6 +28,9 @@ namespace OTSModelSharp
         DOMAIN_SHAPE m_nDefaultShape;
         CMsrParams m_DefaultMsrParam;
         otsdataconst.MEMBRANE_TYPE m_DefaultmembraneType;
+        bool m_bSysSTD;
+        int m_SteelTechnology;
+        String m_STDLibFileName;
         //--------------------public-----------------
         public COTSGeneralParameters()
         {
@@ -327,6 +330,18 @@ namespace OTSModelSharp
             }
         }
 
+      public  String GetPartSTDLibName() { return m_STDLibFileName; }
+
+        bool GetSysSTD() { return m_bSysSTD; }
+
+        void SetSysSTD(bool a_bSysSTD) { m_bSysSTD = a_bSysSTD; }
+
+        int GetSteelTechnology() { return m_SteelTechnology; }
+
+        void SetSteelTechnology(int a_SteelTechnology) { m_SteelTechnology = a_SteelTechnology; }
+
+
+
 
     }
 }

+ 12 - 12
OTS/OTSModelSharp/OTSDataType/COTSFieldData.cs

@@ -21,7 +21,7 @@ namespace OTSDataType
 
         List<COTSParticle> m_listParticles = new List<COTSParticle>();
 
-       List< List<COTSParticle>> m_listBigParticles = new List<List<COTSParticle>>();
+        List<COTSParticle> m_listBigParticles = new List<COTSParticle>();
 
         public long Height;
 
@@ -144,7 +144,7 @@ namespace OTSDataType
         }
 
         // particle list
-       public List<List< COTSParticle>> GetBigParticleList()
+       public List< COTSParticle> GetBigParticleList()
         {
             return m_listBigParticles;
         }
@@ -173,12 +173,12 @@ namespace OTSDataType
             foreach (var p in m_listBigParticles)
             {
                
-                var segs = p[0].GetFeature().GetSegmentsList();//COTSSegment
+                var segs = p.GetFeature().GetSegmentsList();//COTSSegment
                 foreach (var seg in segs)
                 {
                     if (seg.GetHeight() == 0)
                     {
-                        parts.Add(p[0]);
+                        parts.Add(p);
                         break;
                     }
                 }
@@ -186,12 +186,12 @@ namespace OTSDataType
             return parts;
         }
 
-        public List< List< COTSParticle >> GetBottomBorderedBigParticles()
+        public  List< COTSParticle > GetBottomBorderedBigParticles()
         {
-           List< List<COTSParticle>> parts = new List<List<COTSParticle>>();
+            List<COTSParticle> parts = new List<COTSParticle>();
             foreach (var p in m_listBigParticles)
             {
-                var segs = p[0].GetFeature().GetSegmentsList();
+                var segs = p.GetFeature().GetSegmentsList();
                 foreach (var seg in segs)
                 {
                     if (seg.GetHeight() == this.Height - 1)//the lowest height is 767(height-1),cause starting from 0.
@@ -210,12 +210,12 @@ namespace OTSDataType
             List<COTSParticle> parts = new List<COTSParticle>();
             foreach (var p in m_listBigParticles)
             {
-                var segs = p[0].GetFeature().GetSegmentsList();
+                var segs = p.GetFeature().GetSegmentsList();
                 foreach (var seg in segs)
                 {
                     if (seg.GetStart() == 0)
                     {
-                        parts.Add(p[0]);
+                        parts.Add(p);
                         break;
                     }
 
@@ -224,12 +224,12 @@ namespace OTSDataType
             return parts;
         }
 
-        public List< List <COTSParticle>> GetRightBorderedBigParticles()
+        public  List <COTSParticle> GetRightBorderedBigParticles()
         {
-           List< List<COTSParticle>> parts = new List< List<COTSParticle>>();
+            List<COTSParticle> parts = new  List<COTSParticle>();
             foreach (var p in m_listBigParticles)
             {
-                var segs = p[0].GetFeature().GetSegmentsList();
+                var segs = p.GetFeature().GetSegmentsList();
                 foreach (var seg in segs)
                 {
                     if (seg.GetStart() + seg.GetLength() == this.Width)

+ 3 - 3
OTS/OTSModelSharp/OTSDataType/OTSParticle.cs

@@ -615,13 +615,13 @@ namespace OTSDataType
         	UP = 4
         }
 
-        public bool IsConnected(List<COTSParticle> a_p, int fldwidth, int fldheight, int direction)
+        public bool IsConnected(COTSParticle a_p, int fldwidth, int fldheight, int direction)
         {
             //decide if two on boundary particles are connected.
             SORTING_DIRECTION di = (SORTING_DIRECTION)direction;
             foreach (var s in m_pFeature.GetSegmentsList())
             {
-                foreach (var a_seg in a_p[direction].GetFeature().GetSegmentsList())
+                foreach (var a_seg in a_p.GetFeature().GetSegmentsList())
                 {
                     if (di == SORTING_DIRECTION.LEFT || di == SORTING_DIRECTION.RIGHT)
                     {
@@ -669,7 +669,7 @@ namespace OTSDataType
 
         }
 
-        public List<COTSParticle> headerParticle; //used to merge particles ,if this particle has been merged then this pointer will point to the first particle of these merged particles else it's NULL.
+        public COTSParticle headerParticle; //used to merge particles ,if this particle has been merged then this pointer will point to the first particle of these merged particles else it's NULL.
 
         // cleanup
         //protected void Cleanup()