Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

readp.C

Go to the documentation of this file.
00001 
00011 
00012 //           Steve McMillan, July 1999
00013 
00014 #include "dyn.h"
00015 
00016 #ifdef TOOLBOX
00017 
00018 void main(int argc, char ** argv)
00019 {
00020     check_help();
00021 
00022     extern char *poptarg;
00023     int c;
00024     char* param_string = "c:i";
00025 
00026     char *comment;
00027     bool c_flag = false;
00028     bool i_flag = false;
00029 
00030     while ((c = pgetopt(argc, argv, param_string)) != -1)
00031         switch(c) {
00032 
00033             case 'c': c_flag = true;
00034                       comment = poptarg;
00035                       break;
00036             case 'i': i_flag = true;
00037                       break;
00038             case '?': params_to_usage(cerr, argv[0], param_string);
00039                       exit(1);
00040         }
00041 
00042     // Create the root node.
00043 
00044     dyn * root = new dyn();
00045     root->set_system_time(0);
00046     if (i_flag) root->set_index(0);
00047 
00048     // Create the system node by node.
00049 
00050     dyn *b, *bo;
00051     real total_mass = 0;
00052     int n = 0;
00053 
00054     while (!cin.eof()) {
00055 
00056         real mass; cin >> mass; if (cin.eof()) break;   // note: only minimal
00057         vector pos; cin >> pos; if (cin.eof()) break;   // checking for
00058         vector vel; cin >> vel;                         // corrupted data
00059 
00060         dyn * b = new dyn();
00061 
00062         b->set_mass(mass);
00063         b->set_pos(pos);
00064         b->set_vel(vel);
00065 
00066         b->set_parent(root);
00067 
00068         if (n++ == 0)
00069             root->set_oldest_daughter(b);
00070         else {
00071             b->set_elder_sister(bo);
00072             bo->set_younger_sister(b);
00073         }
00074 
00075         if (i_flag) b->set_index(n);
00076         bo = b;
00077     }
00078             
00079     root->set_mass(total_mass);
00080 
00081     root->log_history(argc, argv);
00082     if (c_flag) root->log_comment(comment);
00083 
00084     put_node(cout, *root);
00085 }
00086 
00087 #endif

Generated at Sun Feb 24 09:57:13 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001