示例#1
0
        void origin_MouseEnter(object sender, MouseEventArgs e)
        {
            var origin = sender as DCEL2D.DCELVertex2D;

            switch (MeshViewMode)
            {
            case ViewMode.Geometry:
                break;

            case ViewMode.Wireframe:
                break;

            case ViewMode.DCELStructure:
                origin.Fill           = Brushes.Blue;
                origin.Leaving.Stroke = Brushes.Green;
                break;

            case ViewMode.LeavingEdges:
                origin.Fill = Brushes.Blue;
                foreach (var item in LINQueries.LeavingEdges(this, origin, LINQueries.QueryExecutionMode.Default))
                {
                    buffer.Add(item);
                    item.Stroke = Brushes.Green;
                }
                break;

            case ViewMode.AdjacentFaces:
                origin.Fill = Brushes.Blue;
                foreach (var item in origin.AdjacentFaces())
                {
                    buffer.Add(item);
                    item.Fill = Brushes.Green;
                }
                break;

            case ViewMode.AdjacentVertices:
                origin.Fill = Brushes.Blue;
                foreach (var item in origin.AdjacentVertices())
                {
                    buffer.Add(item);
                    item.Fill = Brushes.Orange;
                }
                break;

            case ViewMode.KStar:
                origin.Fill = Brushes.Blue;
                foreach (var item in origin.KStar(K))
                {
                    buffer.Add(item);
                    item.Fill = Brushes.Green;
                }
                break;

            default:
                break;
            }
        }
示例#2
0
        //public DCELMesh mesh = DCELTools.LoadFromOFF(@"shapes/hexagon.off");

        public TestApp()
        {
            Stopwatch sw = new Stopwatch();

            mesh.AddVertex(new DCELVertex2D(5, 5, null));

            for (int i = 0; i < 1000000; i++)
            {
                mesh.AddHalfEdge(new DCELHalfEdge2D(mesh.VertexList[0], null, null, null));
            }

            sw.Start();
            var q1 = LINQueries.LeavingEdges(mesh, mesh.VertexList[0],
                                             LINQueries.QueryExecutionMode.ForEachLoop).ToList();

            sw.Stop();
            Console.WriteLine("Foreach loop: " + sw.Elapsed.TotalMilliseconds);

            sw.Restart();
            var q2 = LINQueries.LeavingEdges(mesh, mesh.VertexList[0],
                                             LINQueries.QueryExecutionMode.ForLoop).ToList();

            sw.Stop();
            Console.WriteLine("For loop: " + sw.Elapsed.TotalMilliseconds);

            sw.Restart();
            var q5 = LINQueries.LeavingEdges(mesh, mesh.VertexList[0],
                                             LINQueries.QueryExecutionMode.ForWithAssignment).ToList();

            sw.Stop();
            Console.WriteLine("For with assignment loop: " + sw.Elapsed.TotalMilliseconds);

            sw.Restart();
            var q3 = LINQueries.LeavingEdges(mesh, mesh.VertexList[0],
                                             LINQueries.QueryExecutionMode.Default).ToList();

            sw.Stop();
            Console.WriteLine("Default: " + sw.Elapsed.TotalMilliseconds);

            sw.Restart();
            var q4 = LINQueries.LeavingEdges(mesh, mesh.VertexList[0],
                                             LINQueries.QueryExecutionMode.AsParallel).ToList();

            sw.Stop();
            Console.WriteLine("As parallel: " + sw.Elapsed.TotalMilliseconds);

            Console.ReadLine();
        }