/*
 * $Id: FileInfo.java,v 1.11 1999/12/29 21:23:31 yamauchi Exp $
 *     (M\pi)^2 : FileInfo (file information) 
 *	Copyright 1999 By YAMAUCHI Hitoshi 山内 斉 
 *	Copyright 1999 MAEDA Atusi
 *	@author YAMAUCHI Hitoshi, MAEDA Atusi
 *
 * 	FileInfo  : 入出力のファイル情報 
 *
 * original source FileInfo.h
 * 
 * 1999年7月30日(金)
 */

package jp.ac.tohoku.is.archi.mpi2.sysparam;

import java.io.IOException;
import java.io.FileInputStream;

// import java.util.Map; IBM AIX Java is based on jdk1.1.7
import jp.ac.tohoku.is.archi.mpi2.jdk12src.Map;

import jp.ac.tohoku.is.archi.mpi2.util.*;
import jp.ac.tohoku.is.archi.mpi2.common.*;

/**
 * FileInfo : 読み，書くファイル情報と config file の Option 指定 
 */
public final class FileInfo implements Mpi2Constants {
    public static final int FI_SAVE_PPM  = 0; // save as ppm file 
    public static final int FI_SAVE_GFB  = 1; // save as gfb file 
    public static final int FI_SAVE_ELSE = 2;
    public static final int
      FI_RADIOI_SHOT = 0,
      FI_RADIOI_UNSHOT = 1,
      FI_RADIOI_BOTH = 2;

    // 未定義としてのファイル名 : 残念ながらこの名前のファイル名は使えない
    public final static String INIT_FILENAME = "(none)";

    /*
     * singleton pattern
     */
    private static FileInfo mFileInfo;
    public  static FileInfo getInstance()
    {
	if(FileInfo.mFileInfo == null)
	{
	    FileInfo.mFileInfo = new FileInfo();
	}
	return(FileInfo.mFileInfo);
    }

    // file In/Out
    private String mConfigFileName;	   // config file name
    private String mSpcFileName;	   // define space etc.. info file
    private String mSysInfoFileName;	   // system infomation
    private String mViewDataFileName;	   // view data information
    private String mMatFileName;	   // material info file
    private String mGeoFileName;	   // geometry information file
    private String mSaveResultFileName;    // output file name
    private int    mSaveFileFormat;	   // output file format
    private String mVolumeInFileListName;  // volume data infile list name
    private boolean mIsRadioStageResOut;   // radiosity stage終了時の結果の表示
    private String mRadioStageOutFileName; // radiosity result file base name    
    private boolean mIsRadioOutAt;	   // radiosity stage 指定 HC 破壊時
    private int    mRadioOutStartHC;	   // for(i =  this.mRadioOutStartHC;
    private int    mRadioOutEndHC;	   //     i <= this.mRadioOutEndHC;
    private int    mRadioOutIncHCNum;	   //     i += this.mRadioOutIncHCNum)
    private int    mRadioOutLoopVar;	   // loop 変数 i
    
    private String mRadioIntermFileBaseName; // radiosity result file base name
    private int    mRadioIntermFileType; // shot,unshot,both intermediateresult

    // Intensity Out : file info の名前に合わないかな?
    private boolean mImmediateImageOut; 

    // for genvol
    private String mCompressCommand;	    // for compress output file (gzip)
    private String mGenvolOutFileNameFormat;// volume出力ファイル名printfformat
    private String mDistanceDataFileName;   // distance data information file

    // Profile Monitor 関係
    private boolean mIsTraceFileOut;        // trace file を作成するか
    private boolean mIsProgramMarkerOn;     // Program Marker を ON にするか
    private boolean mIsTraceOutUnshotRadiosity; // unshotradiosity を出力するか
    private String  mTraceFileBaseName;          


    private boolean isFileNameOK(String apDataFname)
    {
	if(!(apDataFname.equals("")))
	{
	    return(true);
	}else
	{
	    throw new RuntimeException("Error! : illegal data filename " +
				       "(no filename)");
	    // commMpi2_exit(1);
	}
    }

