00001 local INLINE void attach_new_node(worldbundle *wb, worldline *ww,
00002 pdyn *root, tdyn *top, tdyn *bb,
00003 bool debug)
00004 {
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 if (debug)
00015 cerr << "base node " << bb << " "
00016 << bb->get_time() << " "
00017 << bb->format_label() << endl;
00018
00019 pdyn *curr = new pdyn(NULL, NULL, false);
00020
00021
00022
00023
00024
00025
00026 if (bb == top) {
00027
00028
00029
00030
00031 pdyn *n = root->get_oldest_daughter();
00032
00033 if (!n)
00034 add_node(*curr, *root);
00035
00036 else {
00037 while (n->get_younger_sister())
00038 n = n->get_younger_sister();
00039 n->set_younger_sister(curr);
00040 curr->set_elder_sister(n);
00041 curr->set_parent(root);
00042 }
00043
00044 } else {
00045
00046
00047
00048
00049
00050
00051 pdyn *par = wb->find_worldline(bb->get_parent())
00052 ->get_tree_node();
00053 curr->set_parent(par);
00054
00055 tdyn * bb_sis = bb->get_elder_sister();
00056
00057 if (!bb_sis)
00058 par->set_oldest_daughter(curr);
00059 else {
00060 pdyn *sis = wb->find_worldline(bb_sis)
00061 ->get_tree_node();
00062 curr->set_elder_sister(sis);
00063 sis->set_younger_sister(curr);
00064 }
00065 }
00066
00067 if (NEW == 1) {
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 if (bb->get_name()) {
00089 curr->set_name(bb->get_name());
00090 curr->set_index(atoi(bb->get_name()));
00091 }
00092 if (bb->get_index() >= 0)
00093 curr->set_index(bb->get_index());
00094
00095
00096
00097 int i = wb->find_index(bb);
00098 if (i < 0) {
00099 PRL(wb->find_index(bb));
00100 PRC(bb); PRL(bb->format_label());
00101 }
00102 curr->set_worldline_index(wb->find_index(bb));
00103
00104 curr->set_mass(bb->get_mass());
00105 }
00106
00107 ww->set_tree_node(curr);
00108
00109
00110
00111 ww->set_t_curr(-VERY_LARGE_NUMBER);
00112 ww->set_current_event(NULL);
00113 }