00001 package commandline.NormalMeshAlgorithm; 00002 import java.awt.Dimension; 00003 import java.io.File; 00004 import java.io.PrintStream; 00005 import java.io.Serializable; 00006 00007 import commandline.Encoder.EncoderTypeSelector; 00008 import commandline.Encoder.Iterators.MeshIteratorSelector; 00009 import commandline.ImageStuff.GeometricObjects.Impl.TriangleImplType; 00010 00011 import commandline.ImageStuff.Topology.ConnectieCriterium; 00012 import commandline.ImageStuff.Topology.ConnectionCriteriumSelector; 00013 import commandline.Norm.NormenMaker; 00014 import commandline.TxTPackage.DirectoryAndFileClass; 00015 import commandline.debuggingCode.Debug; 00016 import commandline.factories.SnijPixelStrategyBuilder; 00017 00027 public class Configuration implements Serializable{ 00028 00029 public static final String DEFAULT_OUTPUT_PATH=new File("").getAbsolutePath()+File.separator+"output"; 00030 public static final String kernel_version="0.1"; 00031 00032 public static final int NO_FILE=0; 00033 public static final int IMAGE_FILE=1; 00034 private int snijPixelStrategyType; 00035 private int compressionType; 00036 private int iteratorType; 00037 00038 00039 private float lagrangian; 00040 private boolean prune; 00041 private float stopValue; 00042 private float percentage; 00043 private int k,N,L,DEGREE; 00044 private int max_rico; 00045 private String image_name,outputname; 00046 private int whichNormToUseForTesselation,whichNormToUseForNextRefinement; 00047 private ConnectieCriterium connectieCriterium; 00048 private boolean makeBaseMesh; 00049 private boolean writevtk_and_matlabfile; 00050 // Image data 00051 private String path,outdir; 00052 private Dimension imageDimension; 00053 private long filesize; 00054 private File open_filechooser_path;// path where last visit happened 00055 public TriangleImplType TRIANGLE=TriangleImplType.INTERPOLOLATING; 00056 // public static final boolean PIERCINGS_FALL_TOGETHER=true; 00057 00058 00059 00060 00061 public Configuration(){ 00062 this.max_rico=12; 00063 this.setStopValue(30); 00064 this.setPercentage(0.9f); 00065 whichNormToUseForTesselation=NormenMaker.L_2; 00066 whichNormToUseForNextRefinement=NormenMaker.L_1; 00067 compressionType=EncoderTypeSelector.GENERIC_COMPRESSION; 00068 snijPixelStrategyType=SnijPixelStrategyBuilder.PIERCING_WAARDE_TYPE; 00069 initConnectionCriterium(whichNormToUseForTesselation); 00070 makeBaseMesh=false; 00071 writevtk_and_matlabfile=true; 00072 setOutputDir(DEFAULT_OUTPUT_PATH); 00073 image_name="image.bmp"; 00074 this.path=DEFAULT_OUTPUT_PATH+File.separator+image_name; 00075 imageDimension=new Dimension(100,100); // set to > 0 because otherwise OpenGL.viewport will crash 00076 outputname=getImageName_WithoutExtension()+".no"; 00077 iteratorType=MeshIteratorSelector.UNTIL_CERTAIN_MINIMAL_PSNR_REACHED; 00078 k=50;N=100;L=75;DEGREE=6; 00079 } 00080 00087 public boolean hasSameAlgoritmicValuesAs(Configuration configuration){ 00088 if (this.compressionType != configuration.compressionType) 00089 return false; 00090 if (this.iteratorType != configuration.iteratorType) 00091 return false; 00092 if (this.connectieCriterium.getType() != connectieCriterium.getType()) 00093 return false; 00094 if (this.makeBaseMesh != configuration.makeBaseMesh) 00095 return false; 00096 if (this.max_rico != configuration.getMaxRico()) 00097 return false; 00098 if (this.snijPixelStrategyType != configuration.snijPixelStrategyType) 00099 return false; 00100 if (this.whichNormToUseForNextRefinement != configuration.whichNormToUseForNextRefinement) 00101 return false; 00102 if (this.whichNormToUseForTesselation != configuration.whichNormToUseForTesselation) 00103 return false; 00104 return true; 00105 } 00106 00107 00112 public void reset(){ 00113 writevtk_and_matlabfile=false; 00114 } 00115 00116 00117 public void setPath(String path){ 00118 if(!new File(path).exists()){ 00119 System.out.println("The path to the input file is incorrect: "+path); 00120 System.exit(-1); 00121 } 00122 this.path=path; 00123 } 00124 00129 public String getPath(){ 00130 return path; 00131 } 00132 00133 00138 public void setOutputDir(String dir){ 00139 if(!new File(dir).exists()){ 00140 System.out.println("The output directory does not exists: " + dir); 00141 DirectoryAndFileClass.makeDir(dir); 00142 } 00143 00144 if(!new File(dir).isDirectory()){ 00145 System.out.println("The output directory is not a directory:" + dir); 00146 System.exit(-1); 00147 } 00148 00149 this.outdir=dir; 00150 } 00151 00152 public String getOutputDir(){ 00153 return outdir; 00154 } 00155 00156 public String getOutputName(){ 00157 return outputname; 00158 } 00159 00160 public void setOutputName(String outputname){ 00161 this.outputname=outputname; 00162 } 00163 00164 00165 public void setMakeBaseMesh(boolean makeBaseMesh) { 00166 this.makeBaseMesh=makeBaseMesh; 00167 } 00168 00169 public boolean getMakeBaseMesh(){ 00170 return this.makeBaseMesh; 00171 } 00172 00173 public void setWhichNormToUseForTesselation(int WHICHNORM){ 00174 this.whichNormToUseForTesselation=WHICHNORM; 00175 if(connectieCriterium!=null){ 00176 ConnectieCriterium.setWichNormToUse(WHICHNORM); 00177 } 00178 //setConnectionCriterium(connectieCriterium); 00179 } 00180 00181 00182 public int getWhichNormToUseForTesselation(){ 00183 return this.whichNormToUseForTesselation; 00184 } 00185 00186 public int getFileType(){ 00187 if(getImageName().endsWith("."+Extensions.decodeExtension)) return NO_FILE; 00188 else return IMAGE_FILE; 00189 } 00190 00191 00192 00193 00194 00195 public void setImageName(String image_name){ 00196 this.image_name=image_name; 00197 } 00198 00199 public String getImageName(){ 00200 return this.image_name; 00201 } 00202 00203 public String getImageName_WithoutExtension(){ 00204 return Extensions.getFileNameWithoutExtension(getImageName()); 00205 00206 } 00207 00208 public void initConnectionCriterium(int whichnormtouseforTesselation){ 00209 connectieCriterium=commandline.debuggingCode.Debug.CONVEX ? 00210 ConnectionCriteriumSelector.createCriterium(ConnectionCriteriumSelector.CONVEX_CONNECTION_CRITERIUM,whichnormtouseforTesselation) 00211 :ConnectionCriteriumSelector.createCriterium(ConnectionCriteriumSelector.IMAGE_DEPENDENT_CONNECTION_CRITERIUM,whichnormtouseforTesselation); 00212 } 00213 00214 public void setConnectionCriterium(ConnectieCriterium connectieCriterium){ 00215 this.connectieCriterium=connectieCriterium; 00216 if(Debug.VERBOSE) Debug.print("ConnectionCriterium set to ->" + connectieCriterium.getInformation()); 00217 } 00218 00219 00220 00221 public ConnectieCriterium getConnectionCriterium(){ 00222 return this.connectieCriterium; 00223 } 00224 00225 00226 00227 public void setSnijPixelStrategyTYPE(int TYPE){ 00228 this.snijPixelStrategyType=TYPE; 00229 } 00230 00231 00232 public int getSnijPixelStrategyTYPE(){ 00233 return snijPixelStrategyType; 00234 } 00235 00236 00237 00238 public void setMaxRico(int max_rico){ 00239 this.max_rico=max_rico; 00240 } 00241 00242 public int getMaxRico(){ 00243 return this.max_rico; 00244 } 00245 00246 00247 public void setImageDimensions(Dimension d){ 00248 this.imageDimension=d; 00249 } 00250 00251 public Dimension getImageDimension(){ 00252 return imageDimension; 00253 } 00254 00255 00256 public void setFileSize(Long size){ 00257 this.filesize=size; 00258 } 00259 public long getFileSize(){ 00260 return filesize; 00261 } 00262 00263 00264 public int getWhichNormToUseForNextRefinement() { 00265 return whichNormToUseForNextRefinement; 00266 } 00267 00268 00269 public void setWhichNormToUseForNextRefinement(int whichNormToUseForRefinement) { 00270 this.whichNormToUseForNextRefinement = whichNormToUseForRefinement; 00271 ConnectieCriterium.setWichNormToUse(whichNormToUseForRefinement); 00272 if(Debug.VERBOSE) Debug.print("set refinement norm -> " + whichNormToUseForRefinement); 00273 } 00274 00275 00276 public int getIteratorType() { 00277 return iteratorType; 00278 } 00279 00280 00281 public void setIteratorType(int iteratorType) { 00282 this.iteratorType = iteratorType; 00283 if(Debug.VERBOSE) Debug.print("Set IteratorType -> "+iteratorType); 00284 } 00285 00286 00287 public void print(PrintStream out){ 00288 out.println("this.getConnectionCriterium()= "+this.getConnectionCriterium()); 00289 out.println("this.getDEGREE()= "+this.getDEGREE()); 00290 out.println("this.getFileSize()= "+this.getFileSize()); 00291 out.println("this.getFileType()= "+this.getFileType()); 00292 out.println("this.getImageDimension()= "+this.getImageDimension()); 00293 out.println("this.getCompressionType() = "+EncoderTypeSelector.getNameForCompressionType(this.getCompressionType())); 00294 out.println("this.image_name= "+this.image_name); 00295 out.println("this.getImageName_WithoutExtension()= "+this.getImageName_WithoutExtension()); 00296 out.println("this.getIteratorType()= "+this.getIteratorType()); 00297 out.println("this.getk()= "+this.getk()); 00298 out.println("this.getL()= "+this.getL()); 00299 out.println("this.getLagrangion()= "+this.getLagrangian()); 00300 out.println("this.getMakeBaseMesh()= "+this.getMakeBaseMesh()); 00301 out.println("this.getMaxRico()= "+this.getMaxRico()); 00302 out.println("this.getStopValue= "+this.getStopValue()); 00303 out.println("this.getN()= "+this.getN()); 00304 out.println("this.getOutputDir()= "+this.getOutputDir()); 00305 out.println("this.getOutputName()= "+this.getOutputName()); 00306 out.println("this.getPath()= "+this.getPath()); 00307 out.println("this.getSnijPixelStrategyTYPE()= "+this.getSnijPixelStrategyTYPE()); 00308 out.println("this.getTRIANGLE()= "+this.getTRIANGLE()); 00309 out.println("this.getWhichNormToUseForRefinement()= "+NormenMaker.getNameForNorm(this.getWhichNormToUseForNextRefinement())); 00310 out.println("this.getWhichNormToUseForTesselation()= "+NormenMaker.getNameForNorm(this.getWhichNormToUseForTesselation())); 00311 } 00312 00313 00314 public int getk() { 00315 return k; 00316 } 00317 00318 00319 public void setk(int k) { 00320 this.k = k; 00321 } 00322 00323 00324 public int getN() { 00325 return N; 00326 } 00327 00328 00329 public void setN(int n) { 00330 this.N = n; 00331 } 00332 00333 00334 public int getDEGREE() { 00335 return DEGREE; 00336 } 00337 00338 00339 public void setDEGREE(int degree) { 00340 DEGREE = degree; 00341 } 00342 00343 00344 public int getL() { 00345 return L; 00346 } 00347 00348 00349 public void setL(int l) { 00350 L = l; 00351 } 00352 00353 00354 public int getCompressionType() { 00355 return compressionType; 00356 } 00357 00358 00359 public void setCompressionType(int compressionType) { 00360 this.compressionType = compressionType; 00361 if(Debug.VERBOSE) Debug.print("CompressionType -> " + compressionType); 00362 } 00363 00364 00365 public float getStopValue() { 00366 return stopValue; 00367 } 00368 00373 public void setStopValue(float stopValue) { 00374 this.stopValue = stopValue; 00375 if(Debug.VERBOSE) Debug.print("Minimum stopValue -> "+stopValue); 00376 } 00377 00378 00379 public float getPercentage() { 00380 return percentage; 00381 } 00382 00383 00384 public void setPercentage(float percentage) { 00385 this.percentage = percentage; 00386 } 00387 00388 00389 public boolean isWritevtk_and_matlabfile() { 00390 return writevtk_and_matlabfile; 00391 } 00392 00393 00394 public void setWritevtk_and_matlabfile(boolean writevtkfile) { 00395 this.writevtk_and_matlabfile = writevtkfile; 00396 } 00397 00398 public File getOpen_filechooser_path() { 00399 return open_filechooser_path; 00400 } 00401 00402 public void setOpen_filechooser_path(File open_filechooser_path) { 00403 this.open_filechooser_path = open_filechooser_path; 00404 } 00405 00406 public float getLagrangian() { 00407 if(!isPrune()){ 00408 System.err.println("WARNING: Try to get Lagrangian multiplier when"+ 00409 "prune is false!"); 00410 } 00411 return lagrangian; 00412 } 00413 00414 public void setLagrangian(float lagrangian) { 00415 this.lagrangian = lagrangian; 00416 } 00417 00418 public boolean isPrune() { 00419 return prune; 00420 } 00421 00422 public void setPrune(boolean prune) { 00423 this.prune = prune; 00424 } 00425 00429 public TriangleImplType getTRIANGLE() { 00430 return TRIANGLE; 00431 } 00432 00436 public void setTRIANGLE(TriangleImplType triagleImplType) { 00437 TRIANGLE = triagleImplType; 00438 Debug.print("TRIANGLE= " + TRIANGLE); 00439 } 00440 00441 00442 00443 }
1.5.5