    public FileInfo()
    {
	this.mConfigFileName 		= INIT_FILENAME;	
	this.mSpcFileName 		= INIT_FILENAME;
	this.mSysInfoFileName 		= INIT_FILENAME;
	this.mViewDataFileName 		= INIT_FILENAME;
	this.mMatFileName 		= INIT_FILENAME;
	this.mGeoFileName 		= INIT_FILENAME;
	this.mSaveResultFileName 	= INIT_FILENAME;
	this.mSaveFileFormat		= FI_SAVE_PPM;
	this.mVolumeInFileListName 	= INIT_FILENAME;

	this.mIsRadioStageResOut 	= false;
	this.mRadioStageOutFileName 	= INIT_FILENAME;
	
	this.mIsRadioOutAt		=  false;
	this.mRadioOutStartHC		=  -1;	     
	this.mRadioOutEndHC		=  -1;
	this.mRadioOutLoopVar		=   0;
	this.mRadioOutIncHCNum		= 256;
	this.mRadioIntermFileBaseName 	= INIT_FILENAME;
	this.mRadioIntermFileType	= -1;

	this.mDistanceDataFileName	= INIT_FILENAME;

	this.mImmediateImageOut	= false;
	this.mCompressCommand		= "gzip";
	this.mGenvolOutFileNameFormat	= "volimg%04d.svol";

	// profile monitor
        this.mIsTraceFileOut           = false;
        this.mIsProgramMarkerOn        = false;
        this.mIsTraceOutUnshotRadiosity= false;
        this.mTraceFileBaseName        = INIT_FILENAME;    
    }

    // set filename functions
    public void setConfigFileName(String aConfigFname)
    {
	// この config filename のみは option で指定する
	isFileNameOK(aConfigFname);
	this.mConfigFileName = aConfigFname;
    }
    public void setSpcFileName(String aSpcFname)
    {
	isFileNameOK(aSpcFname);
	this.mSpcFileName = aSpcFname;
    }
    public void setMatFileName(String aMatFname)
    {
	isFileNameOK(aMatFname);
	this.mMatFileName = aMatFname;
    }
    public void setGeoFileName(String aGeoFname)
    {
	isFileNameOK(aGeoFname);
	this.mGeoFileName = aGeoFname;
    }
    public void setSaveResultFileName(String aSaveFname)
    {
	isFileNameOK(aSaveFname);
	this.mSaveResultFileName = aSaveFname;
    }
    public void setSaveFileFormat(int format)
    {
	if((format < 0) || (FI_SAVE_ELSE <= format))
	{
	    throw new RuntimeException("Error! : FileInfo.setSaveFileFormat " +
				       ": no such file format.");
	}else
	{
	    this.mSaveFileFormat = format;
	}
    }
    public void setSysInfoFileName(String aSysinfoFname)
    {
	isFileNameOK(aSysinfoFname);
	this.mSysInfoFileName = aSysinfoFname;
    }
    public void setViewDataFileName(String aViewDataFname)
    {
	isFileNameOK(aViewDataFname);
	this.mViewDataFileName = aViewDataFname;
    }
    public void setRadioStageOutFileName(String aRadioStageOutFName)
    {
	isFileNameOK(aRadioStageOutFName);
	this.mRadioStageOutFileName = aRadioStageOutFName;
	this.mIsRadioStageResOut = true;
    }
    public void setRadioIntermediateBaseName(String aRadioIntermFBName)
    {
	isFileNameOK(aRadioIntermFBName);
	this.mRadioIntermFileBaseName = aRadioIntermFBName;
    }
    public void setVolumeInFileListName(String aVolInFname)
    {
	isFileNameOK(aVolInFname);
	this.mVolumeInFileListName = aVolInFname;
    }
    public void setDistanceDataFileName(String aDistanceDataFname)// for PRC
    {
	isFileNameOK(aDistanceDataFname);
	this.mDistanceDataFileName = aDistanceDataFname;
    }
    public void setImmediateImageOut() 
    { 
	this.mImmediateImageOut	= true; 
    }
    public void setCompressCommand(String aCompressCommand)
    {
	this.mCompressCommand = aCompressCommand;
    }
    public void setGenvolOutFilename(String aGenvolFNameFormat) // genvol4mpi2
    {
	this.mGenvolOutFileNameFormat = aGenvolFNameFormat;
    }

