/*commanlinetool for segmentation */
#include <fstream.h>
#include <stdio.h>
#include <time.h>

#include "../datalib/vector.h"
#include "../datalib/volume.h"
#include "../mathlib/statistic.h"
#include "../mathlib/transform.h"
#include "../mathlib/moments.h"

#include "../errorcode.h"

#include "../datalib/datacube.h"
#include "../datalib/cfddatacube.h"
#include "../datalib/testcubes.h"

#include "../reconstructionlib/reconstruction.h"
#include "../mathlib/nld.h"

#include "command_line_parser.h"

using namespace std;
using namespace pramodx;


int
main(int argc, char **argv)
{
    DataCube convert(3);
	char inputfile[80];
	char outputfile[80];
	Vector<int> size(3);
	Vector<double> d(3);
	size[1]=0;	size[3]=0;	size[3]=0;
	d[1]=1.0;d[2]=1.0;d[3]=1.0;
        int invert=0;
        command_line_parser parser(argc, argv);
    if (argc<2)
    {
        cout << "Usage: nihtoraw inputfilename.nih outputfilename" << endl;
        return 0;
    };

    for (int i=0;i<parser.get_n_options();i++)
    {
        option o=parser.get_option(i);
        if (strcmp(o.get_option(),"h")==0 || parser.get_n_filenames()==0)
        {
            cout << "Usage: nihtoraw inputfilename.nih outputfilename" << endl;
            return 0;
        };

       


    };

sprintf(inputfile,parser.get_filename(0));
printf("Inputfile:");
printf(inputfile);
printf("\n");
sprintf(outputfile,parser.get_filename(1),"%s%s","ZXchanged");
printf("Outputfile:");
printf(outputfile);
printf("\n");
int errorcode;
errorcode=convert.ReadFromNIH(inputfile);

if (errorcode) 
{
    cout << "Error durring read!" << endl;
    cout << "Error:" << errorCode(errorcode) << endl;
    return 1;
};
 
 char buffer[180];
 sprintf(buffer,"%s%s",parser.get_filename(1), ".info.txt");
 printf("%s%s",parser.get_filename(1), ".info.txt"); 
convert.writeRAWZXSwitched(outputfile,buffer);
return 0;
}


