瀏覽代碼

diagnosis the ParticleClassifyEngine

lizhongsys 4 年之前
父節點
當前提交
e81045aa7b

+ 20 - 7
OTSCPP/OTSClassifyEngine/ParticleClassifyEngine.cpp

@@ -49,7 +49,7 @@ bool ParticleClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray
 
 		auto& originalPartEles = xray->GetElementQuantifyData();//find all the elements containing in the particle xray.
 		//以下为调试用代码段(在log中打出颗粒元素),不要删除----------
-		/*std::string allele="";
+		/*std::string allele=std::to_string(particle->GetTagId()) + " ";
 		for (auto che : originalPartEles)
 		{
 			allele += che->GetName().GetBuffer() ;
@@ -72,16 +72,17 @@ bool ParticleClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray
 
 
 		PartSTDItemList stdItems = m_std->GetSTDItems();
-
+		//以下为调试用代码段(在log中打出颗粒元素),不要删除----------
+		/*CString stdnum = _T("STDNum ")+ CString(std::to_string(stdItems.size()).c_str());
+		LogTrace(__FILE__, __LINE__, stdnum);*/
 		for (auto itm : stdItems)
 		{
 			std::string exp = itm->GetExpressionStr();
-
+			//LogTrace(__FILE__, __LINE__, exp.c_str());
 			//if the element quantity is not match the std item's keyelement num than  is unsatisfied.
 			if (partEles.size() < itm->GetKeyElementList().size())
 			{
-				/*std::string s = std::to_string(partEles.size()) + ":" + std::to_string(itm->GetKeyElementList().size());
-				LogTrace(__FILE__, __LINE__, s.c_str());*///调试用代码段
+				
 				particle->SetClassifyId(9);
 				particle->TypeName("Not Identified");
 
@@ -171,11 +172,23 @@ bool ParticleClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray
 				}
 
 			}
-			//LogInfoTrace(__FILE__, __LINE__, exp.c_str());//调试用代码段
+		
 
 			//calculate the expression which has been processed.
-
+			
 			bool rst = CalcuExp(exp);