    // profile monitor
    public void setTraceFileOut()
    {
        this.mIsTraceFileOut = true;
    }
    public void setProgramMarkerOn()
    {
        this.mIsProgramMarkerOn = true;
    }
    public void setTraceOutWithUnshotRadiosity()
    {
        this.mIsTraceOutUnshotRadiosity = true;
    }
    public void setTraceFileBaseName(final String aTraceFileBaseName)
    {
        this.mTraceFileBaseName = aTraceFileBaseName;
    }

    // get functions
    public String getConfigFileName()  
    {
	return(this.mConfigFileName);	
    }
    public String getSpcFileName()  
    {
	return(this.mSpcFileName);	
    }
    public String getMatFileName()  
    {
	return(this.mMatFileName);	
    }
    public String getGeoFileName()  
    {
	return(this.mGeoFileName);  
    }
    public String getSaveResultFileName()  
    {
	return(this.mSaveResultFileName); 
    }
    public int getSaveFileFormat()  
    {
	return(this.mSaveFileFormat); 
    }
    public String getSysInfoFileName()  
    { 
	return(this.mSysInfoFileName); 
    }
    public String getViewDataFileName()  
    {
	return(this.mViewDataFileName);
    }
    public String getRadioStageOutFileName()  
    {
	return(this.mRadioStageOutFileName);    	  
    }
    public String getRadioIntermediateBaseName() 
    {
	return(this.mRadioIntermFileBaseName);    	  
    }
    public int getRadioIntermFileType()  
    { 
	return(this.mRadioIntermFileType);
    }
    public String getVolumeInFileListName()  
    {
	return(this.mVolumeInFileListName);    	  
    }
    public String getDistanceDataFileName()  // for PRC
    {
	return(this.mDistanceDataFileName);    	  
    }
    public String getCompressCommand() 
    {
 	return(this.mCompressCommand);
    }
    public String getGenvolOutFileNameFormat()  // for genvol4mpi2
    {
 	return(this.mGenvolOutFileNameFormat);
    }

    // boolean
    public boolean isGeometryFile()  
    {
	return(((this.mMatFileName != INIT_FILENAME) && 
		(this.mGeoFileName != INIT_FILENAME)));
    }
    public boolean isVolumeFile()  
    {
	return(this.mVolumeInFileListName != INIT_FILENAME);
    }
    public boolean isRadioStageResultOut()  
    {
	return(this.mIsRadioStageResOut);
    }
    public boolean isImmediateImageOut()  
    {
	return(this.mImmediateImageOut);
    }

    // profile monitor
    public boolean isTraceFileOut() 
    {
        return(this.mIsTraceFileOut);
    }
    public boolean isProgramMarkerOn()
    {
        return(this.mIsProgramMarkerOn);
    }
    public boolean isTraceOutWithUnshotRadiosity() 
    {
        return(this.mIsTraceOutUnshotRadiosity);
    }
    public String getTraceFileBaseName()
    {
        return(this.mTraceFileBaseName);
    }

    // loop
    public boolean isRadioOutAtStep()  
    {
	return(this.mIsRadioOutAt);	
    }
    public void initLoopVar()
    {
	this.mRadioOutLoopVar = this.mRadioOutStartHC;
    }
    public boolean isInLoop()  
    {
	return(this.mRadioOutLoopVar <= this.mRadioOutEndHC);
    }
    public void nextLoopVar()
    {
	this.mRadioOutLoopVar += this.mRadioOutIncHCNum;
    }
    public int  getLoopVarValue()  { return(this.mRadioOutLoopVar);	}
    
