Ejemplo n.º 1
0
    public static void TestPcGeneration()
    {
        StopWatch p = new StopWatch("load and bound");
        StopWatch s = new StopWatch("save");

        p.tic();
        string[]   filenames = Directory.GetFiles("geom-sets/regions/cylinder", "*.stl");
        double[]   bounds    = PointCloud.GetBoundsFromStls(filenames);
        PointCloud pc        = PointCloud.FromBounds(bounds, 0.6);

        p.toc();
        Console.WriteLine(p.Result());
        foreach (double w in bounds)
        {
            Console.WriteLine(w);
        }
        s.tic();
        pc.WriteToCsv("./testcsv/gen.csv");
        s.toc();
        Console.WriteLine(s.Result());
    }
Ejemplo n.º 2
0
    //Class for miscellaneous test functions.
    public static void TestFullMultiGeneration()
    {
        //Should probably generalize this to a "tag case" object...
        double    dx      = 1.1d;
        StopWatch tagload = new StopWatch("tag load");

        tagload.tic();
        Tag[] tags = Tag.ExtractFromFile("geom-sets/cylinder-hollow/tags.tg");
        tagload.toc();
        Console.WriteLine("Loading tags...");
        Console.WriteLine(tagload.Result());
        string[] filenames = new string[tags.Length];
        int      k         = 0;

        foreach (Tag t in tags)
        {
            Console.WriteLine(t.ToString());
            filenames[k] = t.RegionFilename;
            Console.WriteLine(filenames[k] + "?exist=" + File.Exists(filenames[k]).ToString());
            k++;
        }
        Console.WriteLine();

        Console.WriteLine("Generating points...");
        StopWatch buildpoints = new StopWatch("build points");

        buildpoints.tic();
        double[]   bounds = PointCloud.GetBoundsFromStls(filenames);
        PointCloud pc     = PointCloud.FromBounds(bounds, dx);

        pc.WriteToCsv("./testcsv/diag.csv");
        buildpoints.toc();
        Console.WriteLine(buildpoints.Result());
        Console.WriteLine();

        Console.WriteLine("Initializing lattice...");
        StopWatch initlat = new StopWatch("initialize lattice");

        initlat.tic();
        LatticeStateInitializer init = new LatticeStateInitializer(pc, tags, 4, 20, 1.01 * dx);

        init.InitializeNodes();
        initlat.toc();
        Console.WriteLine(initlat.Result());
        Console.WriteLine();

        Console.WriteLine("Building lattice...");
        StopWatch blat = new StopWatch("build lattice");

        blat.tic();
        LatticeState s = init.BuildLatticeState();

        blat.toc();
        Console.WriteLine(blat.Result());
        Console.WriteLine();

        StopWatch file = new StopWatch("write to file");

        Console.WriteLine("Writing to directory...");
        file.tic();
        s.WriteToDirectory("./lattice-output-test/cylgen", true);
        file.toc();
        Console.WriteLine(file.Result());
        Console.WriteLine();
        Console.WriteLine("Done.");
        Console.WriteLine();

        Console.WriteLine("Evolving...");
        Evolver e = new Evolver(s, 0.1, 4);

        e.EvolveAll("evolvetest", 500, true);
    }