Esempio n. 1
0
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            // TODO: Get the object to display a visualizer for.
            //       Cast the result of objectProvider.GetObject()
            //       to the type of the object being visualized.
            IPositionSet data = (IPositionSet)objectProvider.GetObject();

            // TODO: Display your view of the object.
            //       Replace displayForm with your own custom Form or Control.

            //RandomPositionSet data = new RandomPositionSet(100, -1000, 1000);

            LayersExOptDlg Painter = new LayersExOptDlg();

            using (LayersPainterForm frmPainter = new LayersPainterForm(Painter))
            {
                //PainterDialog.DrawPositionSet(data);

                Layer lay = new Layer_PositionSet_Point(data);
                Painter.Add(lay);
                frmPainter.Show();
                frmPainter.Refresh();

                frmPainter.Visible = false;

                //displayForm.Text = data.ToString();
                windowService.ShowDialog(frmPainter);
            }
        }
Esempio n. 2
0
        private void TestBotton_Click(object sender, EventArgs e)
        {
            LayersExOptDlg layers = new LayersExOptDlg();
            RandomPositionSet_InFixedDistribution randomPositionSet1 = new RandomPositionSet_InFixedDistribution
                                                                           (10000, distributionStyle.GaussianDistribution);

            new ConfiguratedByForm(randomPositionSet1);
            randomPositionSet1.Produce();

            layers.Add(new Layer_PositionSet_Point(randomPositionSet1));

            LayersEditerForm positionSetEditerForm = new LayersEditerForm(layers);

            positionSetEditerForm.Show();
        }
        private void SelectBotton_Click(object sender, EventArgs e)
        {
            layersPaintedControl.state_PainterForm_MouseDown = LayersPaintedControl.State_PainterForm_MouseDown.onDaggle;
            ResetEventHandler();
            //layersPainterForm.state_PainterForm_MouseDown = LayersPainterForm.State_PainterForm_MouseDown.Other;
            IPosition nearestPoint = new Position_Point(0, 0);
            PositionSetEdit_ImplementByICollectionTemplate positionSetEdit_ImplementByICollectionTemplate = new PositionSetEdit_ImplementByICollectionTemplate();

            positionSetEdit_ImplementByICollectionTemplate.AddPosition(nearestPoint);
            Layer_PositionSet_Square layer = new Layer_PositionSet_Square(positionSetEdit_ImplementByICollectionTemplate);

            MouseMovedRealPosition = delegate(IPosition position)
            {
                positionSetEdit_ImplementByICollectionTemplate.RemovePosition(nearestPoint);
                nearestPoint = m2m_NN.NearestNeighbor(position);
                positionSetEdit_ImplementByICollectionTemplate.AddPosition(nearestPoint);
                layer.SpringLayerRepresentationChangedEvent(layer);
                layersPaintedControl.Invalidate();
            };

            layer.VisibleInOptDlg = false;
            layer.Active          = true;
            layer.Name            = "Edited Figure";
            layer.SquareFrameDrawer.RectangleRadiusWidth = 8;
            layer.SquareFrameDrawer.LineWidth            = 1;
            layer.SquareFrameDrawer.LineColor            = Color.YellowGreen;
            layer.CenterPointCoordinate.Visible          = true;
            layer.CenterPointCoordinate.CoordinateFont   = new Font(layer.CenterPointCoordinate.CoordinateFont, FontStyle.Bold);

            //layer.Point.IsDrawPointBorder = true;
            //layer.Point.PointColor = Color.Red;
            //layer.Point.PointRadius = 3;
            //layer.PointCoordinate.CoordinateFont = new Font(layer.PointCoordinate.CoordinateFont, FontStyle.Bold);
            //layer.PointCoordinate.Visible = true;

            if (currentLayer != null)
            {
                layers.Remove(currentLayer);
            }
            currentLayer = layer;
            layers.Add(layer);
        }
        protected void runDemo(IPositionSet set)
        {
            //以下代码必须在UI线程中调用,即不能在另开的线程中调用
            LayersExOptDlg       layers               = new LayersExOptDlg();
            LayersPainterForm    layersPainterForm    = new LayersPainterForm(layers);
            LayersPaintedControl layersPaintedControl = layersPainterForm.LayersPaintedControl;
            LayersEditedControl  layersEditedControl  = new LayersEditedControl();

            layersEditedControl.Dock = DockStyle.Top;
            layersEditedControl.LayersPaintedControl = layersPaintedControl;
            layersPainterForm.Controls.Add(layersEditedControl);
            FlowControlerForm flowControlerForm = new FlowControlerForm();

            layersPainterForm.Show();
            flowControlerForm.Show(layersPainterForm);

            //新建或外部传入待演示对象
            M2M_NN m2m_NN = new M2M_NN();
            M2M_CH m2m_CH = new M2M_CH();

            //打开一个Worker线程来进行算法流程的演示(否则会阻塞UI线程以至于演示不能进行)
            IAsyncResult result = new dDemoProcess(delegate
            {
                ////产生随机点集:
                //RandomPositionSet_InFixedDistribution randomPositionSet_InFixedDistribution = new RandomPositionSet_InFixedDistribution();
                //randomPositionSet_InFixedDistribution.PointNum = 100000;
                //randomPositionSet_InFixedDistribution.DistributionStyle = distributionStyle.ClusterGaussianDistribution;
                //new ConfiguratedByForm(randomPositionSet_InFixedDistribution);
                //randomPositionSet_InFixedDistribution.Produce();

                //编辑点集
                Layer_PositionSet layer;
                if (set is IPositionSet_Connected)
                {
                    layer = new Layer_PositionSet_Connected((IPositionSet_Connected)set);
                    ((Layer_PositionSet_Connected)layer).Point.PointColor        = Color.Yellow;
                    ((Layer_PositionSet_Connected)layer).Point.PointRadius       = 2;
                    ((Layer_PositionSet_Connected)layer).Point.IsDrawPointBorder = true;
                }
                else
                {
                    layer = new Layer_PositionSet_Point(set);
                    ((Layer_PositionSet_Point)layer).Point.PointColor        = Color.Yellow;
                    ((Layer_PositionSet_Point)layer).Point.PointRadius       = 2;
                    ((Layer_PositionSet_Point)layer).Point.IsDrawPointBorder = true;
                }
                layer.EditAble = true;
                layers.Add(layer);
                layersPainterForm.Invalidate();
                flowControlerForm.SuspendAndRecordWorkerThread();
                //layers.Remove(layer);

                ///////////////////////////////////////
                //GetRandomPositionFromPositionSetRectangle getRandomPositionFromPositionSetRectangle
                //= new GetRandomPositionFromPositionSetRectangle(randomPositionSet_InFixedDistribution);

                ////对m2m_NN算法进行演示:
                ////为对象的事件添加事件响应,以进行算法演示
                //AlgorithmDemo_M2M_NN algorithmDemo_M2M_NN = new AlgorithmDemo_M2M_NN(m2m_NN, layers, flowControlerForm, layersPaintedControl.Invalidate);

                ////以下代码与非演示状态一样。
                //m2m_NN.PreProcess(randomPositionSet_InFixedDistribution);
                //m2m_NN.NearestNeighbor(layersPaintedControl.GetMouseDoubleChickedRealPosition());
                //while (true)
                //{
                //    for (int i = layers.Count - 1; i >= 0; i--)
                //    {
                //        if ((layers[i].Name != "M2MStructure") && (layers[i].Name != "PositionSetOfComparedPoint"))
                //        {
                //            layers.Remove(layers[i]);
                //        }
                //    }

                //    m2m_NN.NearestNeighbor(getRandomPositionFromPositionSetRectangle.Get());
                //}

                ////结束演示(解除事件响应的绑定)
                //algorithmDemo_M2M_NN.EndDemo();
                ///////////////////////////////////////

                //对m2m_CH算法进行演示:
                //为对象的事件添加事件响应,以进行算法演示
                //AlgorithmDemo_M2M_CH algorithmDemo_M2M_CH = new AlgorithmDemo_M2M_CH(m2m_CH, layers, flowControlerForm, layersPaintedControl.Invalidate);
                //while (true)
                //{
                //    layers.Clear();
                //    //以下代码与非演示状态一样。
                //    m2m_CH.ConvexHull(randomPositionSet_InFixedDistribution.Produce());
                //}

                ////结束演示(解除事件响应的绑定)
                //algorithmDemo_M2M_CH.EndDemo();
            }).BeginInvoke(null, null);
        }
        private void preProcessForPositionSetConnectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IPositionSet_Connected pSet = (IPositionSet_Connected)positionSetContainer.GetPositionSet();

            LayersExOptDlg       layers               = new LayersExOptDlg();
            LayersPainterForm    layersPainterForm    = new LayersPainterForm(layers);
            LayersPaintedControl layersPaintedControl = layersPainterForm.LayersPaintedControl;
            LayersEditedControl  layersEditedControl  = new LayersEditedControl();

            layersEditedControl.Dock = DockStyle.Top;
            layersEditedControl.LayersPaintedControl = layersPaintedControl;
            layersPainterForm.Controls.Add(layersEditedControl);

            Layer_PositionSet_Connected layer_PositionSet_Connected = new Layer_PositionSet_Connected(pSet);

            layer_PositionSet_Connected.Point.PointColor     = Color.Yellow;
            layer_PositionSet_Connected.Connection.LineColor = Color.Blue;
            layer_PositionSet_Connected.Connection.LineWidth = 0.6f;
            layer_PositionSet_Connected.Point.PointRadius    = 1.2f;
            layers.Add(layer_PositionSet_Connected);
            layer_PositionSet_Connected.SpringLayerRepresentationChangedEvent(layer_PositionSet_Connected);


            M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture();

            m2m_Creater_ForGeneralM2MStruture.PartType = typeof(Part_Multi);
            m2m_Creater_ForGeneralM2MStruture.SetPointInPartFactor(50);
            m2m_Creater_ForGeneralM2MStruture.SetUnitNumInGridLength(3);

            IM2MStructure m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(pSet);

            m2mStructure.Preprocessing(pSet);

            BuildPartSetConnectionForM2MStructure buildPartSetConnectionForM2MStructure = new BuildPartSetConnectionForM2MStructure();

            buildPartSetConnectionForM2MStructure.TraversalEveryLevelAndBuild(m2mStructure);

            layers.Add(new Layer_M2MStructure(m2mStructure));

            for (int levelSequence = 1; levelSequence < m2mStructure.GetLevelNum(); levelSequence++)
            {
                //ILevel level = m2mStructure.GetLevel(levelSequence);
                //IPart rootPart = m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0);
                //IPositionSet positionSet = m2mStructure.GetDescendentPositionSetByAncestorPart(levelSequence, rootPart, 0);

                //List<IPosition_Connected> position_ConnectedList = new List<IPosition_Connected>();
                //positionSet.InitToTraverseSet();
                //while (positionSet.NextPosition())
                //{
                //    position_ConnectedList.Add((IPosition_Connected)positionSet.GetPosition());
                //}

                //PositionSet_Connected positionSet_Connected = new PositionSet_Connected(position_ConnectedList);

                Layer_PartSet_Connected layer_PartSet_Connected = new Layer_PartSet_Connected(m2mStructure, levelSequence);
                //layer_PartSet_Connected.MainColor
                //layer_PartSet_Connected.Active = true;
                //layer_PartSet_Connected.SetPositionSetTransformByM2MLevel(level);

                layers.Add(layer_PartSet_Connected);
            }

            layersPainterForm.ShowDialog();
        }
        private void pathFindingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IPositionSet_Connected positionSet_Connected = (IPositionSet_Connected)positionSetContainer.GetPositionSet();

            Dijkstra dijkstra = new Dijkstra();
            AStar    astar    = new AStar();
            M2M_PF   m2m_PF   = new M2M_PF();

            IM2MStructure m2mStructure = null;

            List <IPosition_Connected> m2mPath = null;
            List <IPosition_Connected> path    = null;

            //计算算法运行时间用
            //IPosition_Connected start = null;
            //IPosition_Connected end = null;
            ISearchPathEngine searchPathEngine1 = m2m_PF;
            ISearchPathEngine searchPathEngine2 = dijkstra;

            m2m_PF.GetM2MStructure             += delegate(IM2MStructure m2mS) { m2mStructure = m2mS; };
            m2m_PF.GetM2MStructureInPreprocess += delegate(IM2MStructure m2mS) { m2mStructure = m2mS; };
            List <ushort> timeStampList = new List <ushort>();

            m2m_PF.GetTimeStamp += delegate(ushort timeStamp) { timeStampList.Add(timeStamp); };

            searchPathEngine1.InitEngineForMap(positionSet_Connected);
            searchPathEngine2.InitEngineForMap(positionSet_Connected);

            //以下代码必须在UI线程中调用,即不能在另开的线程中调用
            LayersExOptDlg       layers               = new LayersExOptDlg();
            LayersPainterForm    layersPainterForm    = new LayersPainterForm(layers);
            LayersPaintedControl layersPaintedControl = layersPainterForm.LayersPaintedControl;
            LayersEditedControl  layersEditedControl  = new LayersEditedControl();

            layersEditedControl.Dock = DockStyle.Top;
            layersEditedControl.LayersPaintedControl = layersPaintedControl;
            layersPainterForm.Controls.Add(layersEditedControl);
            layersPainterForm.Show();

            //打开一个Worker线程来进行算法流程的演示(否则会阻塞UI线程以至于演示不能进行)
            IAsyncResult result = new dDemoProcess(delegate
            {
                Layer_PositionSet_Connected layer_PositionSet_Connected = new Layer_PositionSet_Connected(positionSet_Connected);
                layer_PositionSet_Connected.Point.PointColor            = Color.Yellow;
                layer_PositionSet_Connected.Connection.LineColor        = Color.Blue;
                layer_PositionSet_Connected.Connection.LineWidth        = 0.6f;
                layer_PositionSet_Connected.Point.PointRadius           = 1.2f;
                layers.Add(layer_PositionSet_Connected);
                layer_PositionSet_Connected.SpringLayerRepresentationChangedEvent(layer_PositionSet_Connected);

                for (int levelSequence = 1; levelSequence < m2mStructure.GetLevelNum(); levelSequence++)
                {
                    Layer_PartSet_Connected layer_PartSet_Connected = new Layer_PartSet_Connected(m2mStructure, levelSequence);
                    layer_PartSet_Connected.Visible = false;
                    layers.Add(layer_PartSet_Connected);
                }

                while (true)
                {
                    IPosition_Connected start = (IPosition_Connected)layersEditedControl.GetMouseDoubleChickedNearestPositionInCurrentPositionSet(positionSet_Connected);
                    PositionSet_ConnectedEdit startPointSet = new PositionSet_ConnectedEdit();
                    startPointSet.AddPosition_Connected(start);
                    Layer_PositionSet_Point layerStartPoint = new Layer_PositionSet_Point(startPointSet);
                    layerStartPoint.Active = true;
                    layerStartPoint.Point.IsDrawPointBorder = true;
                    layerStartPoint.Point.PointRadius       = 5;
                    layerStartPoint.Point.PointColor        = Color.PaleGreen;
                    layers.Add(layerStartPoint);
                    layerStartPoint.SpringLayerRepresentationChangedEvent(layerStartPoint);

                    IPosition_Connected end = (IPosition_Connected)layersEditedControl.GetMouseDoubleChickedNearestPositionInCurrentPositionSet(positionSet_Connected);
                    PositionSet_ConnectedEdit endPointSet = new PositionSet_ConnectedEdit();
                    endPointSet.AddPosition_Connected(end);
                    Layer_PositionSet_Point layerEndPoint = new Layer_PositionSet_Point(endPointSet);
                    layerEndPoint.Active = true;
                    layerEndPoint.Point.IsDrawPointBorder = true;
                    layerEndPoint.Point.PointRadius       = 5;
                    layerEndPoint.Point.PointColor        = Color.Cyan;
                    layers.Add(layerEndPoint);
                    layerEndPoint.SpringLayerRepresentationChangedEvent(layerEndPoint);

                    CountTimeTool.TimeCounter timeCounter = new CountTimeTool.TimeCounter();

                    searchPathEngine2.InitEngineForMap(positionSet_Connected);
                    double time2      = timeCounter.CountTimeForRepeatableMethod(delegate { searchPathEngine2.SearchPath(start, end); });
                    path              = searchPathEngine2.SearchPath(start, end);
                    float pathLength2 = ((Dijkstra)searchPathEngine2).GetPathLength();
                    Console.WriteLine("Dijkstra consume time: " + time2 + " path Length = " + pathLength2);

                    searchPathEngine1.InitEngineForMap(positionSet_Connected);

                    //清空timeStampList以记录寻径过程各层的timeStamp
                    double time1 = timeCounter.CountTimeForRepeatableMethod(delegate { searchPathEngine1.SearchPath(start, end); });

                    timeStampList.Clear();
                    m2mPath           = searchPathEngine1.SearchPath(start, end);
                    float pathLength1 = ((M2M_PF)searchPathEngine1).GetPathLength();

                    Console.WriteLine("M2M_PF   consume time: " + time1 + " path Length = " + pathLength1);
                    //searchPathEngine1.SearchPath(start, end);

                    if (searchPathEngine1 is M2M_PF && m2mStructure != null)
                    {
                        for (int levelSequence = 1; levelSequence < m2mStructure.GetLevelNum(); levelSequence++)
                        {
                            ILevel level             = m2mStructure.GetLevel(levelSequence);
                            IPart rootPart           = m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0);
                            IPositionSet positionSet = m2mStructure.GetDescendentPositionSetByAncestorPart(levelSequence, rootPart, 0);

                            List <IPosition_Connected> position_ConnectedList = new List <IPosition_Connected>();
                            positionSet.InitToTraverseSet();
                            while (positionSet.NextPosition())
                            {
                                if (positionSet.GetPosition() is IPart_Multi)
                                {
                                    IPart_Multi partMulti = (IPart_Multi)positionSet.GetPosition();
                                    IEnumerable <IPart_Connected> part_ConnectedEnumerable = partMulti.GetSubPartSet();

                                    foreach (IPart_Connected part in part_ConnectedEnumerable)
                                    {
                                        IPosition_Connected tempPartConnected = (IPosition_Connected)part;
                                        if (((Tag_M2M_Part)tempPartConnected.GetAttachment()).isNeedToSearch == true)
                                        {
                                            if (timeStampList[levelSequence - 1] == ((Tag_M2M_Part)tempPartConnected.GetAttachment()).timeStamp)
                                            {
                                                position_ConnectedList.Add(tempPartConnected);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    IPosition_Connected tempPartConnected = (IPosition_Connected)positionSet.GetPosition();
                                    if (((Tag_M2M_Part)tempPartConnected.GetAttachment()).isNeedToSearch == true)
                                    {
                                        if (timeStampList[levelSequence - 1] == ((Tag_M2M_Part)tempPartConnected.GetAttachment()).timeStamp)
                                        {
                                            position_ConnectedList.Add(tempPartConnected);
                                        }
                                    }
                                }
                            }

                            IPositionSet partSet = new PositionSet_Connected(position_ConnectedList);

                            Layer_M2MPartSetInSpecificLevel layer_M2MPartSetInSpecificLevel = new Layer_M2MPartSetInSpecificLevel(m2mStructure.GetLevel(levelSequence), partSet);
                            layer_M2MPartSetInSpecificLevel.Active = true;
                            layer_M2MPartSetInSpecificLevel.Alpha  = 100;
                            //layer_M2MPartSetInSpecificLevel.

                            layers.Add(layer_M2MPartSetInSpecificLevel);

                            //PositionSet_Connected partSet_Connected = new PositionSet_Connected(position_ConnectedList);

                            //Layer_PositionSet_Connected layer_PartSet_Connected = new Layer_PositionSet_Connected(partSet_Connected);
                            ////layer_PartSet_Connected.MainColor
                            ////layer_PartSet_Connected.Active = true;
                            //layer_PartSet_Connected.SetPositionSetTransformByM2MLevel(level);

                            //layers.Add(layer_PartSet_Connected);
                        }
                    }

                    if (path != null)
                    {
                        Layer_PositionSet_Path layer = new Layer_PositionSet_Path(new PositionSet_Connected(path));
                        layer.Active                      = true;
                        layer.PathLine.LineColor          = Color.Black;
                        layer.PathLine.LineWidth          = 2;
                        layer.PathPoint.PointRadius       = 2;
                        layer.PathPoint.IsDrawPointBorder = true;

                        //layer.EditAble = true;
                        //layer.Point.PointColor = Color.Yellow;
                        //layer.Point.PointRadius = 2;
                        //layer.Point.IsDrawPointBorder = true;
                        layers.Add(layer);
                        layer.SpringLayerRepresentationChangedEvent(layer);
                    }
                    else
                    {
                        this.BeginInvoke(new dShow(MessageBox.Show), new object[] { "There is no path between two node" });
                    }

                    if (m2mPath != null)
                    {
                        Layer_PositionSet_Path layer = new Layer_PositionSet_Path(new PositionSet_Connected(m2mPath));
                        layer.Active                      = true;
                        layer.PathLine.LineColor          = Color.Red;
                        layer.PathLine.LineWidth          = 2;
                        layer.PathPoint.PointRadius       = 2;
                        layer.PathPoint.IsDrawPointBorder = true;

                        //layer.EditAble = true;
                        //layer.Point.PointColor = Color.Yellow;
                        //layer.Point.PointRadius = 2;
                        //layer.Point.IsDrawPointBorder = true;
                        layers.Add(layer);
                        layer.SpringLayerRepresentationChangedEvent(layer);
                    }
                    else
                    {
                        this.BeginInvoke(new dShow(MessageBox.Show), new object[] { "There is no path between two node by M2M_PF" });
                    }
                }
            }).BeginInvoke(null, null);
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            M2M_CD M2M_CD = new M2M_CD();

            new ConfiguratedByForm(M2M_CD);

            //以下代码必须在UI线程中调用,即不能在另开的线程中调用
            LayersExOptDlg       layers               = new LayersExOptDlg();
            LayersPainterForm    layersPainterForm    = new LayersPainterForm(layers);
            LayersPaintedControl layersPaintedControl = layersPainterForm.LayersPaintedControl;
            LayersEditedControl  layersEditedControl  = new LayersEditedControl();

            layersEditedControl.Dock = DockStyle.Top;
            layersEditedControl.LayersPaintedControl = layersPaintedControl;
            layersPainterForm.Controls.Add(layersEditedControl);
            FlowControlerForm flowControlerForm = new FlowControlerForm();

            layersPainterForm.Show();
            flowControlerForm.Show(layersPainterForm);

            //新建或外部传入待演示对象



            //打开一个Worker线程来进行算法流程的演示(否则会阻塞UI线程以至于演示不能进行)
            IAsyncResult result = new dDemoProcess(delegate
            {
                //产生随机点集:

                /*
                 * RandomPositionSet_InFixedDistribution randomPositionSet_InFixedDistribution = new RandomPositionSet_InFixedDistribution();
                 * randomPositionSet_InFixedDistribution.PointNum = 1000;
                 * randomPositionSet_InFixedDistribution.DistributionStyle = distributionStyle.ClusterGaussianDistribution;
                 * new ConfiguratedByForm(randomPositionSet_InFixedDistribution);
                 * randomPositionSet_InFixedDistribution.Produce();
                 *
                 * //编辑点集
                 * Layer_PositionSet_Point layer = new Layer_PositionSet_Point(randomPositionSet_InFixedDistribution);
                 * layer.EditAble = true;
                 * layer.Point.PointColor = Color.Yellow;
                 * layer.Point.PointRadius = 2;
                 * layer.Point.IsDrawPointBorder = true;
                 * layers.Add(layer);
                 * layersPainterForm.Invalidate();
                 * flowControlerForm.SuspendAndRecordWorkerThread();
                 * layers.Remove(layer);
                 * */

                ///////////////////////////////////////
                //GetRandomPositionFromPositionSetRectangle getRandomPositionFromPositionSetRectangle
                //= new GetRandomPositionFromPositionSetRectangle(randomPositionSet_InFixedDistribution);

                ////对m2m_NN算法进行演示:
                ////为对象的事件添加事件响应,以进行算法演示
                //AlgorithmDemo_M2M_NN algorithmDemo_M2M_NN = new AlgorithmDemo_M2M_NN(m2m_NN, layers, flowControlerForm, layersPaintedControl.Invalidate);

                ////以下代码与非演示状态一样。
                //m2m_NN.PreProcess(randomPositionSet_InFixedDistribution);
                //m2m_NN.NearestNeighbor(layersPaintedControl.GetMouseDoubleChickedRealPosition());
                //while (true)
                //{
                //    for (int i = layers.Count - 1; i >= 0; i--)
                //    {
                //        if ((layers[i].Name != "M2MStructure") && (layers[i].Name != "PositionSetOfComparedPoint"))
                //        {
                //            layers.Remove(layers[i]);
                //        }
                //    }

                //    m2m_NN.NearestNeighbor(getRandomPositionFromPositionSetRectangle.Get());
                //}

                ////结束演示(解除事件响应的绑定)
                //algorithmDemo_M2M_NN.EndDemo();
                ///////////////////////////////////////

                //对M2M_CD算法进行演示:
                //为对象的事件添加事件响应,以进行算法演示
                PositionSetEditSet polygonSet = new PositionSetEditSet();
                IPositionSetEdit polygon      = new PositionSetEdit_ImplementByICollectionTemplate();
                polygon.AddPosition(new Position_Point(40, 40));
                polygon.AddPosition(new Position_Point(50, 10));
                polygon.AddPosition(new Position_Point(100, 70));
                IPositionSetEdit polygon2 = new PositionSetEdit_ImplementByICollectionTemplate();
                polygon2.AddPosition(new Position_Point(0, 0));
                polygon2.AddPosition(new Position_Point(20, 20));
                polygon2.AddPosition(new Position_Point(21, 12));
                IPositionSetEdit polygon3 = new PositionSetEdit_ImplementByICollectionTemplate();
                polygon3.AddPosition(new Position_Point(60, 60));
                polygon3.AddPosition(new Position_Point(62, 60));
                polygon3.AddPosition(new Position_Point(62, 56));
                polygon3.AddPosition(new Position_Point(64, 56));
                polygon3.AddPosition(new Position_Point(61, 52));
                polygon3.AddPosition(new Position_Point(58, 56));
                polygon3.AddPosition(new Position_Point(60, 56));
                polygonSet.AddPositionSet(polygon);
                polygonSet.AddPositionSet(polygon2);
                //polygonSet.AddPositionSet(polygon3);



                AlgorithmDemo_M2M_CD algorithmDemo_M2M_CD = new AlgorithmDemo_M2M_CD(M2M_CD, layers, flowControlerForm, layersPaintedControl.Invalidate);
                while (true)
                {
                    layers.Clear();
                    //以下代码与非演示状态一样。
                    //M2M_CD.ConvexHull(randomPositionSet_InFixedDistribution.Produce());
                    Layer_PositionSet_Polygon layer  = new Layer_PositionSet_Polygon(polygon);
                    Layer_PositionSet_Polygon layer2 = new Layer_PositionSet_Polygon(polygon2);
                    layers.Add(layer);
                    layers.Add(layer2);
                    M2M_CD.CollisionDetection(polygonSet, polygon3);
                }

                //结束演示(解除事件响应的绑定)
                algorithmDemo_M2M_CD.EndDemo();
            }).BeginInvoke(null, null);
        }