    /**
     * print out 
     */
    public String toStringWithHead(String head)
    {
	head += " ";
	String s = 
	    head + "----- FileInfo Filename entries -----\n"	+
	    head + "conf    [" + this.mConfigFileName	+ "]\n" +
	    head + "spc     [" + this.mSpcFileName	+ "]\n" +
	    head + "mat     [" + this.mMatFileName	+ "]\n" +
	    head + "geo     [" + this.mGeoFileName	+ "]\n" +
	    head + "sysinfo [" + this.mSysInfoFileName	+ "]\n" +
	    head + "view    [" + this.mViewDataFileName   + "]\n" +
	    head + "save    [" + this.mSaveResultFileName + "]\t";
	s += " : save format   ";
	switch(this.mSaveFileFormat)
	{
	case FI_SAVE_PPM:
	    s += "ppm";
	    break;
	case FI_SAVE_GFB:	    
	    s += "gfb";
	    break;
	default:
	    s += "Error! (none) file format.";
	    break;
	}
	s += "\n" + head + "radout  = " + this.mRadioStageOutFileName + "\n";
	if(this.mIsRadioOutAt == true)
	{
	    String [] InfoType = { "Shot", "Unshot", "Both", };

	    s += head + "radIout = for(" + this.mRadioOutStartHC + "; " + 
		this.mRadioOutEndHC + "; " +
		this.mRadioOutIncHCNum + ")" + ", type " + 
		InfoType[this.mRadioIntermFileType] + "\n";
	    s += head + "radIout basename ["+ 
		this.mRadioIntermFileBaseName + "]\n";
	}else
	{
	    s += head + "radIout = NO\n";
	}
	s += head + "volList = " + this.mVolumeInFileListName + "\n";

	// for PRC method
	s += head + "PRCmap  = " + this.mDistanceDataFileName + "\n";

	// for Immediate Image Out
	s += head + "Immediate Image out = " + 
	    ((this.mImmediateImageOut == true) ? "true" : "NO") + "\n";
	
	// for Genvol (option 関係を共有できる)
	if(Mpi2Option.getInstance().isCompressOut() == true)
	{
	    s += head + "Compress Command = " + this.mCompressCommand + "\n";
	}else
	{
	    s += head + "No output will be compressed.\n";
	}

	s += head + "(for only genvol4mpi2) : out volumefilename format = "+ 
	    this.mGenvolOutFileNameFormat + "\n";

	// profile monitor
	if(Config.Use_Profile_Monitor == true)
	{
	    if(this.isTraceFileOut())
	    {
		s += head + 
		    "Profile Trace: On, Total Radiosity Calc: " +
		    ((this.isTraceOutWithUnshotRadiosity()) ? "On" : "Off") +
		    ", Output file basename [" + this.getTraceFileBaseName()+
		    "]\n";
	    }else
	    {
		s += head + "Profile Trace: Off\n";
	    }
	}else
	{
	    s += head + "Compile : Use_Profile_MonitorTrace disabled.\n";
	}
    
	s += head + "Compile : Use_IBM_Program_MarkerArray ";
	if(Config.Use_IBM_Program_MarkerArray == true)
	{
	    s += "enabled,"+((this.isProgramMarkerOn()) ? "On" : "Off") + "\n";
	}else
	{
	    s += "disabled.\n";
	}
	s += head + "Compile : Use_IBM_Program_MarkerArray ";
	if(Config.Use_Mpi2_Program_MarkerArray == true)
	{
	    s += "enabled," + ((this.isProgramMarkerOn()) ? "On" : "Off")+"\n";
	}else
	{
	    s += "disabled.\n";
	}
	return(s);
    }

