/*
# dataAnalysis_kayabuki : $Revision$  
# $Date$ 
# Created by $Author$
# Usage : dataAnalysis_kayabuki
# Attention
#   $Loccker$
#  	$State$ 
#
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>                  
#define GLOBAL_DECLARATION
#include "../inc/config.h"

#define DEBUG
#include "genUtil.h"

/*
Example:
typedef struct ldataAnalysis_kayabukiInfo {
	float a;
	int   b;
} ldataAnalysis_kayabukiInfo;

typedef enum ldataAnalysis_kayabukiMode {
	a=0,
	b=1
} ldataAnalysis_kayabukiMode;
*/

int
main(int argc, char* argv[]) 
{
	dataAnalysis_kayabukiInfo info;
	//double data[3][3][3][30][12];
	int i,j,k,l,m,n,o;
	double ind[3];
	double out1, out2;

	init0(&info);
    argCheck(&info, argc, argv);
    init1(&info);

	DEBUGPRINT("Program Start\n");
	if(info.mode==4){
		for(i=0;i<20;i++){
			for(j=0;j<3;j++){
				fscanf(info.fptIn,"%lf",&ind[j]);
				out1=ind[j]-3.0; out2=ind[j]+3.0;
				fprintf(info.fptOut,"-Rot%d %f %f 2.0 ",j+1,out1,out2);
			}
			fprintf(info.fptOut,"\n");
		}
	}else if(info.mode==10){
		for(i=0;i<40;i++){
			for(j=0;j<3;j++){
				fscanf(info.fptIn,"%lf",&ind[j]);
				fprintf(info.fptOut,"-Rot%d %f %f 1.0 ",j+1,ind[j],ind[j]);
			}fprintf(info.fptOut,"\n");	
		}
	}else if(info.mode==5){
		for(i=0;i<11;i++){
			for(j=0;j<3;j++){
				fscanf(info.fptIn,"%lf",&ind[j]);
				fprintf(info.fptOut,"-Rot%d %f %f 1.0 ",j+1,ind[j],ind[j]);
			}fprintf(info.fptOut,"\n");
	    }
				 
}else if(info.mode==2){
		for(j=0;j<3;j++){
			fscanf(info.fptIn,"%lf",&ind[j]);
			fprintf(info.fptOut,"-Rot%d %f %f 1.0 ",j+1,ind[j],ind[j]);
		}
}else if(info.mode==1){
		for(j=0;j<3;j++){
			fscanf(info.fptIn,"%lf",&ind[j]);
			out1=ind[j]-3.0; out2=ind[j]+3.0;
			fprintf(info.fptOut,"-Rot%d %f %f 2.0 ",j+1,out1,out2);
		}
	}else if(info.mode==64){
		for(i=0;i<50;i++){
			fscanf(info.fptIn,"%lf",&ind[0]);
			fscanf(info.fptIn,"%lf",&ind[0]);
			fscanf(info.fptIn,"%lf",&ind[0]);
			out1=0;
			for(j=1;j<7;j++){
				
				fscanf(info.fptIn,"%lf",&ind[0]);
				fscanf(info.fptIn,"%lf",&ind[0]);
				out1+=ind[0];
				fscanf(info.fptIn,"%lf",&ind[0]);
			}
			fprintf(info.fptOut,"%f\n",out1);
		}
				
	}else{
		
		for(i=0;i<10;i++){
			for(j=0;j<3;j++){
				fscanf(info.fptIn,"%lf",&ind[j]);
				fprintf(stderr,"%f\t",ind[j]);
				out1=ind[j]-10.0; out2=ind[j]+10.0;
				fprintf(info.fptOut,"-Rot%d %f %f 5.0 ",j+1,out1,out2);
			}
			fprintf(info.fptOut,"\n");
		}
	}
	/*for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
				for(l=0;l<30;l++){
					for(m=0;m<12;m++){
						fscanf(info.fptIn,"%lf",&data[i][j][k][l][m]);
					}}}}}
	//fprintf(stdout,"%f %f\n",data[0][0][0][0][0],data[2][2][2][29][0]);
	*/
	/*//noise effects of each rotate , for all column positioned below before one
	for(i=0;i<12;i++){//column
		for(j=0;j<3;j++){//rotate
			for(k=0;k<30;k++){//sm
				for(l=0;l<3;l++){//noise
					for(m=0;m<3;m++){//num
						fprintf(info.fptOut,"%15.11f, ",data[j][l][m][k][i]);
					}}fprintf(info.fptOut,"\n");
			}fprintf(info.fptOut,"\n");
		}fprintf(info.fptOut,"\n");
	}*/
				
	//
	/*
	for(i=0;i<12;i++){//column
        for(j=0;j<3;j++){//noise
            for(k=0;k<30;k++){//sm
                for(l=0;l<3;l++){//rotate
                    for(m=0;m<3;m++){//num
						fprintf(info.fptOut,"%15.11f, ",data[l][j][m][k][i]);
					}}fprintf(info.fptOut,"\n");
			}fprintf(info.fptOut,"\n");
		}fprintf(info.fptOut,"\n");
	}
	*/					
											

	exit(EXIT_SUCCESS);
}

void
additionalUsage()
{
	fprintf(stderr, "----- Additional Usage -----\n");
}
