package org.uct.cs.simplify;

import org.uct.cs.simplify.img.BluePrintGenerator;
import org.uct.cs.simplify.ply.reader.PLYReader;
import org.uct.cs.simplify.ply.reader.Vertex;
import org.uct.cs.simplify.ply.reader.VertexReader;
import org.uct.cs.simplify.util.Timer;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Main
{

    public static void main(String[] args)
    {
        String filename = "C:\\Users\\Ben\\Desktop\\Chapel_of_Nossa_Senhora_de_Baluarte_ao.ply";
        //String filename = "C:\\Users\\Ben\\Desktop\\Gede Palace _3_Mio.ply";

        try (Timer ignored = new Timer("Entire read"))
        {

            PLYReader r = new PLYReader(new File(filename));

            System.out.printf("%d vertices\n", r.getHeader().getElement("vertex").getCount());

            try (VertexReader vr = new VertexReader(r.getFile(), r.getPositionOfElement("vertex"), r.getHeader().getElement("vertex").getCount(), 20))
            {
                Vertex v;
                int n = 0;
                float minx = Float.MAX_VALUE,
                        maxx = -Float.MAX_VALUE,
                        miny = Float.MAX_VALUE,
                        maxy = -Float.MAX_VALUE,
                        minz = Float.MAX_VALUE,
                        maxz = -Float.MAX_VALUE;

                long s = System.nanoTime();
                while (vr.hasNext())
                {
                    n += 1;
                    v = vr.next();

                    minx = Math.min(minx, v.x);
                    maxx = Math.max(maxx, v.x);

                    miny = Math.min(miny, v.y);
                    maxy = Math.max(maxy, v.y);

                    minz = Math.min(minz, v.z);
                    maxz = Math.max(maxz, v.z);
                }
                long e = System.nanoTime();
                System.out.printf("%f vertices per second.\n", (float) (e - s) / n);
                System.out.printf("x: %f < %f @ %f\n", minx, maxx, (minx + maxx) / 2);
                System.out.printf("y: %f < %f @ %f\n", miny, maxy, (miny + maxy) / 2);
                System.out.printf("z: %f < %f @ %f\n", minz, maxz, (minz + maxz) / 2);


            }
            catch (Exception e)
            {
                e.printStackTrace();
            }

            try
            {
                BufferedImage bi = BluePrintGenerator.CreateImage(r, 1024, 0.1f, BluePrintGenerator.Axis.X_Z);
                ImageIO.write(bi, "jpg", new File("C:\\Users\\Ben\\o.jpg"));
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }


        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}

@@ -127,106 +127,8 @@
 er;%0A
-import org.uct.cs.simplify.ply.reader.Vertex;%0Aimport org.uct.cs.simplify.ply.reader.VertexReader;%0A
 impo
@@ -162,16 +162,16 @@
 .Timer;%0A
+
 %0Aimport 
@@ -755,1491 +755,8 @@
 );%0A%0A
-            try (VertexReader vr = new VertexReader(r.getFile(), r.getPositionOfElement(%22vertex%22), r.getHeader().getElement(%22vertex%22).getCount(), 20))%0A            %7B%0A                Vertex v;%0A                int n = 0;%0A                float minx = Float.MAX_VALUE,%0A                        maxx = -Float.MAX_VALUE,%0A                        miny = Float.MAX_VALUE,%0A                        maxy = -Float.MAX_VALUE,%0A                        minz = Float.MAX_VALUE,%0A                        maxz = -Float.MAX_VALUE;%0A%0A                long s = System.nanoTime();%0A                while (vr.hasNext())%0A                %7B%0A                    n += 1;%0A                    v = vr.next();%0A%0A                    minx = Math.min(minx, v.x);%0A                    maxx = Math.max(maxx, v.x);%0A%0A                    miny = Math.min(miny, v.y);%0A                    maxy = Math.max(maxy, v.y);%0A%0A                    minz = Math.min(minz, v.z);%0A                    maxz = Math.max(maxz, v.z);%0A                %7D%0A                long e = System.nanoTime();%0A                System.out.printf(%22%25f vertices per second.%5Cn%22, (float) (e - s) / n);%0A                System.out.printf(%22x: %25f %3C %25f @ %25f%5Cn%22, minx, maxx, (minx + maxx) / 2);%0A                System.out.printf(%22y: %25f %3C %25f @ %25f%5Cn%22, miny, maxy, (miny + maxy) / 2);%0A                System.out.printf(%22z: %25f %3C %25f @ %25f%5Cn%22, minz, maxz, (minz + maxz) / 2);%0A%0A%0A            %7D%0A            catch (Exception e)%0A            %7B%0A                e.printStackTrace();%0A            %7D%0A%0A
     
@@ -1058,32 +1058,32 @@
 ntStackTrace();%0A
+
             %7D%0A%0A%0A
@@ -1081,17 +1081,16 @@
      %7D%0A%0A
-%0A
         

Remove old code, leave just the blueprint stuff