    /**
     * ここに保持されているファイル間の一貫性を見る 
     * 	@return レンダリング可能なだけの条件がそろっていれば true
     */
    public boolean isOKforMpi2()
    {
	final String mes1 = "Error! : FileInfo : lack of ";
	final String mes2 = " for rendering, abort.";
	
	boolean isOK           = true;  // この FileInfo の保持する内容は妥当か
	boolean isObjDat       = false;	// 物体情報は存在するのか
    
	// 空間の定義情報 : 必要
	if(this.mSpcFileName.equals(INIT_FILENAME))
	{
	    isOK = false;
	    if(Mpi2Option.getInstance().getVerboseMode())
	    {
		throw new RuntimeException(mes1 + "space file" + mes2);
	    }
	}
	
	// sysinfo : 必要
	if(this.mSysInfoFileName == INIT_FILENAME)
	{
	    isOK = false;
	    if(Mpi2Option.getInstance().getVerboseMode())
	    {
		throw new RuntimeException(mes1 + "sysinfo file" + mes2);
	    }
	}
	
	// view data : 必要
	if(this.mViewDataFileName == INIT_FILENAME)
	{
	    isOK = false;
	    if(Mpi2Option.getInstance().getVerboseMode())
	    {
		throw new RuntimeException(mes1 + "viewdata file" + mes2);
	    }
	}
	
	// mat file があるが geo file がない あるいは
	// geo file があるが mat file がない場合は error : これらはペア
	if(((!(this.mMatFileName.equals(INIT_FILENAME))) && 
	    (this.mGeoFileName.equals(INIT_FILENAME))) ||
	   ((this.mMatFileName.equals(INIT_FILENAME)) && 
	    (!(this.mGeoFileName.equals(INIT_FILENAME)))))
	{
	    isOK = false;
	    if(Mpi2Option.getInstance().getVerboseMode())
	    {
		final String s = mes1 + "geo file or material file.\n" +
		    "geo file and material file must be specify " + 
		    "at the same time.";
		throw new RuntimeException(s);
	    }
	}else if(!(this.mGeoFileName.equals(INIT_FILENAME)))
	{
	    /*
	     * 上記の条件でなく，しかも geo file がある場合には必ず 
	     * material file は存在する．geo と material が両方存在し
	     * ない場合はある．geo, material の組は必須ではない．
	     * (volume のみのレンダリングもあり．)
	     */
	    isObjDat = true;
	}
	
	// output filename : 必要
	if(this.mSaveResultFileName.equals(INIT_FILENAME))
	{
	    isOK = false;
	    if(Mpi2Option.getInstance().getVerboseMode())
	    {
		throw new RuntimeException(mes1 + "output filename" + mes2);
	    }
	}
	
	/*
	 * volume file : 必須ではない．(get, mat のみをレンダリングす
	 * る場合あり．)
	 */
	if(!(this.mVolumeInFileListName.equals(INIT_FILENAME)))
	{
	    isObjDat = true;    
	}
	
	/*
	 * radiosity stage の結果出力が指定されている場合にはファイル名指定
	 */
	if((this.mIsRadioStageResOut == true) &&
	   (this.mRadioStageOutFileName.equals(INIT_FILENAME)))
	{
	    isOK = false;
	    if(Mpi2Option.getInstance().getVerboseMode())
	    {
		throw new RuntimeException(mes1 + "radiosity stage output file"
					   + mes2);
	    }
	}
	
	// 出力指定時にパラメータ初期化確認
	if(this.mIsRadioOutAt == true)
	{
	    // 数値の範囲と basename のチェック
	    if((this.mRadioOutStartHC  <  0) ||
	       (this.mRadioOutIncHCNum <= 0) ||
	       (this.mRadioOutStartHC  > this.mRadioOutEndHC) ||
	       (this.mRadioIntermFileBaseName.equals(INIT_FILENAME)))
	    {
		isOK = false;
		if(Mpi2Option.getInstance().getVerboseMode())
		{
		    final String s = mes1 + 
			"periodically radio out parameters\n" + 
			"\t In spite of RadiosityIFileOut == On.";
		    throw new RuntimeException(s);
		}
	    }
	}
	
	// 物体情報がまったくない場合にはレンダリングできない
	if(isObjDat == false)
	{
	    isOK = false;
	    if(Mpi2Option.getInstance().getVerboseMode()) 
	    {
		throw new RuntimeException(mes1 + 
					   "object data (geometry or volume)"
					   + mes2);
	    }
	}
	return(isOK);
    }

