|
|
@@ -752,106 +752,106 @@ namespace OTSModelSharp
|
|
|
m_smallParticlePercentage = percentageOfWhole;
|
|
|
}
|
|
|
|
|
|
- //public bool GetFeatureList1(List<COTSSegment> a_listSegments, List<COTSFeature> a_listFeatures)
|
|
|
- //{
|
|
|
- // List<COTSSegment> listSegmentNew = new List<COTSSegment>();
|
|
|
- // Dictionary<long, List<COTSSegment>> mapOneLineSegments = new Dictionary<long, List<COTSSegment>>();
|
|
|
- // foreach(var s in a_listSegments)
|
|
|
- // {
|
|
|
- // mapOneLineSegments[s.GetHeight()].Add(s);//sorting all the segments base on the line number.
|
|
|
- // }
|
|
|
- // var first = mapOneLineSegments.First();
|
|
|
- // KeyValuePair<long, List<COTSSegment>> lineItr = first.Value;
|
|
|
- // mapOneLineSegments.Keys();//find the highest line
|
|
|
- // while (lineItr != mapOneLineSegments.Last())
|
|
|
- // {
|
|
|
- // for (var s = lineItr.Values.First; s < lineItr.second.end();)//find one segment of this line.
|
|
|
- // {
|
|
|
- // COTSSegment bottomSeg = *s;
|
|
|
- // listSegmentNew.Clear();
|
|
|
- // listSegmentNew.Add(s);
|
|
|
- // s = lineItr.second.erase(s);
|
|
|
- // Dictionary<List<long>, List<COTSSegment>> tempItr = lineItr;
|
|
|
- // tempItr++;
|
|
|
- // for (; tempItr != mapOneLineSegments.end(); tempItr++)//find all other lines of segments
|
|
|
- // {
|
|
|
- // if (tempItr.first - bottomSeg.GetHeight() > 1)
|
|
|
- // {
|
|
|
- // break;
|
|
|
- // }
|
|
|
-
|
|
|
- // for (var nextLineSegment = tempItr.second.begin(); nextLineSegment < tempItr.second.end();)//find next line's all segments
|
|
|
- // {
|
|
|
- // if (((*nextLineSegment)->GetStart() - (bottomSeg.GetStart() + bottomSeg.GetLength())) > 1)
|
|
|
- // {
|
|
|
- // break;
|
|
|
- // }
|
|
|
-
|
|
|
- // if (bottomSeg.UpDownConection(**nextLineSegment))
|
|
|
- // {
|
|
|
- // listSegmentNew.Add(*nextLineSegment);
|
|
|
- // bottomSeg = *nextLineSegment;
|
|
|
- // nextLineSegment = tempItr.second.erase(nextLineSegment);
|
|
|
- // break;
|
|
|
- // }
|
|
|
+ public bool GetFeatureList1(List<COTSSegment> a_listSegments, List<COTSFeature> a_listFeatures)
|
|
|
+ {
|
|
|
+ List<COTSSegment> listSegmentNew = new List<COTSSegment>();
|
|
|
+ Dictionary<long, List<COTSSegment>> mapOneLineSegments = new Dictionary<long, List<COTSSegment>>();
|
|
|
+ foreach(var s in a_listSegments)
|
|
|
+ {
|
|
|
+ mapOneLineSegments[s.GetHeight()].Add(s);//sorting all the segments base on the line number.
|
|
|
+ }
|
|
|
+ var first = mapOneLineSegments.First();
|
|
|
+ Dictionary<long, List<COTSSegment>> lineItr = first.Value;
|
|
|
+ // mapOneLineSegments.Keys();//find the highest line
|
|
|
+ while (lineItr != mapOneLineSegments.Last())
|
|
|
+ {
|
|
|
+ for (var s = lineItr.Value.First; s < lineItr.Value.Last;)//find one segment of this line.
|
|
|
+ {
|
|
|
+ COTSSegment bottomSeg = *s;
|
|
|
+ listSegmentNew.Clear();
|
|
|
+ listSegmentNew.Add(s);
|
|
|
+ s = lineItr.Value.Last.erase(s);
|
|
|
+ Dictionary<List<long>, List<COTSSegment>> tempItr = lineItr;
|
|
|
+ tempItr++;
|
|
|
+ for (; tempItr != mapOneLineSegments.Last(); tempItr++)//find all other lines of segments
|
|
|
+ {
|
|
|
+ if (tempItr.First - bottomSeg.GetHeight > 1)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- // if (tempItr.second.size() > 0)
|
|
|
- // {
|
|
|
- // nextLineSegment++;
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
+ for (var nextLineSegment = tempItr.Values.Last; nextLineSegment < tempItr.Values.Last;)//find next line's all segments
|
|
|
+ {
|
|
|
+ if (((*nextLineSegment)->GetStart() - (bottomSeg.GetStart() + bottomSeg.GetLength())) > 1)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bottomSeg.UpDownConection(**nextLineSegment))
|
|
|
+ {
|
|
|
+ listSegmentNew.Add(*nextLineSegment);
|
|
|
+ bottomSeg = *nextLineSegment;
|
|
|
+ nextLineSegment = tempItr.Values.erase(nextLineSegment);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tempItr.Values.size() > 0)
|
|
|
+ {
|
|
|
+ nextLineSegment++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // }
|
|
|
- // COTSFeature pFeature = new COTSFeature();
|
|
|
- // pFeature.SetSegmentsList(listSegmentNew);
|
|
|
- // //check if this new feature is connected with other found feature.
|
|
|
- // COTSSegment topSeg = listSegmentNew[0];//find the toppest segment of this new feature.
|
|
|
- // COTSSegment bottomSegment = listSegmentNew[listSegmentNew.Count - 1];//find the lowest segment of this new feature.
|
|
|
-
|
|
|
- // bool haveMerged = false;
|
|
|
- // foreach(var f in a_listFeatures)
|
|
|
+ }
|
|
|
+ COTSFeature pFeature = new COTSFeature();
|
|
|
+ pFeature.SetSegmentsList(listSegmentNew);
|
|
|
+ //check if this new feature is connected with other found feature.
|
|
|
+ COTSSegment topSeg = listSegmentNew[0];//find the toppest segment of this new feature.
|
|
|
+ COTSSegment bottomSegment = listSegmentNew[listSegmentNew.Count - 1];//find the lowest segment of this new feature.
|
|
|
+
|
|
|
+ bool haveMerged = false;
|
|
|
+ foreach(var f in a_listFeatures)
|
|
|
|
|
|
- // {
|
|
|
- // foreach (var seg in f.GetSegmentsList())
|
|
|
- // {
|
|
|
- // if (bottomSegment.UpDownConection(seg) || topSeg.UpDownConection(seg))
|
|
|
- // {
|
|
|
- // List<COTSSegment> segs = f.GetSegmentsList();
|
|
|
- // foreach (var s in listSegmentNew)
|
|
|
- // {
|
|
|
- // segs.Add(s);
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // f.SetSegmentsList(segs);
|
|
|
- // haveMerged = true;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (haveMerged)
|
|
|
- // {
|
|
|
- // break;
|
|
|
- // }
|
|
|
+ {
|
|
|
+ foreach (var seg in f.GetSegmentsList())
|
|
|
+ {
|
|
|
+ if (bottomSegment.UpDownConection(seg) || topSeg.UpDownConection(seg))
|
|
|
+ {
|
|
|
+ List<COTSSegment> segs = f.GetSegmentsList();
|
|
|
+ foreach (var s in listSegmentNew)
|
|
|
+ {
|
|
|
+ segs.Add(s);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ f.SetSegmentsList(segs);
|
|
|
+ haveMerged = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (haveMerged)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- // }
|
|
|
- // if (!haveMerged)
|
|
|
- // {
|
|
|
- // a_listFeatures.Add(pFeature);
|
|
|
- // }
|
|
|
+ }
|
|
|
+ if (!haveMerged)
|
|
|
+ {
|
|
|
+ a_listFeatures.Add(pFeature);
|
|
|
+ }
|
|
|
|
|
|
- // if (lineItr.second.size() == 0)
|
|
|
- // {
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // lineItr++;
|
|
|
- // }
|
|
|
- // return true;
|
|
|
- //}
|
|
|
+ if (lineItr.second.size() == 0)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lineItr++;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
public bool GetIncAParticleList(List<COTSParticle> a_listParticleOut)
|
|
|
{
|