00001
00011
00012
00013
00014 #include "_dyn_.h"
00015
00016 #ifdef TOOLBOX
00017
00018
00019
00020 local _dyn_* leaf_with_label(_dyn_* b, char* label)
00021 {
00022 for_all_leaves(_dyn_, b, bi) {
00023 if (bi->get_name() != NULL) {
00024 if (strcmp(bi->get_name(), label) == 0)
00025 return bi;
00026 } else if (bi->get_index() >= 0) {
00027 char id[64];
00028 sprintf(id, "%d", bi->get_index());
00029 if (strcmp(id, label) == 0)
00030 return bi;
00031 }
00032 }
00033 return NULL;
00034 }
00035
00036 local void set_radius_by_label(_dyn_* b, char* label, real radius)
00037 {
00038
00039
00040 _dyn_* bi = leaf_with_label(b, label);
00041
00042 if (bi == NULL)
00043 cerr << "Warning: particle \"" << label << "\" not found.\n";
00044 else
00045 bi->set_radius(radius);
00046
00047 }
00048
00049 local void set_radius(_dyn_* b, real radius)
00050 {
00051
00052
00053 for_all_leaves(_dyn_, b, bi) {
00054 if (bi == NULL)
00055 cerr << "Warning: no particle found.\n";
00056 else
00057 bi->set_radius(radius);
00058 }
00059
00060 }
00061
00062 void main(int argc, char ** argv)
00063 {
00064 char label[64];
00065 label[0] = '\0';
00066
00067 check_help();
00068
00069 _dyn_* b;
00070 b = get__dyn_(cin);
00071
00072 b->log_history(argc, argv);
00073
00074
00075
00076 int i = 0;
00077 while (++i < argc)
00078 if (argv[i][0] == '-')
00079 switch (argv[i][1]) {
00080
00081 case 'A': set_radius(b, (real)atof(argv[++i]));
00082 break;
00083
00084 case 'l': strcpy(label, argv[++i]);
00085 break;
00086
00087 case 'm': set_radius_by_label(b, label, (real)atof(argv[++i]));
00088 break;
00089
00090 default: get_help();
00091 }
00092
00093 put__dyn_(cout, *b);
00094 }
00095
00096 #endif