Explorar o código

improve the smplpreviewMeasure algorithm.improve the FieldMgr.cpp module.

GSP hai 1 mes
pai
achega
a4492c73c9

+ 120 - 34
OTSCPP/OTSImagePro/FieldMgr.cpp

@@ -342,11 +342,29 @@ namespace OTSIMGPROC {
 					std::vector<CPoint> ptPolygon = m_pMeasureArea->GetPolygonPoint();
 					for (auto itr : mapCenterPoint)
 					{
-						CPoint itrPoint = itr.second;
-						if (IsInPolygonMeasureArea(itrPoint, sizeImage, ptPolygon))					
+						
+						switch (distributionMode)
 						{
-							m_listFieldCentrePoints.push_back(itr.second);
-							
+						case 0://center in
+							if (IsInPolygonMeasureArea(itr.second, sizeImage, ptPolygon))
+							{
+								m_listFieldCentrePoints.push_back(itr.second);
+							}
+							break;
+						case 1://partly in ,all field will cover all the measure area
+							if (IsPartlyInPolygonMeasureArea(itr.second, sizeImage, ptPolygon))
+							{
+								m_listFieldCentrePoints.push_back(itr.second);
+							}
+							break;
+						case 2://totally in, field is totally in the measure area
+							if (IsTotallyInPolygonMeasureArea(itr.second, sizeImage, ptPolygon))
+							{
+								m_listFieldCentrePoints.push_back(itr.second);
+							}
+							break;
+						default:
+							break;
 						}
 					}
 				}
@@ -362,7 +380,7 @@ namespace OTSIMGPROC {
 									m_listFieldCentrePoints.push_back(itr.second);
 								}
 								break;
-							case 1://partly in , field will cover all the measure area
+							case 1://partly in ,all field will cover all the measure area
 								if (IsPartlyInMeasureArea(itr.second, sizeImage))
 								{
 									m_listFieldCentrePoints.push_back(itr.second);
@@ -438,43 +456,111 @@ namespace OTSIMGPROC {
 			return TRUE;
 		}
 
+		
+		// this field is not in the area at all, return FALSE.
+		return FALSE;
+	}
+	BOOL CFieldMgr::IsPartlyInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon)
+	{
+		// check measure area parameter
+		ASSERT(m_pMeasureArea);
+		if (!m_pMeasureArea)
+		{
+			// shouldn't happen
+			LogErrorTrace(__FILE__, __LINE__, _T("IsInDomainArea: invalid measure area parameter."));
+			return FALSE;
+		}
+
+		// test field centre point first
+		if (PtInPolygon(a_poiField, ptPolygon))
+		{
+			// centre in the measure domain area, return TRUE 
+			return TRUE;
+		}
+
 		// get measure field centre
-		//CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
+		CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
 
-		//// move to left top postion.
-		//a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
+		// move to left top postion.
+		a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
 
-		//// rectangle of the field
-		//CRect rectFiled(a_poiField, a_sizeImageSize);
+		// rectangle of the field
+		CRect rectFiled(a_poiField, a_sizeImageSize);
 
 
-		//		// on the top left side, need to test the bottom right  corner
-		//		if (PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
-		//		{
-		//			return TRUE;
-		//		}
+				// on the top left side, need to test the bottom right  corner
+				if (PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
+				{
+					return TRUE;
+				}
 
-		//		// on the bottom left side, need to test the top right corner
-		//		if (PtInPolygon(rectFiled.BottomRight(), ptPolygon))
-		//		{
-		//			return TRUE;
-		//		}
+				// on the bottom left side, need to test the top right corner
+				if (PtInPolygon(rectFiled.BottomRight(), ptPolygon))
+				{
+					return TRUE;
+				}
+
+				// on the top left side, need to test the bottom right  corner
+				if (PtInPolygon(rectFiled.TopLeft(), ptPolygon))
+				{
+					return TRUE;
+				}
+
+				// on the bottom left side, need to test the top right corner
+				if (PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
+				{
+					return TRUE;
+				}
 
-		//		// on the top left side, need to test the bottom right  corner
-		//		if (PtInPolygon(rectFiled.TopLeft(), ptPolygon))
-		//		{
-		//			return TRUE;
-		//		}
-	
-		//		// on the bottom left side, need to test the top right corner
-		//		if (PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
-		//		{
-		//			return TRUE;
-		//		}
-	
 		// this field is not in the area at all, return FALSE.
 		return FALSE;
 	}
+	BOOL CFieldMgr::IsTotallyInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon)
+	{
+		// check measure area parameter
+		ASSERT(m_pMeasureArea);
+		if (!m_pMeasureArea)
+		{
+			// shouldn't happen
+			LogErrorTrace(__FILE__, __LINE__, _T("IsInDomainArea: invalid measure area parameter."));
+			return FALSE;
+		}
+
+
+		// move to left top postion.
+		a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
+
+		// rectangle of the field
+		CRect rectFiled(a_poiField, a_sizeImageSize);
+
+
+		// on the top left side, need to test the bottom right  corner
+		if (!PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
+		{
+			return FALSE;
+		}
+
+		// on the bottom left side, need to test the top right corner
+		if (!PtInPolygon(rectFiled.BottomRight(), ptPolygon))
+		{
+			return FALSE;
+		}
+
+		// on the top left side, need to test the bottom right  corner
+		if (!PtInPolygon(rectFiled.TopLeft(), ptPolygon))
+		{
+			return FALSE;
+		}
+
+		// on the bottom left side, need to test the top right corner
+		if (!PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
+		{
+			return FALSE;
+		}
+
+		
+		return TRUE;
+	}
 
 
 	//function:judge whether the point p is in the polygon ptPolygon
@@ -561,7 +647,7 @@ namespace OTSIMGPROC {
 		}
 
 		// get measure field centre
-		CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
+		//CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
 
 		// move to left top postion.
 		a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
@@ -606,7 +692,7 @@ namespace OTSIMGPROC {
 		}
 
 		// get measure field centre
-		CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
+		//CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
 
 		// move to left top postion.
 		a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);

+ 2 - 0
OTSCPP/OTSImagePro/FieldMgr.h

@@ -120,6 +120,8 @@ namespace OTSIMGPROC {
 	
 		// test if field is in or partly in the measure domain area
 		BOOL IsInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon);
+		BOOL IsPartlyInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon);
+		BOOL IsTotallyInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon);
 		BOOL PtInPolygon(CPoint p, const std::vector<CPoint> ptPolygon);
 	};
 

