void update_Screen(void) { int tem_co, row, col; tem_co = FMIN(co, TEMPLATE_COLS); for (row = 0; !BU_STR_EMPTY(screen_template[row]); row++) { int lastcol = -2; if (BU_STR_EMPTY(screen_template[row + 1])) { SetStandout(); } for (col = 0; col < tem_co; col++) if (screen[row][col] != screen_template[row][col]) { if (col != lastcol+1) MvCursor(col+1, row+1); lastcol = col; (void) putchar(screen_template[row][col]); screen[row][col] = screen_template[row][col]; } } (void) ClrStandout(); EVENT_MOVE(); (void) fflush(stdout); return; }
/** * Add the list of regions in the model to the rigid bodies list in * simulation parameters. This function will duplicate the existing * regions prefixing "sim_" to the new region and putting them all * under a new comb "sim.c". It will skip over any existing regions * with "sim_" in the name */ int add_regions(struct ged *gedp, struct simulation_params *sim_params) { struct directory *dp, *ndp; char *prefix = "sim_"; int i; struct rigid_body *prev_node = NULL, *current_node; struct bu_vls dp_name_vls = BU_VLS_INIT_ZERO; /* Kill the existing sim comb */ sim_kill(gedp, sim_params->sim_comb_name); sim_params->num_bodies = 0; /* Walk the directory list duplicating all regions only, skip some regions */ for (i = 0; i < RT_DBNHASH; i++) for (dp = gedp->ged_wdbp->dbip->dbi_Head[i]; dp != RT_DIR_NULL; dp = dp->d_forw) { if ((dp->d_flags & RT_DIR_HIDDEN) || /* check for hidden comb/prim */ !(dp->d_flags & RT_DIR_REGION) /* check if region */ ) { continue; } if (strstr(dp->d_namep, prefix)) { bu_vls_printf(gedp->ged_result_str, "add_regions: Skipping \"%s\" due to \"%s\" in name\n", dp->d_namep, prefix); continue; } if (BU_STR_EMPTY(dp->d_namep)) { bu_vls_printf(gedp->ged_result_str, "add_regions: Skipping \"%s\" due to empty name\n", dp->d_namep); continue; } /* Duplicate the region */ bu_vls_sprintf(&dp_name_vls, "%s%s", prefix, dp->d_namep); sim_kill_copy(gedp, dp, bu_vls_addr(&dp_name_vls)); bu_vls_printf(gedp->ged_result_str, "add_regions: Copied \"%s\" to \"%s\"\n", dp->d_namep, bu_vls_addr(&dp_name_vls)); /* Get the directory pointer for the object just added */ if ((ndp=db_lookup(gedp->ged_wdbp->dbip, bu_vls_addr(&dp_name_vls), LOOKUP_QUIET)) == RT_DIR_NULL) { bu_vls_printf(gedp->ged_result_str, "add_regions: db_lookup(%s) failed", bu_vls_addr(&dp_name_vls)); return GED_ERROR; } /* Add to simulation list */ BU_ALLOC(current_node, struct rigid_body); current_node->index = sim_params->num_bodies; current_node->rb_namep = bu_strdup(bu_vls_addr(&dp_name_vls)); current_node->dp = ndp; current_node->next = NULL; /* Save the internal format as well */ if (!rt_db_lookup_internal(sim_params->gedp->ged_wdbp->dbip, ndp->d_namep, &ndp, &(current_node->intern), LOOKUP_NOISY, &rt_uniresource)) { bu_exit(1, "add_regions: ERROR rt_db_lookup_internal(%s) failed to get the internal form", ndp->d_namep); return GED_ERROR; } /* Add physics attribs : one shot get from user */ add_physics_attribs(current_node); /* Setup the linked list */ if (prev_node == NULL) { /* first node */ prev_node = current_node; sim_params->head_node = current_node; } else { /* past 1st node now */ prev_node->next = current_node; prev_node = prev_node->next; } /* Add the new region to the simulation result */ add_to_comb(gedp, sim_params->sim_comb_name, bu_vls_addr(&dp_name_vls)); sim_params->num_bodies++; } bu_vls_free(&dp_name_vls); if(sim_params->num_bodies == 0){ bu_vls_printf(gedp->ged_result_str, "add_regions: ERROR No objects were added\n"); return GED_ERROR; } /* Show list of objects to be added to the sim : keep for debugging as of now */ /* bu_log("add_regions: The following %d regions will participate in the sim : \n", sim_params->num_bodies); for (current_node = sim_params->head_node; current_node != NULL; current_node = current_node->next) { print_rigid_body(current_node); }*/ return GED_OK; }