    static LineParser.Element[] configElements = {
      // Options.
      new LineParser.Type("DebugMode", new String[] {"On", "Off"}),
      new LineParser.Type("VerboseMode", new String[] {"On", "Off"}),
      new LineParser.Type("ShowReadData", new String[] {"On", "Off"}),
      new LineParser.Type("ShowObjNumInSubSpc", new String[] {"On", "Off"}),
      new LineParser.Type("ImmediateImageOut", new String[] {"On", "Off"}),
      // Input files.
      new LineParser.Name("SpaceParamFile"),
      new LineParser.Name("SysinfoParamFile"),
      new LineParser.Name("ViewFile"),
      new LineParser.Name("MaterialFile"),
      new LineParser.Name("GeometryFile"),
      new LineParser.Name("VolumeInfileListFile", INIT_FILENAME),
      new LineParser.Name("PCMdistanceFile", INIT_FILENAME),
      // Output files.
      new LineParser.Name("RadiosityResultFile", INIT_FILENAME),
      new LineParser.Type("RadiosityIFileOut", new String[]{"On", "Off"}),
      new LineParser.Name("RadiosityIFileBaseName", INIT_FILENAME),
      new LineParser.Number("RadiosityIFileOutParam", 3,
			    new double[]{0.0, 0.0, 0.0}),
      new LineParser.Type("RadiosityIFileType",
			  new String[]{"ShotRadiosity", "UnshotRadiosity", "BothRadiosity"},
			  "BothRadiosity"),
      new LineParser.Type("SaveOutFileType", new String[]{"ppm", "gfb"}),
      new LineParser.Name("SaveOutFile"),
      new LineParser.Name("GenvolOutputFileNameFormat", "volimg%04d.svol"),
      // Other information.
      new LineParser.Name("CompressCommand", "gzip"),
      // Profile Monitor
      new LineParser.Type("OutputProfileTrace", new String[]{"On", "Off"}),
      new LineParser.Type("ProgramMarker", new String[]{"On", "Off"}),
      new LineParser.Type("CalcTotalUnshotRadiosityEnergy", 
			  new String[]{"On", "Off"}),
      new LineParser.Name("ProfileMonBasename", INIT_FILENAME),
    };
    /**
     * config file を読む
     */
    public void readConfigFile() throws IOException
    {
      LineParser lp = new LineParser(configElements);
      FileInputStream fin = new FileInputStream(mConfigFileName);
      Map config = lp.parseAll(fin);
      fin.close();

      mSpcFileName = (String)config.get("SpaceParamFile");
      mSysInfoFileName = (String)config.get("SysinfoParamFile");
      mViewDataFileName = (String)config.get("ViewFile");
      mMatFileName = (String)config.get("MaterialFile");
      mGeoFileName = (String)config.get("GeometryFile");
      mSaveResultFileName = (String)config.get("SaveOutFile");
      mSaveFileFormat = ((String)config.get("SaveOutFileType")).equals("ppm") ?
	FI_SAVE_PPM : FI_SAVE_GFB;
      mVolumeInFileListName = (String)config.get("VolumeInfileListFile");
      mRadioStageOutFileName = (String)config.get("RadiosityResultFile");
      mIsRadioStageResOut = !(mRadioStageOutFileName.equals(INIT_FILENAME));
      mIsRadioOutAt = ((String)config.get("RadiosityIFileOut")).equals("On");
      double[] radioIOutParam = (double[])config.get("RadiosityIFileOutParam");
      mRadioOutStartHC = (int)radioIOutParam[0];
      mRadioOutEndHC = (int)radioIOutParam[1];
      mRadioOutIncHCNum = (int)radioIOutParam[2];
      mRadioIntermFileBaseName = (String)config.get("RadiosityIFileBaseName");
      String radioIFileType = (String)config.get("RadiosityIFileType");
      if (radioIFileType.equals("ShotRadiosity")) {
         mRadioIntermFileType = FI_RADIOI_SHOT;
      } else if (radioIFileType.equals("UnshotRadiosity")) {
         mRadioIntermFileType = FI_RADIOI_UNSHOT;
      } else {
         mRadioIntermFileType = FI_RADIOI_BOTH;
      }
      mImmediateImageOut = ((String)config.get("ImmediateImageOut")).equals("On");
      mCompressCommand = (String)config.get("CompressCommand");
      mGenvolOutFileNameFormat = (String)config.get("GenvolOutputFileNameFormat");
      mDistanceDataFileName = (String)config.get("PCMdistanceFile");

      // profile monitor
      this.mIsTraceFileOut    = "On".equals(config.get("OutputProfileTrace"));
      this.mIsProgramMarkerOn = "On".equals(config.get("ProgramMarker"));
      this.mIsTraceOutUnshotRadiosity = 
	  "On".equals(config.get("CalcTotalUnshotRadiosityEnergy"));
      this.mTraceFileBaseName = (String)config.get("ProfileMonBasename");
    }

