00001
00010
00011
00012
00013 #include "node.h"
00014
00015
00016
00017 #ifdef TOOLBOX
00018
00019
00020
00021
00022
00023 main(int argc, char ** argv)
00024 {
00025 int i;
00026 int j;
00027 bool c_flag = FALSE;
00028 bool e_flag = FALSE;
00029 bool i_flag = FALSE;
00030 bool j_flag = FALSE;
00031 real m = 1;
00032 char *comment;
00033
00034 check_help();
00035
00036 extern char *poptarg;
00037 int c;
00038 char* param_string = "c:ei:j:m:";
00039
00040 while ((c = pgetopt(argc, argv, param_string)) != -1)
00041 switch(c)
00042 {
00043 case 'c': c_flag = TRUE;
00044 comment = poptarg;
00045 break;
00046 case 'e': e_flag = TRUE;
00047 break;
00048 case 'i': i_flag = TRUE;
00049 i = atoi(poptarg);
00050 break;
00051 case 'j': j_flag = TRUE;
00052 j = atoi(poptarg);
00053 break;
00054 case 'm': m = atof(poptarg);
00055 break;
00056 case '?': params_to_usage(cerr, argv[0], param_string);
00057 get_help();
00058 exit(1);
00059 }
00060
00061 node * root;
00062 node * p;
00063 node * d;
00064 node * y;
00065 node * n;
00066
00067 root = get_node(cin);
00068
00069 if (root == NULL)
00070 err_exit("add_daughter_node: no input nodes provided");
00071
00072 if (c_flag == TRUE)
00073 root->log_comment(comment);
00074 root->log_history(argc, argv);
00075
00076 if (i_flag == FALSE)
00077 p = root;
00078 else
00079 p = node_with_index(i, root);
00080
00081 if (p == NULL)
00082 err_exit("add_daughter_node: no such parent");
00083
00084 n = new node();
00085 n->set_mass(m);
00086 if (j_flag)
00087 n->set_label(j);
00088
00089 d = p->get_oldest_daughter();
00090 if (d == NULL)
00091 p->set_oldest_daughter(n);
00092 else
00093 {
00094 y = d->get_younger_sister();
00095 while (y)
00096 {
00097 d = y;
00098 y = d->get_younger_sister();
00099 }
00100 d->set_younger_sister(n);
00101 }
00102
00103 if (e_flag)
00104 root->pretty_print_tree(cerr);
00105
00106 put_node(cout, *root);
00107 rmtree(root);
00108 }
00109
00110 #endif
00111
00112
00113
00114
00115