Пример #1
0
 public override string ToString()
 {
     if (obj != null)
     {
         return(obj.ToString());
     }
     return("- null -");
 }
Пример #2
0
        public bool Run()
        {
            Program.PrintTitle("SETUP - FIGURE BUILDER");
            Console.WriteLine("This launcher let's you create a SDF operator tree");
            SDF figure = userSDF();


            Program.PrintTitle("FIGURE BUILDER");
            Console.WriteLine("You choose to create:");
            Console.WriteLine(figure.ToString());
            Console.WriteLine("Nice choice!");

            // # of triangulations?
            Console.WriteLine("\nNumber of simultaneous triangulations?");
            Console.Write("> ");
            var n = 1;

            int.TryParse(Console.ReadLine(), out n);

            // Setup...
            var triangulator = new ITriangulator[n];
            var sdf          = new SDF[n];

            for (int i = 0; i < n; i++)
            {
                Program.PrintTitle($"PERFORM SETUP {i + 1} of {n}");
                triangulator[i] = Program.UserInstantiation <ITriangulator>("triangulation method");
                sdf[i]          = figure;
            }

            // Debug?
            var debugView = AskUser("Enable step visualizer triangulation?");

            // Triangulate!
            Tuple <Log, IPolygon, string, long>[] result;
            if (debugView)
            {
                result = TriangulateWithLog(triangulator, sdf);
            }
            else
            {
                result = Triangulate(triangulator, sdf);
            }

            // Show result!
            if (debugView)
            {
                if (!LaunchLogView(result))
                {
                    Export(result);
                }
            }
            else
            {
                if (!LaunchView(result))
                {
                    Export(result);
                }
            }

            return(!AskUser("Restart the application?"));
        }