Пример #1
0
        internal static Line[] findLineCross(Line[] lineAcross)
        {
            ArrayList crossLines    = ArrayList.Synchronized(new ArrayList(10));
            ArrayList lineNeighbor  = ArrayList.Synchronized(new ArrayList(10));
            ArrayList lineCandidate = ArrayList.Synchronized(new ArrayList(10));

            for (int i = 0; i < lineAcross.Length; i++)
            {
                lineCandidate.Add(lineAcross[i]);
            }
            for (int i = 0; i < lineCandidate.Count - 1; i++)
            {
                lineNeighbor.Clear();
                lineNeighbor.Add(lineCandidate[i]);
                for (int j = i + 1; j < lineCandidate.Count; j++)
                {
                    if (Line.isNeighbor((Line)lineNeighbor[lineNeighbor.Count - 1], (Line)lineCandidate[j]))
                    {
                        lineNeighbor.Add(lineCandidate[j]);
                        Line compareLine = (Line)lineNeighbor[lineNeighbor.Count - 1];
                        if (lineNeighbor.Count * 5 > compareLine.Length && j == lineCandidate.Count - 1)
                        {
                            crossLines.Add(lineNeighbor[lineNeighbor.Count / 2]);
                            for (int k = 0; k < lineNeighbor.Count; k++)
                            {
                                lineCandidate.Remove(lineNeighbor[k]);
                            }
                        }
                    }
                    else
                    {
                        if (FinderPattern.cantNeighbor((Line)lineNeighbor[lineNeighbor.Count - 1], (Line)lineCandidate[j]) || j == lineCandidate.Count - 1)
                        {
                            Line compareLine = (Line)lineNeighbor[lineNeighbor.Count - 1];
                            if (lineNeighbor.Count * 6 > compareLine.Length)
                            {
                                crossLines.Add(lineNeighbor[lineNeighbor.Count / 2]);
                                for (int k = 0; k < lineNeighbor.Count; k++)
                                {
                                    lineCandidate.Remove(lineNeighbor[k]);
                                }
                            }
                            break;
                        }
                    }
                }
            }
            Line[] foundLines = new Line[crossLines.Count];
            for (int i = 0; i < foundLines.Length; i++)
            {
                foundLines[i] = (Line)crossLines[i];
            }
            return(foundLines);
        }
Пример #2
0
        internal static Line[] findLineCross(Line[] lineAcross)
        {
            ArrayList arrayList1 = ArrayList.Synchronized(new ArrayList(10));
            ArrayList arrayList2 = ArrayList.Synchronized(new ArrayList(10));
            ArrayList arrayList3 = ArrayList.Synchronized(new ArrayList(10));

            for (int index = 0; index < lineAcross.Length; ++index)
            {
                arrayList3.Add((object)lineAcross[index]);
            }
            for (int index1 = 0; index1 < arrayList3.Count - 1; ++index1)
            {
                arrayList2.Clear();
                arrayList2.Add(arrayList3[index1]);
                for (int index2 = index1 + 1; index2 < arrayList3.Count; ++index2)
                {
                    if (Line.isNeighbor((Line)arrayList2[arrayList2.Count - 1], (Line)arrayList3[index2]))
                    {
                        arrayList2.Add(arrayList3[index2]);
                        Line line = (Line)arrayList2[arrayList2.Count - 1];
                        if (arrayList2.Count * 5 > line.Length && index2 == arrayList3.Count - 1)
                        {
                            arrayList1.Add(arrayList2[arrayList2.Count / 2]);
                            for (int index3 = 0; index3 < arrayList2.Count; ++index3)
                            {
                                arrayList3.Remove(arrayList2[index3]);
                            }
                        }
                    }
                    else if (FinderPattern.cantNeighbor((Line)arrayList2[arrayList2.Count - 1], (Line)arrayList3[index2]) || index2 == arrayList3.Count - 1)
                    {
                        Line line = (Line)arrayList2[arrayList2.Count - 1];
                        if (arrayList2.Count * 6 > line.Length)
                        {
                            arrayList1.Add(arrayList2[arrayList2.Count / 2]);
                            for (int index3 = 0; index3 < arrayList2.Count; ++index3)
                            {
                                arrayList3.Remove(arrayList2[index3]);
                            }
                            break;
                        }
                        break;
                    }
                }
            }
            Line[] lineArray = new Line[arrayList1.Count];
            for (int index = 0; index < lineArray.Length; ++index)
            {
                lineArray[index] = (Line)arrayList1[index];
            }
            return(lineArray);
        }