00001 
00002        
00003       
00004      
00005     
00006    
00007   
00008  
00009 
00010 
00028 
00029 
00030 
00031 #include "worldline.h"
00032 
00033 #ifdef TOOLBOX
00034 
00035 local void create_and_print_interpolated_tree(ostream & s, 
00036                                               worldbundle *wb,
00037                                               real t_world, 
00038                                               bool vel = true,
00039                                               bool brief = false) {
00040 
00041   dyn* b = create_interpolated_tree(wb, t_world, vel);
00042   if (b) {
00043     put_dyn(s, *b, brief);
00044     rmtree(b);
00045   }
00046 }
00047 
00048 local void convert_relative_to_absolute(dyn* b)
00049 {
00050     if (b->get_parent()) b->inc_pos(b->get_parent()->get_pos());
00051     for_all_daughters(dyn, b, bb) convert_relative_to_absolute(bb);
00052 }
00053 
00054 main(int argc, char *argv[]) {
00055 
00056   bool c_flag = false;
00057 
00058   real dt = 0.015625;   
00059   int b_start = 0;      
00060   int b_end   = 32767;  
00061   bool t_flag = false;
00062   real t_world;         
00063 
00064 
00065   extern char *poptarg;
00066   char *comment;
00067   int c;
00068   char* param_string = "B:b:d:f:t:c:";
00069   
00070   check_help();
00071   
00072   while ((c = pgetopt(argc, argv, param_string)) != -1)
00073     switch(c) {
00074       
00075         case 'B': b_start = atoi(poptarg);
00076                 break;
00077         case 'b': b_end = atoi(poptarg);
00078                 break;
00079         case 'd': dt = atof(poptarg);
00080                 break;
00081         case 't': t_flag = true;
00082                   t_world = atof(poptarg);
00083                 break;
00084         case 'c': c_flag = TRUE;
00085                 comment = poptarg;
00086                 break;
00087         case '?': params_to_usage(cerr, argv[0], param_string);
00088                 get_help();
00089                 exit(1);
00090               }
00091 
00092   if(t_flag) {
00093     b_start = 0;     
00094     b_end   = 32767; 
00095   }
00096   else if(b_end<=b_start)
00097     err_exit("begin worldbunlde <= end worldbundle");
00098 
00099   
00100   real time, t_min, t_max;
00101   dyn *b;
00102   worldbundle *wb;
00103   int itot=0, iw=0;
00104   if(b_start>0) {
00105     for(int i=0; i<b_start; i++)  {
00106       
00107       cerr << "Skip worldbundle " << i << endl;
00108       if(!(wb = read_bundle(cin)))
00109         err_exit("Not that many worldbundles");
00110     }
00111   }
00112 
00113   int ib = b_start;
00114   while (ib<b_end  && (wb = read_bundle(cin))) {
00115 
00116     time = wb->get_t_min();
00117     t_max = wb->get_t_max();
00118 
00119     ib++;
00120     cerr << "Time= " << time << " N_bundle= " << ib << endl; 
00121 
00122     if(t_flag) {
00123 
00124       if(t_world>=time && t_world<=t_max) {
00125         cerr << "Time= " << t_world
00126           << " N (b, w, tot)= " << ib << " " << iw <<" " << itot << endl; 
00127 
00128         create_and_print_interpolated_tree(cout, wb, t_world);
00129 
00130         delete wb;
00131         exit(1);
00132       }
00133     }
00134     else {
00135 
00136       iw = 0;
00137       do {
00138         
00139         itot++;
00140         iw++;
00141         create_and_print_interpolated_tree(cout, wb, time);
00142         cerr << "Time= " << time
00143           << " N (b, w, tot)= " << ib << " " << iw <<" " << itot << endl; 
00144 #if 0
00145         create_and_print_interpolated_tree(cout, wb, t_world);
00146         b = create_interpolated_tree(wb, time, true);
00147         
00148         if (b) {
00149           
00150           cerr << "Time= " << time 
00151             << " N (b, w, tot)= " << ib << " " << iw <<" " << itot << endl; 
00152           put_dyn(cout, *b, false);
00153           rmtree(b);
00154         }
00155 #endif  
00156         time += dt;
00157       }
00158       while(time<=t_max);
00159     }
00160 
00161     delete wb;
00162   };
00163 }
00164 
00165 #endif