예제 #1
0
        //�����������
        /// <summary>
        ///�����������
        /// </summary>
        /// <param name="starti">��ʼ�����ڵ���</param>
        /// <param name="store">����˳��</param>
        /// <param name="Sosflag">�����������������</param>
        /// <param name="insectflag">�ཻ������� �ཻΪ1</param>
        ///  <param name="insectpoint">�ཻ�������¼����</param>
        ///  <param name="polyon">�������������</param>
        ///  <param name="vectcollect">�����ཻ��̩ɭ�����</param>
        public void Sospoloy(int starti, bool store, int[] Sosflag,int[] taisflag, int[,] insectflag, PointF[,] insectpoint, Polyon multrect, voronoiboundary tais)
        {
            int m = multrect.Vertices.Count; int n = tais.voronicollect.Count;
            if(store)
            {
                for(int j=starti;j<m;j++)
                {
                    if (Sosflag[j]==1)
                    {
                        return;
                    }
                    else
                    {
                        Sosflag[j] = 1;
                        if (PtInPolygon(multrect.Vertices[j], tais.voronicollect))
                        {
                            if (tais.Vimultptcompare(multrect.Vertices[j]))
                            {
                                tais.vimultcollect.Add(multrect.Vertices[j]);
                            }

                        }
                        for (int i = 0; i < n;i++ )
                        {
                            if (insectflag[i,j] == 1)
                            {
                                insectflag[i,j] = 0;
                                //�ж��ཻ�ĵ��Ƿ���Ƕ˵�
                                if (tais.Vimultptcompare(insectpoint[i, j]))
                                {
                                    tais.vimultcollect.Add(insectpoint[i, j]);
                                }

                                if (PtInPolygon(tais.voronicollect[i], multrect.Vertices))
                                {
                                    if (tais.Vimultptcompare(tais.voronicollect[i]))
                                    {
                                        tais.vimultcollect.Add(tais.voronicollect[i]);
                                    }

                                    //������һѭ���ĺ��� ����Ҫ�жϴ˶���ε�˳�������ʱ�����С�����������С�����˳�� ���������������ǴӴ�С��˳��
                                    if (i < (i + 1) % n)
                                   {
                                       if (!IsCCW(tais.voronicollect))
                                       {
                                           Sospoloy(i, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                       }
                                       else
                                           Sospoloy(i, true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                   }
                                    else
                                    {
                                        if (!IsCCW(tais.voronicollect))
                                        {
                                            Sospoloy(i, true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                        }
                                        else
                                            Sospoloy(i, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                    }

                                }
                                if (PtInPolygon(tais.voronicollect[(i + 1) % n], multrect.Vertices))
                                {
                                    if (tais.Vimultptcompare(tais.voronicollect[(i + 1) % n]))
                                    {
                                        tais.vimultcollect.Add(tais.voronicollect[(i + 1) % n]);
                                    }

                                    //������һѭ���ĺ���
                                    if (i < (i + 1) % n)
                                    {
                                        if (!IsCCW(tais.voronicollect))
                                        {
                                            Sospoloy((i + 1) % n, true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                        }
                                        else
                                            Sospoloy((i + 1) % n, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                    }
                                    else
                                    {
                                        if (!IsCCW(tais.voronicollect))
                                        {
                                            Sospoloy((i + 1) % n, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                        }
                                        else
                                            Sospoloy((i + 1) % n,true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                    }

                                }
                            }
                        }
                    }

                }
            }
            else
            {
                for (int j = starti+m; j >0 ; j--)
                {
                    if (Sosflag[j%m] == 1)
                    {
                        return;
                    }
                    else
                    {
                        Sosflag[j % m] = 1;
                        if (PtInPolygon(multrect.Vertices[j % m], tais.voronicollect))
                        {
                            if (tais.Vimultptcompare(multrect.Vertices[j % m]))
                            {
                                tais.vimultcollect.Add(multrect.Vertices[j % m]);
                            }

                        }
                        for (int i = 0; i < n; i++)
                        {
                            if (insectflag[i,j % m] == 1)
                            {
                                insectflag[i,j % m] = 0;
                                if (tais.Vimultptcompare(insectpoint[i, j % m]))
                                {
                                    tais.vimultcollect.Add(insectpoint[i, j % m]);
                                }

                                if (PtInPolygon(tais.voronicollect[i], multrect.Vertices))
                                {
                                    if (tais.Vimultptcompare(tais.voronicollect[i]))
                                    {
                                        tais.vimultcollect.Add(tais.voronicollect[i]);
                                    }

                                    //������һѭ���ĺ���
                                    if (i < (i + 1) % n)
                                    {
                                        if (!IsCCW(tais.voronicollect))
                                        {
                                            Sospoloy(i, true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                        }
                                        else
                                            Sospoloy(i, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                    }
                                   else
                                    {
                                        if (!IsCCW(tais.voronicollect))
                                        {
                                            Sospoloy(i, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                        }
                                        else
                                            Sospoloy(i, true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                    }

                                }
                                if (PtInPolygon(tais.voronicollect[(i + 1) % n], multrect.Vertices))
                                {
                                    if (tais.Vimultptcompare(tais.voronicollect[(i + 1) % n]))
                                    {
                                        tais.vimultcollect.Add(tais.voronicollect[(i + 1) % n]);
                                    }

                                    //������һѭ���ĺ���
                                    if (i < (i + 1) % n)
                                    {
                                        if (!IsCCW(tais.voronicollect))
                                        {
                                            Sospoloy((i + 1) % n, true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                        }
                                        else
                                            Sospoloy((i + 1) % n, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                    }
                                    else
                                    {
                                        if (!IsCCW(tais.voronicollect))
                                        {
                                            Sospoloy((i + 1) % n, false, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                        }
                                        else
                                            Sospoloy((i + 1) % n, true, Sosflag, taisflag, insectflag, insectpoint, tais, multrect);
                                    }

                                }
                            }
                        }
                    }

                }
            }
        }
예제 #2
0
        //����̩ɭ�����
        /// <summary>
        ///����̩ɭ�����
        /// </summary>
        /// <param name="starti">��ʼ�����ڵ���</param>
        /// <param name="store">����˳��</param>
        /// <param name="Sosflag">�����������������</param>
        /// <param name="insectflag">�ཻ������� �ཻΪ1</param>
        ///  <param name="insectpoint">�ཻ�������¼����</param>
        ///  <param name="polyon">�������������</param>
        ///  <param name="vectcollect">�����ཻ��̩ɭ�����</param>
        public void Sospoloy(int starti, bool store, int[] Sosflag, int[] taisflag,int[,] insectflag, PointF[,] insectpoint, voronoiboundary tais,Polyon multrect )
        {
            int m = multrect.Vertices.Count; int n = tais.voronicollect.Count;
            if (store)
            {
                for (int i = starti; i< n; i++)
                {
                    if (taisflag[i] == 1)
                    {
                        return;
                    }
                    else
                    {
                        taisflag[i] = 1;
                        if (PtInPolygon(tais.voronicollect[i], multrect.Vertices))
                        {
                            if (tais.Vimultptcompare(tais.voronicollect[i]))
                            {
                                tais.vimultcollect.Add(tais.voronicollect[i]);
                            }

                        }
                        for (int j = 0; j < m; j++)
                        {
                            if (insectflag[i,j] == 1)
                            {
                                insectflag[i,j] = 0;
                                if (tais.Vimultptcompare(insectpoint[i, j]))
                                {
                                    tais.vimultcollect.Add(insectpoint[i, j]);
                                }

                                if (PtInPolygon(multrect.Vertices[j], tais.voronicollect))
                                {
                                    if (tais.Vimultptcompare(multrect.Vertices[j]))
                                    {
                                        tais.vimultcollect.Add(multrect.Vertices[j]);
                                    }

                                    //������һ����ε�ѭ�� ����Ҫ�жϴ˶������ʲô˳��
                                    if (j < (j + 1) % m)
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy(j, false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy(j, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }
                                    else
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy(j, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy(j, false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }

                                }
                                if (PtInPolygon(multrect.Vertices[(j + 1) % m], tais.voronicollect))
                                {
                                    if (tais.Vimultptcompare(multrect.Vertices[(j + 1) % m]))
                                    {
                                        tais.vimultcollect.Add(multrect.Vertices[(j + 1) % m]);
                                    }

                                    //������һ����ε�ѭ��
                                    if (j < (j + 1) % m)
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy((j + 1) % m, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy((j + 1) % m, false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }
                                    else
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy((j + 1) % m, false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy((j + 1) % m, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }

                                }
                            }
                        }
                    }

                }
            }
            else
            {
                for (int i= starti + n; i > 0; i--)
                {
                    if (taisflag[i % n] == 1)
                    {
                        return;
                    }
                    else
                    {
                       taisflag[i% n] = 1;
                        if (PtInPolygon(tais.voronicollect[i % n], multrect.Vertices))
                        {
                            if (tais.Vimultptcompare(tais.voronicollect[i % n]))
                            {
                                tais.vimultcollect.Add(tais.voronicollect[i % n]);
                            }

                        }
                        for (int j = 0; j < m; j++)
                        {
                            if (insectflag[i%n,j] == 1)
                            {
                                insectflag[i % n,j] = 0;
                                if (tais.Vimultptcompare(insectpoint[i % n, j]))
                                {
                                    tais.vimultcollect.Add(insectpoint[i % n, j]);
                                }

                                if (PtInPolygon(multrect.Vertices[j], tais.voronicollect))
                                {
                                    if (tais.Vimultptcompare(multrect.Vertices[j]))
                                    {
                                        tais.vimultcollect.Add(multrect.Vertices[j]);
                                    }

                                    //������һ���ѭ��
                                    if (j < (j + 1) % m)
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy(j, false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy(j, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }

                                    else
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy(j, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy(j,false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }
                                }
                                if (PtInPolygon(multrect.Vertices[(j + 1) % m], tais.voronicollect))
                                {
                                    if (tais.Vimultptcompare(multrect.Vertices[(j + 1) % m]))
                                    {
                                        tais.vimultcollect.Add(multrect.Vertices[(j + 1) % m]);
                                    }

                                    //����Ҫѭ��������
                                    if (j < (j + 1) % m)
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy((j + 1) % m, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy((j + 1) % m, false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }
                                   else
                                    {
                                        if (!IsCCW(multrect.Vertices))
                                        {
                                            Sospoloy((j + 1) % m, false, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                        }
                                        else
                                            Sospoloy((j + 1) % m, true, Sosflag, taisflag, insectflag, insectpoint, multrect, tais);
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }