Allink  v0.1
ElPoly.cpp
00001 /***********************************************************************
00002 ElPoly:This progam provide a graphical visualisation of the data 
00003 opend by VarData using openGL glut. The most important option are 
00004 the possibility of changing the backfold of the polymers with 'c', 
00005 see the subsequent file in the list with '>', see the bond with 'b'. 
00006 Copyright (C) 2008 by Giovanni Marelli <sabeiro@virgilio.it>
00007 
00008 
00009 This program is free software; you can redistribute it and/or modify
00010 it under the terms of the GNU General Public License as published by
00011 the Free Software Foundation; either version 2 of the License, or
00012 (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 ***********************************************************************/
00023 #include "ElPoly.h"
00024              //#include "../include/Draw.h"
00025 
00026 ElPoly *Pol;
00027 void Legenda();
00028 
00029 #ifdef __glut_h__
00030 void MenuChoise(int option){
00031   //Pol->What2Draw = option;
00032   Pol->ElMenuChoise(option);
00033 }
00034 void MenuVisual(int option){
00035   //Pol->What2Draw = option;
00036   Pol->ElMenuVisual(option);
00037 }
00038 #endif
00039 int main(int argc,char **argv){
00040   if(argc<2){
00041     printf("Mi serve come argomento un file!\n");
00042     return 0;
00043   }
00044   int *FilePos = (int *)calloc(argc,sizeof(int));
00045   char Comando[60];
00046   char ConfF[256];
00047   char cWhat2Draw[12];
00048   sprintf(cWhat2Draw,"part");
00049   sprintf(ConfF,"Polymers.conf");
00050   sprintf(Comando,"ciccia");
00051   int NBin = 100;
00052   int NSample = 32;
00053   int NFile = 0;
00054   int IfUser = 1;
00055   int IfCreate = 0;
00056   int nBlock = 0;
00057   int quando = 0;
00058   int Coord = 2;
00059   int CoordProfile = 0;
00060   int nNano = 0;
00061   int BackFold = BF_PART;
00062   int NParam = 0;
00063   double Param[10];
00064   //Number = (char *)malloc(100*sizeof(char));
00065   //  frame = (char *)malloc(100*sizeof(char));
00066   //SpecFuntore <Matematica> SpecMat(&Mat,Matematica::Eval);
00067   //SpecFuntore <ElPoly> SpecPol(&Pol,ElPoly::ContactAngle);
00068   for(int i=1;i<argc;i++){
00069     if(argv[i][0] != '-'){
00070       FilePos[NFile] = i;
00071       NFile++;
00072     }
00073     if(!strcmp(*(argv+i),"--help")){
00074       Legenda();
00075       return 0;
00076     }
00077     if(!strcmp(*(argv+i),"-b")){
00078       char sBf[12];
00079       if(argc < i){printf("Which backfold?\n");return 1;}
00080       i += 1;
00081     }
00082     else if(!strcmp(*(argv+i),"-bl")){
00083       if(argc < i){printf("Which block?\n");return 1;}
00084       sscanf(argv[i+1],"%d",&nBlock);
00085       i+=1;
00086     }
00087     else if(!strcmp(*(argv+i),"-c")){
00088       if(argc < i){printf("Which normal coordinate?\n");return 1;}
00089       i+=1;
00090     }
00091     else if(!strcmp(*(argv+i),"-cc")){
00092       if(argc < i){printf("Which coordinate for the profile?\n");return 1;}
00093       sscanf(argv[i+1],"%d",&CoordProfile);
00094       i+=1;
00095     }
00096     else if(!strcmp(*(argv+i),"-d")){
00097       sprintf(Comando,"d");
00098       if(argc < i){printf("What to visualize?\n");return 1;}
00099       sscanf(argv[i+1],"%s",&cWhat2Draw);
00100       i+=1;
00101       IfUser = 0;
00102     }
00103     else if(!strcmp(*(argv+i),"-f")){
00104       if(argc < i+1){printf("Which files?\n");return 1;}
00105       i+=2;
00106    }
00107     else if(!strcmp(*(argv+i),"-n")){
00108       if(argc < i){printf("Which nanoparticle?\n");return 1;}
00109       sscanf(argv[i+1],"%d",&nNano);
00110       i+=1;
00111     }
00112     else if(!strcmp(*(argv+i),"--normalize")){
00113     }
00114     else if(!strcmp(*(argv+i),"-p")){
00115       if(argc < i){printf("Which value for the paramter?\n");return 1;}
00116       i+=1;
00117     }
00118     else if(!strcmp(*(argv+i),"-s")){
00119       if(argc < i){printf("How many samples?\n");return 1;}
00120       sscanf(argv[i+1],"%d",&NSample);
00121       i+=1;
00122     }
00123     else if(!strcmp(*(argv+i),"--scale")){
00124       if(argc < i){printf("What scale?\n");return 1;}
00125       i+=3;
00126     }
00127     else if(!strcmp(*(argv+i),"--scalez")){
00128       if(argc < i){printf("What scale?\n");return 1;}
00129       i+=1;
00130     }
00131     else if(!strcmp(*(argv+i),"--skip")){
00132       if(argc < i){printf("How many chains to skip?\n");return 1;}
00133       i+=1;
00134     }
00135     else if(!strcmp(*(argv+i),"--Shift")){
00136       i+=3;
00137     }
00138     else if(!strcmp(*(argv+i),"-v")){
00139       if(argc < i){printf("How many values?\n");return 1;}
00140       sscanf(argv[i+1],"%d",&NBin);
00141       i+=1;
00142     }
00143     else if(!strcmp(*(argv+i),"-x")){
00144       IfCreate = 1;
00145     }
00146     else if(!strncmp(*(argv+i),"--",2)){
00147       sprintf(Comando,"%s",argv[i]+2);
00148       IfUser = 0;
00149     }
00150   }
00151   if(IfCreate){
00152     VarData *Dat = new VarData;
00153     Dat->DefSoft(argv[FilePos[0]],ConfF);
00154     return 0;
00155   }
00156   Pol = new ElPoly(NFile,argv,FilePos);
00157   for(int i=1;i<argc;i++){
00158     if(!strcmp(*(argv+i),"-b")){
00159       char sBf[12];
00160       if(argc < i){printf("Which backfold?\n");return 1;}
00161       sscanf(argv[i+1],"%s",sBf);
00162       if(!strcmp(sBf,"part"))
00163     BackFold = BF_PART;
00164       else if(!strcmp(sBf,"no"))
00165     BackFold = BF_NO;
00166       else if(!strcmp(sBf,"chain"))
00167     BackFold = BF_CHAIN;
00168       else if(!strcmp(sBf,"skip"))
00169     BackFold = BF_SKIP;
00170       else if(!strcmp(sBf,"nano"))
00171     BackFold = BF_NANO;
00172       else if(!strcmp(sBf,"tilt"))
00173     BackFold = BF_TILT;
00174       else{
00175    printf("Backfold not recognized set to chain\n");
00176    BackFold = BF_CHAIN;
00177       }
00178       Pol->SetBackFold(BackFold);
00179       i+=1;
00180     }
00181     else if(!strcmp(*(argv+i),"-c")){
00182       if(argc < i){printf("Which normal coordinate?\n");return 1;}
00183       sscanf(argv[i+1],"%d",&Coord);
00184       Pol->SetCNorm(Coord);
00185       i+=1;
00186     }
00187     else if(!strcmp(*(argv+i),"--normalize")){
00188       Pol->SetIfNormalize(1);
00189     }
00190     else if(!strcmp(*(argv+i),"-f")){
00191       int InitFile = 0;
00192       int EndFile = 0;
00193       if(argc < i+1){printf("Which files?\n");return 1;}
00194       sscanf(argv[i+1],"%d",&InitFile);
00195       sscanf(argv[i+2],"%d",&EndFile);
00196       Pol->SetBoundFile(InitFile,EndFile);
00197       i+=2;
00198     }
00199     else if(!strcmp(*(argv+i),"-p")){
00200       if(argc < i){printf("Which value for the paramter?\n");return 1;}
00201       sscanf(argv[i+1],"%lf",Param);
00202       Pol->ExtParam = Param[0];
00203       NParam = 1;
00204       i+=1;
00205     }
00206     else if(!strcmp(*(argv+i),"--Ref")){
00207       double RefPos[3]   = {.0,.0,.0};
00208       double ShiftPos[3] = {.0,.0,.0};
00209       if(i<argc-2){
00210    for(int d=0;d<3;d++){
00211      sscanf(*(argv+d+i+1),"%lf",RefPos+d);
00212      ShiftPos[d] = RefPos[d] - .5;
00213    }
00214    i+=3;
00215       }
00216       Pol->SetShiftPos(ShiftPos);
00217     }  
00218     else if(!strcmp(*(argv+i),"-s")){
00219       Pol->NEdge = NSample;
00220       i+=1;
00221     }
00222     else if(!strcmp(*(argv+i),"--scale")){
00223       double Scale[3];
00224       if(argc < i){printf("What scale?\n");return 1;}
00225       for(int d=0;d<3;d++){
00226    sscanf(*(argv+d+i+1),"%lf",Scale+d);
00227       }
00228       Pol->SetScaleF(Scale);
00229       i+=3;
00230     }
00231     else if(!strcmp(*(argv+i),"--scalez")){
00232       double Scale;
00233       if(argc < i){printf("What scale?\n");return 1;}
00234       sscanf(argv[i+1],"%lf",&Scale);
00235       Pol->ScaleFact = Scale;
00236       i+=1;
00237     }
00238     else if(!strcmp(*(argv+i),"--skip")){
00239       if(argc < i){printf("How many lipid to skip in the visualisation?\n");return 1;}
00240       int NSkip = 0;
00241       sscanf(argv[i+1],"%d",&NSkip);
00242       Pol->SetNVisSkip(NSkip);
00243       i+=1;
00244     }
00245     else if(!strcmp(*(argv+i),"--Shift")){
00246       double ShiftPos[3] = {.0,.0,.0};
00247       if(i<argc-2){
00248    for(int d=0;d<3;d++){
00249      sscanf(*(argv+d+i+1),"%lf",ShiftPos+d);
00250    }
00251    i+=3;
00252       }
00253       Pol->SetShiftPos(ShiftPos);
00254     }
00255     else if(!strcmp(*(argv+i),"-S")){
00256       int Shift = SHIFT_NO;
00257       char sBf[12];
00258       if(argc < i){printf("Which shift?\n");return 1;}
00259       sscanf(argv[i+1],"%s",sBf);
00260       if(!strcmp(sBf,"cm"))
00261     Shift = BF_PART;
00262       else if(!strcmp(sBf,"nano"))
00263     Shift = BF_NO;
00264       else if(!strcmp(sBf,"cm_nano"))
00265     Shift = BF_CHAIN;
00266       else{
00267    printf("shift not recognized set to no\n");
00268    Shift = SHIFT_NO;
00269       }
00270       Pol->ShiftSys(Shift);
00271       i+=1;
00272     }
00273   }
00274   Pol->Open(argv[FilePos[0]],BackFold);
00275   if(!IfUser)sprintf(Pol->cWhat2Draw,"%s",cWhat2Draw);
00276   char cSystem1[STRSIZE];
00277   char cSystem2[STRSIZE];
00278   Pol->SysInfo(cSystem1);
00279   Pol->SysDef(cSystem2);
00280   printf("------------------------------------------------------\n");
00281   printf("%s NFile %d\n%s\n",cSystem1,NFile,cSystem2);
00282   printf("------------------------------------------------------\n");
00283   while(strcmp(Comando,"q")){
00284     if(IfUser){
00285       printf("ElPoly> ");
00286       scanf("%s",Comando);
00287     }
00288     if(!strcmp(Comando,"d")){
00289 #ifdef __glut_h__
00290       Pol->Graphics(argc,argv);
00291 #else 
00292       printf("Graphics libraries (GL/glut.h) not supplied\n");
00293 #endif //__glut_h__
00294     }
00295     else if(!strcmp(Comando,"?") ){
00296       Legenda();
00297     }
00298     else if(!strcmp(Comando,"!") ){
00299       printf("Insert a shell command: ");
00300       scanf("%s",Comando);
00301       system(Comando);
00302     }//--------------------Dens-Func----------------------
00303     else if(!strcmp(Comando,"dens")){
00304       Pol->DensProf(NBin,NSample,Coord);
00305       if(!IfUser) return 0;
00306     }//--------------------3To2-------------------------
00307     else if(!strcmp(Comando,"3to2")){
00308       Pol->From3To2d(NSample,Param[0]);
00309       if(!IfUser) return 0;
00310     }//--------------------3To1-------------------------
00311     else if(!strcmp(Comando,"3to1")){
00312       Pol->From3To1d(Coord);
00313       if(!IfUser) return 0;
00314     }//--------------------2To1-------------------------
00315     else if(!strcmp(Comando,"2to1")){
00316       Pol->From2To1d(Coord);
00317       if(!IfUser) return 0;
00318     }//--------------------Projection----------------------
00319     else if(!strcmp(Comando,"pro")){
00320       Pol->ProjectionF(NBin,Coord);
00321       if(!IfUser) return 0;
00322     }//--------------------Core-Part----------------------
00323     else if(!strcmp(Comando,"core")){
00324       Pol->CoreF(NSample,0);
00325       if(!IfUser) return 0;
00326     }//--------------------Core-Nano----------------------
00327     else if(!strcmp(Comando,"coreNano")){
00328       Pol->CoreF(NSample,1);
00329       if(!IfUser) return 0;
00330     }//--------------------Radial-Shell--------------------
00331     else if(!strcmp(Comando,"RadShell")){
00332       Pol->RadialShell(NBin);
00333       if(!IfUser) return 0;
00334     }//--------------------Contact-Angle-------------------
00335     else if(!strcmp(Comando,"angle")){
00336       Pol->Angle(NBin);
00337       if(!IfUser) return 0;
00338     }//--------------------Slab-Prof-----------------------
00339     else if(!strcmp(Comando,"SlabProf")){
00340       Pol->SlabProf(NBin,nNano,CoordProfile);
00341       if(!IfUser) return 0;
00342     }//--------------------Slab-Prof-----------------------
00343     else if(!strcmp(Comando,"SlabAngleProfs")){
00344       Pol->SlabAngleProfs(NBin,10,CoordProfile);
00345       if(!IfUser) return 0;
00346     }//--------------------Cart-Dens-----------------------
00347     else if(!strcmp(Comando,"CartDens")){
00348       Pol->CartDens(NBin,nNano);
00349       if(!IfUser) return 0;
00350     }//--------------------Rad-Nano-----------------------
00351     else if(!strcmp(Comando,"radNano")){
00352       Pol->RadDistrF(NBin,1,nNano);
00353       if(!IfUser) return 0;
00354     }//--------------------Rad-Cm----------------------------
00355     else if(!strcmp(Comando,"radCm")){
00356       Pol->RadDistrF(NBin,0,nNano);
00357       if(!IfUser) return 0;
00358     }//--------------------Rad-CmN----------------------------
00359     else if(!strcmp(Comando,"radCmN")){
00360       Pol->RadDistrF(NBin,2,nNano);
00361       if(!IfUser) return 0;
00362     }//--------------------Rad-CmN----------------------------
00363     else if(!strcmp(Comando,"radStalk")){
00364       Pol->RadDistrF(NBin,4,nNano);
00365       if(!IfUser) return 0;
00366     }//--------------------Rad-CmN----------------------------
00367     else if(!strcmp(Comando,"radPore")){
00368       Pol->RadDistrF(NBin,5,nNano);
00369       if(!IfUser) return 0;
00370     }//----------Cartesian-around-the-pep---------------------
00371     else if(!strcmp(Comando,"cartNano")){
00372       Pol->RadDistrF(NBin,6,nNano);
00373       if(!IfUser) return 0;
00374     }//----------Distribution-of-the-bond-length-----------------
00375     else if(!strcmp(Comando,"BondDistr")){
00376       Pol->BondDistr(NSample);
00377       if(!IfUser) return 0;
00378     }//----------Distribution-of-the-splay-angle-----------------
00379     else if(!strcmp(Comando,"SplayDistr")){
00380       Pol->SplayDistr(NSample);
00381       if(!IfUser) return 0;
00382     }//--------------------Center-Of-Mass------------------
00383     else if(!strcmp(Comando,"cm")){
00384       Pol->CenterOfMass(Coord);
00385       if(!IfUser) return 0;
00386     }//-------------------Thick-prof----------------------
00387     else if(!strcmp(Comando,"Dens2Thick")){
00388       Pol->RadDens2Thick(NBin);
00389       if(!IfUser) return 0;
00390     }//-------------------Thick-prof----------------------
00391     else if(!strcmp(Comando,"Dens2Thick2d")){
00392       Pol->RadDens2Thick2d(NBin);
00393       if(!IfUser) return 0;
00394     }//-------------------Thick-prof----------------------
00395     else if(!strcmp(Comando,"ThickFromDens")){
00396       Pol->ThickFromDens(NBin);
00397       if(!IfUser) return 0;
00398     }//--------------------Temperature----------------------
00399     else if(!strcmp(Comando,"temp")){
00400       Pol->Temperature(NBin,Coord);
00401       if(!IfUser) return 0;
00402     }//--------------------Nano-Particle---------------------
00403     else if(!strcmp(Comando,"nano")){
00404       Pol->NanoParticle(NBin);
00405       if(!IfUser) return 0;
00406     }//--------------------Surface------------------------
00407     else if(!strcmp(Comando,"surf")){
00408       Pol->Surface(NBin,1);
00409       if(!IfUser) return 0;
00410     }//--------------------Diffusivity------------------------
00411     else if(!strcmp(Comando,"diff")){
00412       Pol->Diffusivity();
00413       if(!IfUser) return 0;
00414     }//--------------------DiffusivitySlab------------------------
00415     else if(!strcmp(Comando,"DiffSlab")){
00416       Pol->DiffSlab(NSample);
00417       if(!IfUser) return 0;
00418     }//--------------------Pair-Corr--------------------
00419     else if(!strcmp(Comando,"PairCorr")){
00420       Pol->PairCorr(NBin,1);
00421       if(!IfUser) return 0;
00422     }//--------------------Pair-Correlation--------------------
00423     else if(!strcmp(Comando,"pairMon")){
00424       Pol->PairCorrelationF(NBin,0);
00425       if(!IfUser) return 0;
00426     }//--------------------Pair-Correlation--------------------
00427     else if(!strcmp(Comando,"pairChain")){
00428       Pol->PairCorrelationF(NBin,1);
00429       if(!IfUser) return 0;
00430     }//--------------------Pair-Correlation-----------------
00431     else if(!strcmp(Comando,"pairRound")){
00432       Pol->PairCorrelationF(NBin,2);
00433       if(!IfUser) return 0;
00434     }//--------------------Pair-Correlation------------------
00435     else if(!strcmp(Comando,"pairSquare")){
00436       Pol->PairCorrelationF(NBin,3);
00437       if(!IfUser) return 0;
00438     }//--------------------Pair-Correlation---------------
00439     else if(!strcmp(Comando,"pairPep")){
00440       Pol->PairCorrelationF(NBin,4);
00441       if(!IfUser) return 0;
00442     }//--------------------Average-snapshots---------------
00443     else if(!strcmp(Comando,"AvSnap")){
00444       Pol->AvSnap();
00445       if(!IfUser) return 0;
00446     }//--------------------Scattering--------------------
00447     else if(!strcmp(Comando,"scatt")){
00448       Pol->ScatteringF(NBin,0);
00449       if(!IfUser) return 0;
00450     }//--------------------Scattering--------------------
00451     else if(!strcmp(Comando,"scatt2")){
00452       Pol->ScatteringF(NBin,1);
00453       if(!IfUser) return 0;
00454     }//--------------------Worm--------------------
00455     else if(!strcmp(Comando,"worm")){
00456       Pol->WormF(20,NBin);
00457       if(!IfUser) return 0;
00458     }//--------------------Header--------------------
00459     else if(!strcmp(Comando,"header")){
00460       Pol->HeaderAverage(nNano);
00461       if(!IfUser) return 0;
00462     }//--------------------Spectrum--------------------
00463     else if(!strcmp(Comando,"spe")){
00464       Pol->SpectrumF(NSample);
00465       return 0;
00466       if(!IfUser) return 0;
00467     }//--------------------RadNormPos--------------------
00468     else if(!strcmp(Comando,"RadNormPos")){
00469       Pol->RadNormPos(NBin,NSample);
00470       if(!IfUser) return 0;
00471     }//--------------------PoreDistr--------------------
00472     else if(!strcmp(Comando,"AreaDistr")){
00473       Pol->AreaDistrF(NBin);
00474       if(!IfUser) return 0;
00475     }//--------------------Midplane----------------
00476     else if(!strcmp(Comando,"mid")){
00477       Pol->Midplane(NSample);
00478       if(!IfUser) return 0;
00479     }//--------------------Midplane----------------
00480     else if(!strcmp(Comando,"midSpe")){
00481       Pol->SpectrumMidplane(NSample);
00482       if(!IfUser) return 0;
00483     }//-------------------chain-properties--------------------
00484     else if(!strcmp(Comando,"prop")){
00485       Pol->PropertiesF();
00486       if(!IfUser) return 0;
00487     }//-------------------Divide-Layers--------------------
00488     else if(!strcmp(Comando,"divOpp")){
00489       Pol->DivideLayers(VAR_OPPOSED);
00490       if(!IfUser) return 0;
00491     }//-------------------Divide-Layers--------------------
00492     else if(!strcmp(Comando,"divTube")){
00493       Pol->DivideLayers(VAR_TUBE);
00494       if(!IfUser) return 0;
00495     }//-------------------Divide-Layers--------------------
00496     else if(!strcmp(Comando,"divVes")){
00497       Pol->DivideLayers(VAR_VESICLE);
00498       if(!IfUser) return 0;
00499     }//-------------------ChainPArea--------------------
00500     else if(!strcmp(Comando,"AreaCompr")){
00501       Pol->AreaCompr(NSample);
00502       if(!IfUser) return 0;
00503     }//-------------------Pre-Trace--------------------
00504     else if(!strcmp(Comando,"PTrace")){
00505       Pol->PressTrace();
00506       if(!IfUser) return 0;
00507     }//-------------------Press-Trace--------------------
00508     else if(!strcmp(Comando,"PRadial")){
00509       Pol->PressRadial();
00510       if(!IfUser) return 0;
00511     }//-------------------TensProf--------------------
00512     else if(!strcmp(Comando,"Tens")){
00513       Pol->SurfTens(NBin);
00514       if(!IfUser) return 0;
00515     }//-------------------TensProf--------------------
00516     else if(!strcmp(Comando,"TensCartRad")){
00517       Pol->Tens2dCartRad();
00518       if(!IfUser) return 0;
00519     }//-------------------TensSum--------------------
00520     else if(!strcmp(Comando,"SumTens")){
00521       Pol->SumTens();
00522       //Pol->Prova();
00523       if(!IfUser) return 0;
00524     }//-------------------Prova--------------------
00525     else if(!strcmp(Comando,"Prova")){
00526       Pol->Prova();
00527       if(!IfUser) return 0;
00528     }//-------------------Stalk--------------------
00529     else if(!strcmp(Comando,"stalk")){
00530       Pol->StalkF(32);
00531       if(!IfUser) return 0;
00532     }//-------------------Stalk--------------------
00533     else if(!strcmp(Comando,"StalkLine")){
00534       Pol->StalkLineProfF(NBin);
00535       if(!IfUser) return 0;
00536     }//-------------------BackBone--------------------
00537     else if(!strcmp(Comando,"BackBone")){
00538       double *Line = new double[NBin];
00539       Pol->BackBone(Line,NBin);
00540       if(!IfUser) return 0;
00541     }//-------------------Remove--------------------
00542     else if(!strcmp(Comando,"rem")){
00543       Pol->RemoveChains();
00544       if(!IfUser) return 0;
00545     }//-----------------Chain-position--------------------
00546     else if(!strcmp(Comando,"ChPos")){
00547       FILE *FWrite = fopen("ChainPos.dat","w");
00548       for(int c=0;c<Pol->pNChain();c++){
00549    fprintf(FWrite,"%lf %lf %lf\n",Pol->Ch[c].Pos[0],Pol->Ch[c].Pos[1],Pol->Ch[c].Pos[2]);
00550       }
00551       fclose(FWrite);
00552       if(!IfUser) return 0;
00553     }//-------------------Transform--------------------
00554     else if(!strcmp(Comando,"tra")){
00555       Pol->Transform(nBlock);
00556       Pol->Write("transformed.dat");
00557       if(!IfUser) return 0;      
00558     }//-------------------WriteXyz--------------------
00559     else if(!strcmp(Comando,"xyz")){
00560       Pol->WriteXyz("resume.dat");
00561       if(!IfUser) return 0;
00562     }//-------------------WriteXyz--------------------
00563     else if(!strcmp(Comando,"ConvLattice")){
00564       Pol->ConvLattice(NSample,"LatticePoints.dat");
00565       if(!IfUser) return 0;
00566     }//-------------------Write--------------------
00567     else if(!strcmp(Comando,"write")){
00568       Pol->Write("resume.dat");
00569       if(!IfUser) return 0;
00570     }//-------------------WidomOut--------------------
00571     else if(!strcmp(Comando,"WidomOut")){
00572       //Pol->WidomOut("NrgLipid.dat",NBin);
00573       Pol->WidomOut();
00574       if(!IfUser) return 0;
00575     }//-------------------WidomIn--------------------
00576     else if(!strcmp(Comando,"WidomIn")){
00577       //Pol->WidomIn("NrgLipid.dat",NBin);
00578       Pol->WidomIn();
00579       if(!IfUser) return 0;
00580     }//-------------------End2EndDistr--------------------
00581     else if(!strcmp(Comando,"End2End")){
00582       Pol->End2EndDistr("End2EndDistr");
00583       if(!IfUser) return 0;
00584     }//-----------------ElasticCoupling--------------------
00585     else if(!strcmp(Comando,"ElCoup")){
00586       Pol->ElasticCoupling(NSample);
00587       if(!IfUser) return 0;
00588     }//-----------------ElasticCoupling--------------------
00589     else if(!strcmp(Comando,"ElCoupNVT")){
00590       Pol->ElasticCouplingNVT();
00591       if(!IfUser) return 0;
00592     }//-----------------E2EDecoupling--------------------
00593     else if(!strcmp(Comando,"E2EDec")){
00594       Pol->Decoupling(1);
00595       if(!IfUser) return 0;
00596     }//-----------------SmoothGrid------------------------
00597     else if(!strcmp(Comando,"SmoothGrid")){
00598       Pol->SmoothGrid(NBin,"GridSmoothed.dat");
00599       if(!IfUser) return 0;
00600     }//-----------------IsoSurface------------------------
00601     else if(!strcmp(Comando,"IsoSurf")){
00602       Pol->IsoSurf(NSample,Param,NParam);
00603       if(!IfUser) return 0;
00604     }//-----------------IsoLine------------------------
00605     else if(!strcmp(Comando,"IsoLine")){
00606       NParam = 10;
00607       double OldParam = Param[0];
00608       for(int p=0;p<NParam;p++){
00609    Param[p] = OldParam*p/(double)(NParam);
00610       }
00611       Pol->IsoLine(NSample,Param,NParam,0);
00612       if(!IfUser) return 0;
00613     }//-----------------IsoLineDens------------------------
00614     else if(!strcmp(Comando,"IsoLineDens")){
00615       Pol->IsoLine(NSample,Param,NParam,1);
00616       if(!IfUser) return 0;
00617     }//-----------------Follow-Pore------------------------
00618     else if(!strcmp(Comando,"FPore")){
00619       Pol->FetchPore();
00620       if(!IfUser) return 0;
00621     }//-----------------Follow-Stalk------------------------
00622     else if(!strcmp(Comando,"FStalk")){
00623       Pol->FetchStalk();
00624       if(!IfUser) return 0;
00625     }//-----------------Area-Stalk------------------------
00626     else if(!strcmp(Comando,"AStalk")){
00627       Pol->StalkArea();
00628       if(!IfUser) return 0;
00629     }//-----------------Shift-to-center------------------------
00630     else if(!strcmp(Comando,"Shift2Center")){
00631       Pol->Shift2Center();
00632       if(!IfUser) return 0;
00633     }//-----------------AvSnap------------------------
00634     else if(!strcmp(Comando,"AvSnap")){
00635       Pol->AvSnap();
00636       if(!IfUser) return 0;
00637     }//-----------------DirDecoupling--------------------
00638     else if(!strcmp(Comando,"DirDec")){
00639       Pol->Decoupling(0);
00640       if(!IfUser) return 0;
00641     }//-----------------ElasticCoupling--------------------
00642     else if(!strcmp(Comando,"BilDist")){
00643       Pol->BilayerDistance("BilayerDistance.dat",NSample);
00644       if(!IfUser) return 0;
00645     }//-------------------BondDistr--------------------
00646     else if(!strcmp(Comando,"Bond")){
00647       Pol->BondDistr("BondDistr.dat",NBin);
00648       if(!IfUser) return 0;
00649     }//-------------------Difference,-two-files---------------
00650     else if(!strcmp(Comando,"Diff2Dens")){
00651       Pol->Diff2Files(NSample,1);
00652       if(!IfUser) return 0;
00653     }//-------------------Difference,-two-files---------------
00654     else if(!strcmp(Comando,"Diff2Pre")){
00655       Pol->Diff2Files(NSample,0);
00656       if(!IfUser) return 0;
00657     }//-------------------Difference,-two-files---------------
00658     else if(!strcmp(Comando,"RestPre")){
00659       Pol->RestPress(NBin);
00660       if(!IfUser) return 0;
00661     }//-------------------Conv-to-tecplot-----------------
00662     else if(!strcmp(Comando,"tecplotDens")){
00663       Pol->Conv2Tecplot(NBin,0);
00664       if(!IfUser) return 0;
00665     }//-------------------Conv-to-tecplot-----------------
00666     else if(!strcmp(Comando,"tecplotPre")){
00667       Pol->Conv2Tecplot(NBin,1);
00668       if(!IfUser) return 0;
00669     }//-------------------Conv-to-tecplot-----------------
00670     else if(!strcmp(Comando,"tecplotHei")){
00671       Pol->Conv2Tecplot(NBin,2);
00672       if(!IfUser) return 0;
00673     }//-------------------Conv-to-rzd-----------------
00674     else if(!strcmp(Comando,"rzd")){
00675       Pol->Conv2rzd(NBin);
00676       if(!IfUser) return 0;
00677     }//-------------------Conv-to-rzd-----------------
00678     else if(!strcmp(Comando,"xyzd")){
00679       Pol->Conv2xyzd(NBin);
00680       if(!IfUser) return 0;
00681     }//-------------------Conv-to-vmd--------------
00682     else if(!strcmp(Comando,"vmd")){
00683       Pol->Conv2Vmd();
00684       if(!IfUser) return 0;
00685     }//-------------------povray--------------
00686     else if(!strcmp(Comando,"povray")){
00687       Pol->Conv2Povray();
00688       if(!IfUser) return 0;
00689     }//-----------------------Coord------------------
00690     else if(!strcmp(Comando,"coord")){
00691       printf("Enter coordinate number [0 2] or radius [3]: ");
00692       scanf("%d",&Coord);
00693       if(Coord < 0 || Coord > 3){
00694    printf("Value not valid, coord set to 0\n");
00695    Coord = 0;
00696       }
00697       if(!IfUser) return 0;
00698     }//-----------------------Normal------------------
00699     else if(!strcmp(Comando,"norm")){
00700       printf("Enter the direction of the normal: ");
00701       int Temp = 0;
00702       scanf("%d",&Temp);
00703       if(Temp >= 0 && Temp < 3){
00704    Pol->CNorm = Temp;
00705    Pol->CLat1 = (Pol->CNorm+1)%3;
00706    Pol->CLat2 = (Pol->CNorm+2)%3;
00707    printf("n %d c1 %d c2 %d\n",Pol->CNorm,Pol->CLat1,Pol->CLat2);
00708       }
00709       if(!IfUser) return 0;
00710     }//--------------------Chain-Type------------------
00711     else if(!strcmp(Comando,"type")){
00712       int NChType = CHAIN_EVERY;
00713       printf("up %d down %d flabby %d stretch %d added %d every %d: ",CHAIN_UP,CHAIN_DOWN,CHAIN_FLABBY,CHAIN_STRETCH,CHAIN_ADDED,CHAIN_EVERY);
00714       scanf("%d",&NChType);
00715       if(NChType != CHAIN_UP && NChType != CHAIN_DOWN && NChType != CHAIN_FLABBY && NChType !=  CHAIN_STRETCH && NChType != CHAIN_ADDED && NChType != CHAIN_EVERY){
00716    printf("Value not valid, type set to %d\n",CHAIN_EVERY);
00717    NChType = CHAIN_EVERY;
00718       }
00719       Pol->NChType = NChType;
00720       if(!IfUser) return 0;
00721     }//------------------Change-Files------------------------
00722     else if(!strcmp(Comando,"file")){
00723       Pol->ChangeFile();
00724       if(!IfUser) return 0;
00725     }//------------------Change-NBin---------------------
00726     else if(!strcmp(Comando,"val")){
00727       printf("Number bins (NBin) :");
00728       scanf("%d",&NBin);
00729       if(!IfUser) return 0;
00730     }//------------------Find-neighbours---------------------
00731     else if(!strcmp(Comando,"Nei")){
00732       Pol->FindNeighbours("CrossLinks.dat");
00733       if(!IfUser) return 0;
00734     }//------------------Change-NSample---------------------
00735     else if(!strcmp(Comando,"sample")){
00736       Pol->Sample(NSample);
00737       if(!IfUser) return 0;
00738     }//-------------------Open-Another-File-----------------------------
00739     else if(!strcmp(Comando,"open")){
00740       char InFile[256];
00741       printf("New file name: ");
00742       scanf("%s",Comando);
00743       sprintf(InFile,Comando);
00744       Pol->OpenFile(InFile);
00745       if(!IfUser) return 0;
00746     }//---------------Next-File-in-the-List----------------------
00747     else if(!strcmp(Comando,">")){
00748       quando++;
00749       if(quando >= NFile){
00750    quando = 0;
00751       }
00752       if(quando >=0 && quando < NFile){
00753    Pol->OpenFile(quando);
00754    printf("Opening: %s\n",argv[FilePos[quando]]);
00755       }
00756       if(!IfUser) return 0;
00757     }//---------------Previous--------------------------
00758     else if(!strcmp(Comando,"<")){
00759       quando--;
00760       if(quando < 0){
00761    quando = NFile-1;
00762       }
00763       if(quando >=0 && quando < NFile){
00764    Pol->OpenFile(quando);
00765    printf("Opening: %s\n",argv[FilePos[quando]]);
00766       }
00767        if(!IfUser) return 0;
00768    }//----------------Open-f-File-----------------
00769     else if(!strcmp(Comando,"f")){
00770       printf("Open file num 0-%d: ",NFile);
00771       scanf("%d",&quando);
00772       if( quando >= 0 && quando < NFile){
00773    Pol->OpenFile(quando);
00774       }
00775       if(!IfUser) return 0;
00776     }//-----------------System-Info---------------------------
00777     else if(!strcmp(Comando,"info")){
00778       printf("------------------------------------------------------\n");
00779       char cSystem[STRSIZE];
00780       Pol->SysInfo(cSystem);
00781       printf("%s\n",cSystem);
00782       Pol->SysDef(cSystem);
00783       printf("%s\n",cSystem);
00784     }
00785     else if(!strcmp(Comando,"q") ){
00786       if(!IfUser) return 0;
00787     }
00788     else {
00789       printf("Comando non valido, scrivere ?\
00790  per la lista dei comandi\n");
00791       IfUser = 1;
00792     }
00793   }
00794   printf("Te se qe te ve be te ne?\n");
00795   if(Pol) delete Pol;
00796   return 0;
00797 }
00798 #ifdef __glut_h__
00799 void Slide(){
00800   Pol->ESlide();
00801 }
00802 void ParticleList(){
00803   Pol->RenderPart();
00804 }
00805 void ParticleRealTime(){
00806   return;
00807   Pol->DrRunTime();
00808 }
00809 void keyboard(unsigned char key,int x, int y){
00810   Pol->keyboard(key,x,y);
00811 }
00812 void mouse(int button, int state,int x,int y){
00813   Pol->ElDrawMouse(button,state,x,y);
00814 }
00815 void Menu(){
00816   Pol->Menu();
00817 }
00818 #endif // __glut_h__
00819 void Legenda(){
00820   printf("\n\
00821 *****************************************************************\n\
00822 (                                                               )\n\
00823 )    Program that reads and elaborate a spefic file format      (\n\
00824 (    the option are the following, Needs a input file           )\n\
00825 )                                                               (\n\
00826 (-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-)\n\
00827 (   d     draw the 3D position of the particle                  )\n\
00828 (   ! execute a shell command                                   )\n\
00829 (   q    quit                                                   )\n\
00830 (   dens density of the [coord] coordinate for the [file]       )\n\
00831 (   pro calculate the projection long [coord]                   )\n\
00832 (   core spatial average sample on NBin bin                     )\n\
00833 (   surf ratio between the actual surcafe and the circular      )\n\
00834 (   core three dimentional sampled average of the system        )\n\
00835 (   diff diffusivity of the extra particle                      )\n\
00836 (   > <  open the file form the list position                   )\n\
00837 (   cm   movement  of the center of mass of the system          )\n\
00838 (   file number of file to use from the list                    )\n\
00839 (   info ...                                                    )\n\
00840 (   val  number of values for the density profile               )\n\
00841 (   radShell average the outer shell of a drop                  )\n\
00842 (   radCm normal and radial density wrt the center of mass      )\n\
00843 (   radCmN normal wrt to the center of mass, radial to the nano )\n\
00844 (   radNano normal and radial density wrt the Nano              )\n\
00845 (   temp Temperature profile along a direction                  )\n\
00846 (   nano density and diffisivity of the nano in the membrane    )\n\
00847 (   surf sampling and averaging a surface                       )\n\
00848 (   pairMon pair correlation function of the monomers           )\n\
00849 (   pairChain pair correlation function of the chains           )\n\
00850 (   pairRound radial pair correlation function                  )\n\
00851 (   scatt scattering og the membrane                            )\n\
00852 (   scatt2 alternative formulation                              )\n\
00853 (   worm projecting the density of the system on the local norma)\n\
00854 (   header averaging the values written on the header           )\n\
00855 (   spe calculating the spectrum                                )\n\
00856 (   mid sampling the membrane in midplanes                      )\n\
00857 (   prop calculating some characteristic properties of the chain)\n\
00858 (   Area calculating the area compressibility                   )\n\
00859 (                                                               )\n\
00860 (                                                               )\n\
00861 (                                                               )\n\
00862 *****************************************************************\n");
00863 }
00864    //  else if(!strcmp(Comando,"coreNano")){
00865    //  else if(!strcmp(Comando,"radShell")){
00866    //  else if(!strcmp(Comando,"angle")){
00867    //  else if(!strcmp(Comando,"radNano")){
00868    // else if(!strcmp(Comando,"radCm")){
00869    //  else if(!strcmp(Comando,"radCmN")){
00870    //  else if(!strcmp(Comando,"cm")){
00871    //  else if(!strcmp(Comando,"temp")){
00872    //  else if(!strcmp(Comando,"nano")){
00873    //  else if(!strcmp(Comando,"surf")){
00874    //  else if(!strcmp(Comando,"diff")){
00875    //  else if(!strcmp(Comando,"pairMon")){
00876    //  else if(!strcmp(Comando,"pairChain")){
00877    //  else if(!strcmp(Comando,"pairRound")){
00878    //  else if(!strcmp(Comando,"pairSquare")){
00879    //  else if(!strcmp(Comando,"scatt")){
00880    //  else if(!strcmp(Comando,"scatt2")){
00881    //  else if(!strcmp(Comando,"worm")){
00882    //  else if(!strcmp(Comando,"header")){
00883    //  else if(!strcmp(Comando,"spe")){
00884    //  else if(!strcmp(Comando,"mid")){
00885    //  else if(!strcmp(Comando,"prop")){
00886    //   else if(!strcmp(Comando,"Area")){
00887    //  else if(!strcmp(Comando,"coord")){
00888    //  else if(!strcmp(Comando,"norm")){
00889    //  else if(!strcmp(Comando,"type")){
00890    //  else if(!strcmp(Comando,"file")){
00891    //  else if(!strcmp(Comando,"val")){
00892    //  else if(!strcmp(Comando,"sample")){
00893    //  else if(!strcmp(Comando,"open")){
00894    //  else if(!strcmp(Comando,">")){
00895    //  else if(!strcmp(Comando,"<")){
00896    // else if(!strcmp(Comando,"f")){