package org.uct.cs.simplify;

import org.uct.cs.simplify.file_builder.PackagedHierarchicalNode;
import org.uct.cs.simplify.splitter.HierarchicalSplitter;
import org.uct.cs.simplify.util.Useful;

import java.io.File;
import java.io.IOException;

public class FileBuilder
{
    public static void main(String[] args) throws IOException
    {
        int rescaleTo = 1024;
        File inputFile = new File("temp/builder/GedePalace.ply");
        File outputDir = new File("temp/builder/");
        File outputFile = new File(inputFile.getParent(), Useful.getFilenameWithoutExt(inputFile.getName()) + ".phf");

        File scaledFile = new File(
            outputDir,
            String.format(
                "%s_rescaled_%d.ply",
                Useful.getFilenameWithoutExt(inputFile.getName()),
                rescaleTo
            )
        );
        ScaleAndRecenter.run(inputFile, scaledFile, rescaleTo, true);

        PackagedHierarchicalNode tree = HierarchicalSplitter.split(
            scaledFile,
            outputDir,
            HierarchicalSplitter.DepthControl.TREE_DEPTH_LIMIT
        );

        org.uct.cs.simplify.file_builder.FileBuilder.compile(tree, outputFile);
    }
}

@@ -23,16 +23,49 @@
 plify;%0A%0A
+import org.apache.commons.cli.*;%0A
 import o
@@ -180,16 +180,104 @@
 litter;%0A
+import org.uct.cs.simplify.util.MemStatRecorder;%0Aimport org.uct.cs.simplify.util.Timer;%0A
 import o
@@ -386,16 +386,66 @@
 ilder%0A%7B%0A
+    public static final int RESCALE_SIZE = 1024;%0A%0A
     publ
@@ -516,30 +516,162 @@
     
-int rescaleTo = 1024;%0A
+CommandLine cmd = getCommandLine(args);%0A%0A        try (Timer ignored = new Timer(%22Total%22); MemStatRecorder ignored2 = new MemStatRecorder())%0A        %7B%0A    
     
@@ -704,40 +704,42 @@
 ile(
-%22temp/builder/GedePalace.ply
+cmd.getOptionValue(%22input
 %22)
+)
 ;%0A
+    
     
@@ -772,26 +772,43 @@
 ile(
-%22temp/builder/%22);%0A
+cmd.getOptionValue(%22output%22));%0A    
     
@@ -842,29 +842,17 @@
 ile(
-inputFile.getParent()
+outputDir
 , Us
@@ -915,24 +915,28 @@
 );%0A%0A        
+    
 File scaledF
@@ -951,16 +951,20 @@
 w File(%0A
+    
         
@@ -990,16 +990,20 @@
         
+    
 String.f
@@ -1009,16 +1009,20 @@
 format(%0A
+    
         
@@ -1051,16 +1051,20 @@
 d.ply%22,%0A
+    
         
@@ -1142,18 +1142,29 @@
     
-rescaleTo%0A
+    RESCALE_SIZE%0A    
     
@@ -1181,19 +1181,27 @@
         
+ 
-);%0A
+   );%0A    
         
@@ -1248,17 +1248,20 @@
 le, 
-rescaleTo
+RESCALE_SIZE
 , tr
@@ -1262,24 +1262,28 @@
 ZE, true);%0A%0A
+    
         Pack
@@ -1350,16 +1350,20 @@
         
+    
 scaledFi
@@ -1370,32 +1370,36 @@
 le,%0A            
+    
 outputDir,%0A     
@@ -1405,16 +1405,20 @@
         
+  
+  
 Hierarch
@@ -1468,20 +1468,28 @@
         
-);%0A%0A
+    );%0A%0A    
         
@@ -1559,16 +1559,1020 @@
 utFile);
+%0A%0A        %7D%0A        catch (InterruptedException %7C IllegalArgumentException e)%0A        %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    private static CommandLine getCommandLine(String%5B%5D args)%0A    %7B%0A        CommandLineParser clp = new BasicParser();%0A%0A        Options options = new Options();%0A%0A        Option inputFile = new Option(%22i%22, %22input%22, true, %22path to first PLY file%22);%0A        inputFile.setRequired(true);%0A        options.addOption(inputFile);%0A%0A        Option outputFile = new Option(%22o%22, %22output%22, true, %22path to output directory%22);%0A        outputFile.setRequired(true);%0A        options.addOption(outputFile);%0A%0A        CommandLine cmd;%0A        try%0A        %7B%0A            cmd = clp.parse(options, args);%0A            return cmd;%0A        %7D%0A        catch (ParseException e)%0A        %7B%0A            HelpFormatter formatter = new HelpFormatter();%0A            formatter.printHelp(%22filebuilder --input %3Cpath%3E --output %3Cpath%3E%22, options);%0A            System.exit(1);%0A            return null;%0A        %7D
 %0A    %7D%0A%7D

Remove fixed variables