00001 package testbench;
00002
00003 import java.io.File;
00004 import java.io.IOException;
00005 import java.io.PrintWriter;
00006
00007 import commandline.Encoder.EncoderTypeSelector;
00008 import commandline.Encoder.NormalMeshEncoder;
00009 import commandline.Encoder.Iterators.DisposeListener;
00010 import commandline.Encoder.Iterators.MeshIteratorSelector;
00011 import commandline.ImageStuff.GeometricObjects.GeometricObject;
00012 import commandline.ImageStuff.Topology.ConnectionCriteriumSelector;
00013 import commandline.Norm.NormenMaker;
00014 import commandline.NormalMeshAlgorithm.CommandLineConfiguration;
00015 import commandline.debuggingCode.Debug;
00016
00017 public class AreaOfSelectedTrianglesWriter implements DisposeListener{
00018
00019 protected PrintWriter fileWriter;
00020 protected File file;
00021 public AreaOfSelectedTrianglesWriter(File file) throws IOException{
00022 this.file=file;
00023 fileWriter=new PrintWriter(file);
00024 fileWriter.println("% areas of the selected triangles -- length of the sorted queue at that moment");
00025 fileWriter.println("areaTriangle_lengthQueue=[");
00026 }
00027
00028 public void isGettingDisposed(GeometricObject geometricObject, int length_of_queue) {
00029 fileWriter.println(geometricObject.getLocs().size()+ " "+ length_of_queue+";");
00030 System.out.println(geometricObject.getLocs().size()+ " "+ length_of_queue);
00031 }
00032
00033 public void close(){
00034 fileWriter.println("];");
00035 fileWriter.flush();
00036 fileWriter.close();
00037 System.out.println(this.getClass().getName()+ ": matlab file written to "+file.getAbsolutePath());
00038 }
00039
00040 public static void main(String[] args2) throws IOException {
00041 boolean makeBaseMesh=false;
00042 int maxr=12;
00043 int MESH_ITERATOR=MeshIteratorSelector.UNTIL_NUMBER_OF_TRIANGLES_REACHED;
00044 int stop=1000;
00045 int ORDERING_NORM=NormenMaker.L_2;
00046 int TESSELATION_NORM=NormenMaker.L_1;
00047 int ConnectionCriteriumType=ConnectionCriteriumSelector.CONVEX_CONNECTION_CRITERIUM;
00048 String path_to_original_fig=Paths.getPathToImageDB()+File.separator+"hor_1_perfect.bmp";
00049 String path_to_out_dir=Paths.getPathToOutput();
00050 String name="triangle";
00051
00052 String[] args=new String[]{
00053 "-i", ""+path_to_original_fig,
00054 "-o" ,""+ path_to_out_dir,
00055 "-n", ""+name,
00056 "-IT",""+ MESH_ITERATOR,
00057 "-stop",""+ stop,
00058 "-Con", ""+ConnectionCriteriumType,
00059 "-compressiontype", ""+EncoderTypeSelector.getNameForCompressionType(EncoderTypeSelector.GENERIC_COMPRESSION),
00060 "-D", "12",
00061 "-maxr",""+maxr,
00062 "-Wnr",""+ORDERING_NORM,
00063 "-Wnt",""+TESSELATION_NORM
00064 };
00065
00066
00067
00068
00069 for (String s:args){
00070 Debug.print(s);}
00071
00072 File matlabFile=new File(Paths.getPathToOutput()+File.separator+"areas_lengths.m");
00073 AreaOfSelectedTrianglesWriter areaOfSelectedTrianglesWriter=new
00074 AreaOfSelectedTrianglesWriter(matlabFile);
00075
00076 NormalMeshEncoder normalMeshEncoder=new NormalMeshEncoder(new CommandLineConfiguration(args));
00077 normalMeshEncoder.registerWithMeshIterator(areaOfSelectedTrianglesWriter);
00078 normalMeshEncoder.perform();
00079 areaOfSelectedTrianglesWriter.close();
00080
00081
00082
00083 }
00084
00085
00086 }