#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream.h>

#include "outilsinit.h"
#include "ntuple.h"

int main(int, char **)
{
PeidaInit();

char * names[3] = {"XPos", "YPos", "Val"};
int i,j, k;
float xnt[3];

printf("Creation Ntuple avec X,Y,Val ... \n");
NTuple  nt1(3, names, 20);

k = 0;
for(j=0; j<8; j++)
  for(i=0; i<12; i++)
    { xnt[0] = i+0.5;  xnt[1] = j+0.5;  xnt[2] = k;
    nt1.Fill(xnt); k++; }

nt1.Show(cout);
nt1.Print(0, 5);
nt1.Print(18, 5);
nt1.Print(94, 5);

string fn = "nt.ppf";
{
printf("Ecriture NTuple ds nt.ppf ... \n");
ObjFileIO<NTuple> fio(&nt1);
fio.Write(fn);
}

{
printf("Lecture NTuple (nt2) ds nt.ppf ... \n");

ObjFileIO<NTuple> fio(fn);
NTuple* nt2 = (NTuple*)fio.DataObj();
nt2->Show(cout);
nt2->Print(0, 5);
nt2->Print(18, 5);
nt2->Print(94, 5);
}

/*
printf("ReLecture NTuple (nt1) ds nt.ppf ... \n");

nt1.Read("nt.ppf");
nt1.Show(cout);
nt1.Print(0, 5);
nt1.Print(18, 5);
nt1.Print(94, 5);

printf("Creation/Lecture Lecture NTuple (nt1) ds nt.ppf ... \n");
NTuple nt3;
nt3.Read("nt.ppf");
nt3.Show(cout);
nt3.Print(0, 5);
nt3.Print(18, 5);
nt3.Print(94, 5);
*/

exit(0);
}


