static GLuint compile_display_list (RendererCar * self, char * prefix, rwx_model_t * model) { GLuint dl = glGenLists (1); glNewList (dl, GL_COMPILE); char key[64]; sprintf (key, "renderer_car.%s_scale", prefix); double scale; if (config_get_double (self->config, key, &scale) == 0) glScalef (scale, scale, scale); sprintf (key, "renderer_car.%s_xyz_rotate", prefix); double rot[3]; if (config_get_double_array (self->config, key, rot, 3) == 3) { glRotatef (rot[2], 0, 0, 1); glRotatef (rot[1], 0, 1, 0); glRotatef (rot[0], 1, 0, 0); } sprintf (key, "renderer_car.%s_translate", prefix); double trans[3]; if (config_get_double_array (self->config, key, trans, 3) == 3) glTranslated (trans[0], trans[1], trans[2]); glEnable (GL_LIGHTING); rwx_model_gl_draw (model); glDisable (GL_LIGHTING); glEndList (); return dl; }
int main(int argc, char **argv) { BkgdEvoMdlData *data; Config *config; if(argc != 2) { fprintf(stderr, "usage: %s <config_file>", argv[0]); exit(2); } fprintf(stderr, "Reading config\n"); config = config_read_file(argv[1], CONFIG_MISSING_KEY_ERROR); data = bkgd_data_read_data(config); if(config_get_boolean(config, "COMBINE_CAT_BINS")) { double min_cat, max_cat; min_cat = config_get_double(config, "MIN_CAT"); max_cat = config_get_double(config, "MAX_CAT"); bkgd_data_combine_cat_bin(data, min_cat, max_cat); } if(config_get_boolean(config, "COMBINE_DATA_BINS")) { long n_bin = config_get_long(config, "N_DATA_BIN"); bkgd_data_combine_bin(data, n_bin); } if(config_get_boolean(config, "WRITE_COUNTS")) { bkgd_data_write_site_counts(stdout, data); } if(config_get_boolean(config, "WRITE_BINS")) { write_data(stdout, data); } g_free(data->bin); g_free(data); return 0; }
static bool load_body(ALLEGRO_CONFIG *cfg, const char *fullname, Body *body, char **primary_name) { const char *name; char *type; /* Just checking */ if (al_get_first_config_entry(cfg, fullname, NULL) == NULL) { log_err("Section %s not in file\n", fullname); return false; } /* Fill in some common parameters */ if (!config_get_double(cfg, fullname, "Mass", &body->mass, false)) return false; if (!config_get_double(cfg, fullname, "Gravitational parameter", &body->grav_param, true)) { body->grav_param = GRAV_CONST * body->mass; } if (!config_get_double(cfg, fullname, "Radius", &body->radius, false)) return false; /* Figure out what kind of object it is */ config_get_string(cfg, fullname, "Type", &type, true); if (type == NULL) body->type = BODY_UNKNOWN; else if (strcmp(type, "Star") == 0) body->type = BODY_STAR; else if (strcmp(type, "Planet") == 0) body->type = BODY_PLANET; else if (strcmp(type, "Moon") == 0) body->type = BODY_PLANET; else if (strcmp(type, "Comet") == 0) body->type = BODY_COMET; else { log_err("Unknown type: %s\n", type); ralloc_free(type); return false; } ralloc_free(type); /* Does it have a primary or not? * Full names are of the form of "Primary/Name" * We search backwards to allow for things like "Sol/Earth/Moon" */ if ((name = strrchr(fullname, '/')) == NULL) { /* This is a body without a primary */ body->name = ralloc_strdup(body->ctx, fullname); body->type = (body->type == BODY_UNKNOWN ? BODY_STAR : body->type); body->primary = NULL; *primary_name = NULL; } else if (name == fullname) /* No primary name, eg: sec = "/Earth" */ { log_err("Malformed name: %s", fullname); return false; } else { const char *c; for (c = name - 1; c >= fullname && *c != '/'; c--); c++; body->name = ralloc_strdup(body->ctx, name + 1); body->type = (body->type == BODY_UNKNOWN ? BODY_PLANET : body->type); body->primary = NULL; /* Fill in later */ *primary_name = ralloc_strndup(body->ctx, c, name - c); } body->num_satellites = 0; body->satellite = NULL; /* Bodies without primaries can't orbit another body */ if (*primary_name == NULL) return true; if (!config_get_double(cfg, fullname, "Ecc", &body->orbit.Ecc, false) || !config_get_double(cfg, fullname, "SMa", &body->orbit.SMa, false) || !config_get_double(cfg, fullname, "Inc", &body->orbit.Inc, false) || !config_get_double(cfg, fullname, "LAN", &body->orbit.LAN, false) || !config_get_double(cfg, fullname, "APe", &body->orbit.APe, false) || !config_get_double(cfg, fullname, "MnA", &body->orbit.MnA, false)) { log_err("Couldn't load orbital elements of %s\n", fullname); return false; } return true; }
/* * Main program logic */ int main(int argc, char **argv) { Config *config; Analysis *analysis; char *bkgd1_dir, *bkgd2_dir; SeqCoord *region; long len; int i, b1_int, b2_int, b_new, last_b, b_len; double uscale1, uscale2; BkgdReader *br1, *br2; FILE *out_fh; if(argc != 2) { fprintf(stderr, "usage: %s <config_file>\n", argv[0]); exit(2); } fprintf(stderr, "Reading config\n"); config = config_read_file(argv[1], CONFIG_MISSING_KEY_ERROR); analysis = analysis_new(config); bkgd1_dir = config_get_str(config, "BKGD1_DIR"); bkgd2_dir = config_get_str(config, "BKGD2_DIR"); /* get deleterious mutation rate rescale */ uscale1 = config_get_double(config, "BKGD1_USCALE"); uscale2 = config_get_double(config, "BKGD2_USCALE"); fprintf(stderr, "using uscale1=%g, uscale2=%g\n", uscale1, uscale2); while(analysis_next_region(analysis)) { region = analysis_get_region(analysis); fprintf(stderr, "chromosome %s\n", region->chr->name); len = region->end - region->start + 1; out_fh = get_output_fh(analysis); br1 = get_bkgd_reader(analysis, bkgd1_dir); br2 = get_bkgd_reader(analysis, bkgd2_dir); last_b = B_UNDEF; b_len = 0; for(i = 0; i < len; i++) { b1_int = bkgd_reader_get_pos(br1, i+1); b2_int = bkgd_reader_get_pos(br2, i+1); b_new = combine_bkgd(b1_int, uscale1, b2_int, uscale2); if(b_new == last_b) { b_len++; } else { if(b_len > 0) { fprintf(out_fh, "%d %d\n", last_b, b_len); } b_len = 1; last_b = b_new; } } /* write final region */ if(b_len > 0) { fprintf(out_fh, "%d %d\n", last_b, b_len); } bkgd_reader_free(br1); bkgd_reader_free(br2); } fprintf(stderr, "Freeing analysis\n"); analysis_free(analysis); fprintf(stderr, "Freeing config\n"); config_free(config); return 0; }