Browse Source

improve the RemoveDuplicateOverlapParticles algorithm

gsp 1 year ago
parent
commit
3b3684d48b
1 changed files with 31 additions and 3 deletions
  1. 31 3
      OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

+ 31 - 3
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

@@ -240,7 +240,7 @@ namespace OTSDataType
                         p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
                         COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
                         PointF p1Center = p1rec.GetCenterPoint();
-                       if(Math.Abs(pcenter.X-p1Center.X)<2*overlap && Math.Abs(pcenter.Y-p1Center.Y)<2*overlap)
+                        if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
                         {
                             if (p.CalculateSimilarity(p1) > 0.95)
                             {
@@ -248,14 +248,21 @@ namespace OTSDataType
                                 break;
                             }
                         }
-                        
+
                     }
                     if (findsimilar == false)
                     {
                         finalparts.Add(p);
                     }
 
-                
+
+                }
+            }
+            else 
+            {
+                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.LEFT, overlap))
+                {
+                    finalparts.Add(p);
                 }
             }
             if (upField != null && upField.measureSequence < this.measureSequence)
@@ -292,6 +299,13 @@ namespace OTSDataType
 
                 }
             }
+            else
+            {
+                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap))
+                {
+                    finalparts.Add(p);
+                }
+            }
             if (rightField != null && rightField.measureSequence < this.measureSequence)
             {
                 foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.RIGHT, overlap))
@@ -326,6 +340,13 @@ namespace OTSDataType
 
                 }
             }
+            else
+            {
+                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.RIGHT, overlap))
+                {
+                    finalparts.Add(p);
+                }
+            }
             if (downField != null && downField.measureSequence < this.measureSequence)
             {
                 foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.DOWN, overlap))
@@ -360,6 +381,13 @@ namespace OTSDataType
 
                 }
             }
+            else
+            {
+                foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.DOWN, overlap))
+                {
+                    finalparts.Add(p);
+                }
+            }
 
             foreach (var p in this.GetSideParticlesByOverlap(SORTING_DIRECTION.CENTER, overlap))
             {