    /**
     * ある file info でこの file info を上書きする (Command Line
     * Option を上書きするため．ただし，mode option については 
     * fileinfo と command line の or をとるのでここでは扱わない．
     *
     *   @param cLineFIF	command line で取得した FileInfo
     */
    public void overrideFileInfoWithOption(FileInfo cLineFIF)
    {
	if(!(cLineFIF.getSpcFileName().equals(INIT_FILENAME)))
	{
	    this.setSpcFileName(cLineFIF.getSpcFileName());
	    this.overrideMes("spcinfo  filename", cLineFIF.getSpcFileName());
	}
	if(!(cLineFIF.getMatFileName().equals(INIT_FILENAME)))
	{
	    this.setMatFileName(cLineFIF.getMatFileName());
	    this.overrideMes("material filename", cLineFIF.getMatFileName());
	}
	if(!(cLineFIF.getGeoFileName().equals(INIT_FILENAME)))
	{
	    this.setGeoFileName(cLineFIF.getGeoFileName());
	    this.overrideMes("geometry filename", cLineFIF.getGeoFileName());
	}
	if(!(cLineFIF.getSaveResultFileName().equals(INIT_FILENAME)))
	{
	    this.setSaveResultFileName(cLineFIF.getSaveResultFileName()); 
	    this.setSaveFileFormat(cLineFIF.getSaveFileFormat());
	    this.overrideMes("save result filename", 
			     cLineFIF.getSaveResultFileName());
	}
	if(!(cLineFIF.getSysInfoFileName().equals(INIT_FILENAME)))
	{ 
	    this.setSysInfoFileName(cLineFIF.getSysInfoFileName());
	    this.overrideMes("sysinfo filename",cLineFIF.getSysInfoFileName());
	}
	if(!(cLineFIF.getViewDataFileName().equals(INIT_FILENAME)))
	{
	    this.setViewDataFileName(cLineFIF.getViewDataFileName());
	    this.overrideMes("view filename",cLineFIF.getViewDataFileName());
	}
	if(!(cLineFIF.getRadioStageOutFileName().equals(INIT_FILENAME)))
	{
	    this.setRadioStageOutFileName(cLineFIF.getRadioStageOutFileName());
	    this.overrideMes("radiosity stage result filename",
			     cLineFIF.getRadioStageOutFileName());
	}
	if(!(cLineFIF.getRadioIntermediateBaseName().equals(INIT_FILENAME)))
	{
	    this.setRadioIntermediateBaseName(cLineFIF.
					      getRadioIntermediateBaseName());
	    this.overrideMes("radiosity intermediate result basename",
			     cLineFIF.getRadioIntermediateBaseName());
	}
	if(!(cLineFIF.getVolumeInFileListName().equals(INIT_FILENAME)))
	{
	    this.setVolumeInFileListName(cLineFIF.
					 getVolumeInFileListName());
	    this.overrideMes("volume infile list filename",
			     cLineFIF.getVolumeInFileListName());
	}
	if(!(cLineFIF.getDistanceDataFileName().equals(INIT_FILENAME)))
	{
	    this.setDistanceDataFileName(cLineFIF.
					 getDistanceDataFileName());
	    this.overrideMes("proximity clouds method distance filename",
			     cLineFIF.getDistanceDataFileName());
	}	
    }
    private void overrideMes(String mes, String fname)
    {
	if((Mpi2Option.getInstance().getVerboseMode() == true) || 
	   (Mpi2Option.getInstance().getDebugMode()   == true))
	{
	    System.out.println(VERBOSEHEAD + " Override " + mes + 
			       " as [" + fname + "].");
	}	
    }
}