+ 4 - 8
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplPreviewMeasure.cs

@@ -306,17 +306,13 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
                     m_listHoleBSEImg.Add(pHoleBSEImg);
 
                 }
+            }
+            ST_MSTMsg MsgSmplEnd = new ST_MSTMsg();
 
-              
-              
-                ST_MSTMsg MsgSmplEnd = new ST_MSTMsg();
-
-                MsgSmplEnd.InitHolePreSampleEndMsg();
-
+            MsgSmplEnd.InitHolePreSampleEndMsg();
 
-                m_pMsrThread.SendHolePreviewMessageToMeasureGUI(MsgSmplEnd);
 
-            }
+            m_pMsrThread.SendHolePreviewMessageToMeasureGUI(MsgSmplEnd);
         }
        
         bool InitHoleBSEParam()

+ 3 - 1
OTSIncAMeasureApp/1-OTSMeasure/Measure/DBDataTransition/IncADataTable.cs

@@ -44,7 +44,8 @@ namespace OTSModelSharp
             N_GRPID=28,
             S_GRPNAME=29,
             S_GRPCOLOR=30,
-            MAX = 30
+            //S_SubParticles = 31,
+            MAX = 31
         }
 
 
@@ -85,6 +86,7 @@ namespace OTSModelSharp
             AddColumn(new ColumnDefine() { ColumName = "GroupId", ColumType = new ColumnType(ColumnType.ID.INTEGER, false, false), IsPrimarykey = false });
             AddColumn(new ColumnDefine() { ColumName = "GroupName", ColumType = new ColumnType(ColumnType.ID.STRING, false, false), IsPrimarykey = false });
             AddColumn(new ColumnDefine() { ColumName = "GroupColor", ColumType = new ColumnType(ColumnType.ID.STRING, false, false), IsPrimarykey = false });
+            //AddColumn(new ColumnDefine() { ColumName = "SubParticles", ColumType = new ColumnType(ColumnType.ID.STRING, false, false), IsPrimarykey = false });
             SetTableName("IncAData");
 
         }