+
+			//以下为调试用代码段(在log中打出颗粒元素),不要删除----------
+			/*LogTrace(__FILE__, __LINE__, exp.c_str());
+			if (rst)
+			{
+				LogTrace(__FILE__, __LINE__, CString("true"));
+			}
+			else
+			{
+				LogTrace(__FILE__, __LINE__, CString("false"));
+			}*/
+			
 			if (rst)
 			{
 				//int id = itm->GetID();

+ 3 - 3
OTSCPP/OTSClassifyEngine/ParticleEngine/LogicExp.cpp

@@ -7,7 +7,7 @@
 #include<map>
 #include "MathExpression.h"
 #include "XMLSerialization.h"
-
+#include "COTSUtilityDllFunExport.h"
 using namespace std;
 namespace expInterpreter {
 	namespace {
@@ -259,7 +259,7 @@ namespace expInterpreter {
 		expInterpreter::Expression mathExpIpr;
 		std::vector<std::pair<string,string>> mathexp;
 		DevidExpToMathExp(mathexp, hybrids);//first ,we devid the expression into math expressions such as "20+(5+1)*25-500>60" ,we use "and" and "or" to separate it.
-		//
+		
 		for (auto e : mathexp)
 		{
 			string rst;
@@ -370,7 +370,7 @@ namespace expInterpreter {
 		xmls::ReplaceAll(hybrids, "and", "&");
 		xmls::ReplaceAll(hybrids, "or", "|");//get a pure logic expression.
 		
-
+		//LogTrace(__FILE__, __LINE__, hybrids.c_str());
 		string post;
 		char ans;
 		post = MidToPost(hybrids.c_str());

+ 7 - 6
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.cpp

@@ -3135,20 +3135,21 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<Br
 	WORD* pixelTimes(new WORD[nCollectCount]);
 	BrukerFeature* features(new BrukerFeature[nCollectCount]);
 	std::vector<BrukerSegment> extraSegments;
-	for (size_t i = 0; i < a_vXPoints.size(); i++)
+	for (size_t i = 0; i < nCollectCount; i++)
 	{
-		features[i].SegmentCount = (long)a_vFeatures[i].SegmentCount;
-		if (a_vFeatures[i].SegmentCount > 0)
+		BrukerFeature ofeature = a_vFeatures[i];
+		features[i].SegmentCount = ofeature.SegmentCount;
+		if (ofeature.SegmentCount > 0)
 		{
-			features[i].pSegment = a_vFeatures[i].pSegment;
+			features[i].pSegment = ofeature.pSegment;
 
 			// calculate pixel time
 			int nPixelCount = 0;
 	
 
-			for (int j = 0; j < a_vFeatures[i].SegmentCount; j++)
+			for (int j = 0; j < ofeature.SegmentCount; j++)
 			{
-				nPixelCount += a_vFeatures[i].pSegment[j].XCount;
+				nPixelCount += ofeature.pSegment[j].XCount;
 			}
 			pixelTimes[i] = (WORD)(ceil((double)a_nACTimeMS * 1000.0 / (double)nPixelCount));
 

+ 4 - 3
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -2564,7 +2564,7 @@ namespace OTSIMGPROC
 
 			}
 		}
-
+		static int partTagId;
 		for (auto pair : mapMergeParticles)
 		{
 			struct EleAreaPercentage
@@ -2680,8 +2680,9 @@ namespace OTSIMGPROC
 			newPart->SetXrayInfo(xray);
 			newPart->SetSubParticles(partsStr);
 			newPart->SetArea(allPartArea);
-			newPart->SetTagId(mergedParts.size());
-			newPart->SetAnalysisId(mergedParts.size());
+			partTagId++;
+			newPart->SetTagId(partTagId);
+			newPart->SetAnalysisId(partTagId);
 			std::string name = p->TypeName();
 			newPart->TypeName(name);
 			newPart->TypeColor(p->TypeColor());

+ 9 - 4
OTSIncAMeasureApp/0-OTSModel/Measure/1-OTSInclution/SmplMeasureInclution.cs

@@ -36,7 +36,12 @@ namespace OTSModelSharp
             // create a field
             curFldData = new CFieldDataIncA(a_pBSEImg, m_Sample.CalculatePixelSize());
             curFldData.SetId(nNewFieldId);
-            curFldData.SetPosition(fldCenter);
+            curFldData.SetOTSPosition(fldCenter);
+            CSEMStageData a_pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
+            Point semPos = new Point();
+            a_pCSEMStageData.ConverOTSToSEMPoint(fldCenter,ref semPos);
+            curFldData.SemPos = semPos;
+           
             //first step:remove background of the bse image and compound all the finded particles.
             COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
             log.Info("Begin to process image and get all particles!");
@@ -151,7 +156,7 @@ namespace OTSModelSharp
             foreach (var p in xrayParticles)
             {
                
-                Point fldOtsPos = new Point(curFldData.PoiPos.X, curFldData.PoiPos.Y);//take the field position as the particle's position instead
+                Point fldOtsPos = new Point(curFldData.OTSPos.X, curFldData.OTSPos.Y);//take the field position as the particle's position instead
                 Point semPos = new Point();
                 pCSEMStageData.ConverOTSToSEMPoint(fldOtsPos, ref semPos);
                 p.SetAbsolutPos(semPos);
@@ -349,11 +354,11 @@ namespace OTSModelSharp
             pDBFileMgr.SaveStatusDataToDB();
             var fldDB = pDBFileMgr.GetFieldDB();
             //fldDB.SaveAField(fldData.GetId(),fldData.GetPosition());
-            var fldcmds = fldDB.GetSavingAFieldcmd(fldData.GetId(), fldData.GetPosition());
+            var fldcmds = fldDB.GetSavingAFieldcmd(fldData.GetId(), fldData.GetOTSPosition(),fldData.SemPos);
 
             log.Warn("Start saving particle data.");
         
-            var cmds = pDBFileMgr.GetSavingIncADataToDBCmds(curFldData.GetListAnalysisParticles(), fldData.GetPosition());
+            var cmds = pDBFileMgr.GetSavingIncADataToDBCmds(curFldData.GetListAnalysisParticles(), fldData.GetOTSPosition());
 
 
             //save the xray data and element data.

+ 4 - 4
OTSIncAMeasureApp/0-OTSModel/Measure/2-OTSCleanliness/SmplMeasureCleanliness.cs

@@ -34,7 +34,7 @@ namespace OTSModelSharp
             CFieldDataClean curFldDataCln =( CFieldDataClean) curFldData;
           
             curFldData.SetId(nNewFieldId);
-            curFldData.SetPosition(fldCenter);
+            curFldData.SetOTSPosition(fldCenter);
             GetOriginalParticles();
  
             // second step :filter the finded particles.
@@ -78,7 +78,7 @@ namespace OTSModelSharp
             foreach (var p in curFldData.GetListAnalysisParticles())
             {
 
-                Point fldOtsPos = new Point(curFldData.PoiPos.X, curFldData.PoiPos.Y);
+                Point fldOtsPos = new Point(curFldData.OTSPos.X, curFldData.OTSPos.Y);
                 Point semPos = new Point();
                 pCSEMStageData.ConverOTSToSEMPoint(fldOtsPos, ref semPos);
                 p.SetAbsolutPos(semPos);
@@ -407,8 +407,8 @@ namespace OTSModelSharp
             //pDBFileMgr.BeginTransaction();
             pDBFileMgr.SaveStatusDataToDB();
             var fldDB = pDBFileMgr.GetFieldDB();
-            fldDB.SaveAField(fldData.GetId(), fldData.GetPosition());
-            if (!pDBFileMgr.SaveIncADataToDB(fldData.GetListAnalysisParticles(), fldData.GetPosition()))
+            fldDB.SaveAField(fldData.GetId(), fldData.GetOTSPosition(),fldData.SemPos);
+            if (!pDBFileMgr.SaveIncADataToDB(fldData.GetListAnalysisParticles(), fldData.GetOTSPosition()))
             {
                 log.Info("SaveFieldFiles: save inclusion file failed.");
                 return false;

+ 1 - 1
OTSIncAMeasureApp/0-OTSModel/Measure/3-MeasureFlow/CSmplMsrResult.cs

@@ -688,7 +688,7 @@ namespace OTSModelSharp
                         }
                         mapTypeParticles[part.GetClassifyId()].Add(part);
                     }
-                    completedfld.Add(fld.GetPosition());
+                    completedfld.Add(fld.GetOTSPosition());
                     msrFldsArea += aFieldArea;
                 }
             }

+ 11 - 9
OTSIncAMeasureApp/0-OTSModel/Measure/BSEPicData/COTSFieldData.cs

@@ -20,7 +20,7 @@ namespace OTSModelSharp
         int m_nID;
 
         // position (from field center manager) 
-      protected  System.Drawing.Point m_poiPos ;
+      protected  System.Drawing.Point m_otsPos ;
 
        protected CBSEImgClr m_pBSEImg;
 
@@ -40,8 +40,10 @@ namespace OTSModelSharp
 
         public int Height { get => height; set => height = value; }
         public int Width { get => width; set => width = value; }
-        public System.Drawing.Point PoiPos { get => m_poiPos; set => m_poiPos = value; }
+        public System.Drawing.Point OTSPos { get => m_otsPos; set => m_otsPos = value; }
+        public Point SemPos { get => m_semPos; set => m_semPos = value; }
 
+        private Point m_semPos;
         public List<COTSParticleClr> GetListAnalysisParticles()
         {
             return m_listAnalysisParticles;
@@ -77,7 +79,7 @@ namespace OTSModelSharp
         {
             // initialization
             m_nID = -1;
-            PoiPos =new  System.Drawing.Point(0, 0);
+            OTSPos =new  System.Drawing.Point(0, 0);
             m_listAllParticles.Clear();
         }
 
@@ -300,7 +302,7 @@ namespace OTSModelSharp
             }
 
             return m_nID == a_oSource.m_nID &&
-                PoiPos == a_oSource.PoiPos;
+                OTSPos == a_oSource.OTSPos;
               
         }
 
@@ -318,14 +320,14 @@ namespace OTSModelSharp
         }
 
         // position (from field center manager) 
-       public  System.Drawing.Point GetPosition()
+       public  System.Drawing.Point GetOTSPosition()
         {
-            return PoiPos;
+            return m_otsPos;
         }
 
-       public  void SetPosition(System.Drawing.Point a_poiPos)
+       public  void SetOTSPosition(System.Drawing.Point a_poiPos)
         {
-            PoiPos = a_poiPos;
+            m_otsPos = a_poiPos;
         }
 
  
@@ -419,7 +421,7 @@ namespace OTSModelSharp
 	    {
 	
         m_nID = a_oSource.m_nID;
-		PoiPos =  a_oSource.PoiPos;
+		OTSPos =  a_oSource.OTSPos;
 		//m_strFieldFileFolder = a_oSource.m_strFieldFileFolder;
 
 		// copy data over

+ 1 - 1
OTSIncAMeasureApp/0-OTSModel/Measure/DBDataTransition/IncADataDB.cs

@@ -108,7 +108,7 @@ namespace OTSModelSharp
                     System.Drawing.Point fldPos =new System.Drawing.Point();
                     fldPos.X = Convert.ToInt32(allRecords.Rows[i][(int)CIncADataTable.ColumnID.N_FldPosX]);
                     fldPos.Y = Convert.ToInt32(allRecords.Rows[i][(int)CIncADataTable.ColumnID.N_FldPosY]);
-                    fld.SetPosition(fldPos);
+                    fld.SetOTSPosition(fldPos);
                     List<COTSParticleClr> ps = fld.GetListAnalysisParticles();
                     COTSParticleClr p = new COTSParticleClr();
                     p.SetFieldId(fld.GetId());

+ 1 - 1
OTSIncAMeasureApp/0-OTSModel/Measure/DBDataTransition/MergedParticles/MergeParticleDB.cs

@@ -107,7 +107,7 @@ namespace OTSModelSharp
                     
                     fldPos.X = (int)allRecords.Rows[(int)CMergeParticleTable.ColumnID.N_FldPosX][0];
                     fldPos.Y = (int)allRecords.Rows[(int)CMergeParticleTable.ColumnID.N_FldPosY][0];
-                    fld.SetPosition(fldPos);
+                    fld.SetOTSPosition(fldPos);
                     List< COTSParticleClr> ps = fld.GetListAnalysisParticles();
                     COTSParticleClr p = new COTSParticleClr();
                    

+ 1 - 1
OTSIncAMeasureApp/0-OTSModel/Measure/ParamData/COTSMsrPrjResultData.cs

@@ -365,7 +365,7 @@ namespace OTSModelSharp
                             }
                            
                         }
-                        completedflds.Add(fld.GetPosition());
+                        completedflds.Add(fld.GetOTSPosition());
                         msrFldsArea += aFieldArea;
                     }
 

+ 1 - 1
OTSIncAMeasureApp/ServiceCenter/CImageHandler.cs

@@ -187,7 +187,7 @@ namespace OTSModelSharp.ServiceInterface
             foreach (var f in allFields)
             {
                 COTSFieldDataClr fldclr = new COTSFieldDataClr();
-                fldclr.SetPosition(f.GetPosition());
+                fldclr.SetPosition(f.GetOTSPosition());
                 fldclr.SetImageWidth(f.Width);
                 fldclr.SetImageHeight(f.Height);
                 

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

@@ -443,7 +443,7 @@ namespace OTSIncAReportGraph.Controls
                 Point thisfield_point = new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY };
               
                 
-                Point offset_point = ReportFun.ConvertPhysicalCoordinateToScreenCoord(otsLeftBottomPoint, m_pixelSize, thisfield_point);//the ots coordinate is always the up right positive.
+                Point offset_point = ReportFun.ConvertOTSCoordinateToScreenCoord(otsLeftBottomPoint, m_pixelSize, thisfield_point, m_backRect, new RectangleF(0,0,fieldwidth,fieldheight));//the ots coordinate is always the up right positive.
                
                 DisplayField df = new DisplayField(fieldlist[i],fieldwidth,fieldheight, offset_point);
         

+ 4 - 3
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -124,12 +124,13 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             return new Point(i_offset_x, i_offset_y);
         }
      
-            public Point ConvertPhysicalCoordinateToScreenCoord(Point otsleftBottomPoint,double pixelSize, Point currenFldPos)//ots coordinate equals to the physical coordinate.
+            public Point ConvertOTSCoordinateToScreenCoord(Point otsleftBottomPoint,double pixelSize, Point currenFldPos,RectangleF wholeImageRec,RectangleF singleImgRec)//
         {
            
                var OTSPoint=new Point(currenFldPos.X - otsleftBottomPoint.X, currenFldPos.Y - otsleftBottomPoint.Y);
-
-            var screenPoint = new Point((int)(Convert.ToDouble(OTSPoint.X)/pixelSize), (int)(Convert.ToDouble(OTSPoint.Y)/pixelSize));
+            double screenHeight = wholeImageRec.Height + (0 - (int)(Convert.ToDouble(OTSPoint.Y) / pixelSize));//because the screen coordinate is downward rightward positive,so we need to translate the Y coordinate of the OTS system which is upward rightward positive.
+            screenHeight = screenHeight - singleImgRec.Height;
+            var screenPoint = new Point((int)(Convert.ToDouble(OTSPoint.X)/pixelSize), (int)screenHeight);
 
             return screenPoint;
         }