int real_time_listen( serial_port_t const port, struct activity *activity, struct model const *const model ) { double elapsed; struct packet packet; struct timespec tic; char message[MSG_LEN]; struct calibr calibr[CONF_BAN_NUM_NODES]; if (calibration_table_read(FILE_CONF_CALIBRATION, calibr)) return EXIT_FAILURE; file_write_header(activity->files[FILE_RAW]); file_write_header(activity->files[FILE_HISTORY]); clock_gettime(CLOCK_MONOTONIC, &tic); while (time_stopwatch(tic, CONF_TIME_LISTENING, &elapsed)) { if (serial_port_read(port, message, sizeof(message))) return EXIT_FAILURE; file_write_raw(activity->files[FILE_RAW], message); if (packet_validate(message, &packet)) continue; packet.elapsed = elapsed; if (calibrate_packet(&packet, calibr, sizeof(calibr))) return EXIT_FAILURE; file_write_history(activity->files[FILE_HISTORY], packet); process_region(&packet, model); activity->window[packet.node_id - 1][packet.region - 1]++; } return EXIT_SUCCESS; }
void lung_analysis(img** volume, img** orig, ushort thresh) { int i, j, z, k3, k2, k1; uint visited, visiting; vector<ushort> rar, car, zar; while (locate_3d_seed(volume, rar, car, zar)) { visited = 1; visiting = 0; while (visited != visiting) { i = rar[visiting]; j = car[visiting]; z = zar[visiting]; for (k3 = z-1; k3 <= z+1; ++k3) { if (k3 < 0 || k3 >= num_imgs) continue; for (k1 = i-1; k1 <= i+1; ++k1) { if (k1 < EDGE_DELTA-1 || k1 > 511-EDGE_DELTA) continue; for (k2 = j-1; k2 <= j+1; ++k2) { if (k2 < EDGE_DELTA-1 || k2 > 511-EDGE_DELTA) continue; if (volume[k3]->pix[k1][k2] == 0) { rar.push_back(k1); car.push_back(k2); zar.push_back(k3); volume[k3]->pix[k1][k2] = BENIGN; // visited and benign visited++; } } } } visiting++; } process_region(volume, orig, thresh, rar, car, zar); } }
void IR_GVN::process_bb(IR_BB * bb, bool & change) { C<IR*> * ct; for (IR * ir = IR_BB_ir_list(bb).get_head(&ct); ir != NULL; ir = IR_BB_ir_list(bb).get_next(&ct)) { switch (IR_type(ir)) { case IR_ST: case IR_STPR: case IR_IST: process_st(ir, change); break; case IR_CALL: case IR_ICALL: process_call(ir, change); break; case IR_TRUEBR: case IR_FALSEBR: comp_vn(BR_det(ir), change); break; case IR_SWITCH: comp_vn(SWITCH_vexp(ir), change); break; case IR_IGOTO: comp_vn(IGOTO_vexp(ir), change); break; case IR_RETURN: comp_vn(RET_exp(ir), change); break; case IR_REGION: process_region(ir, change); break; case IR_PHI: process_phi(ir, change); break; case IR_GOTO: break; default: IS_TRUE0(0); } } }
/* * Called from db_walk_tree(). * * This routine must be prepared to run in parallel. */ union tree * do_region_end(struct db_tree_state *tsp, const struct db_full_path *pathp, union tree *curtree, void *UNUSED(client_data)) { union tree *ret_tree = NULL; struct bu_list vhead; /* static due to longjmp */ static struct nmgregion *r = NULL; RT_CK_FULL_PATH(pathp); RT_CK_TREE(curtree); RT_CK_TESS_TOL(tsp->ts_ttol); BN_CK_TOL(tsp->ts_tol); NMG_CK_MODEL(*tsp->ts_m); BU_LIST_INIT(&vhead); if (RT_G_DEBUG&DEBUG_TREEWALK || verbose) { char *sofar = db_path_to_string(pathp); bu_log("\ndo_region_end(%d %d%%) %s\n", regions_tried, regions_tried>0 ? (regions_converted * 100) / regions_tried : 0, sofar); bu_free(sofar, "path string"); } if (curtree->tr_op == OP_NOP) return curtree; regions_tried++; /* do the deed */ ret_tree = process_region(pathp, curtree, tsp); if (ret_tree) r = ret_tree->tr_d.td_r; else { if (verbose) { printf("\tNothing left of this region after Boolean evaluation\n"); fprintf(fpe, "WARNING: Nothing left after Boolean evaluation: %s\n", db_path_to_string(pathp)); fflush(fpe); } regions_written++; /* don't count as a failure */ r = (struct nmgregion *)NULL; } regions_converted++; if (r != (struct nmgregion *)NULL) { struct shell *s; int empty_region=0; int empty_model=0; /* Kill cracks */ s = BU_LIST_FIRST(shell, &r->s_hd); while (BU_LIST_NOT_HEAD(&s->l, &r->s_hd)) { struct shell *next_s; next_s = BU_LIST_PNEXT(shell, &s->l); if (nmg_kill_cracks(s)) { if (nmg_ks(s)) { empty_region = 1; break; } } s = next_s; } /* kill zero length edgeuses */ if (!empty_region) { empty_model = nmg_kill_zero_length_edgeuses(*tsp->ts_m); } if (!empty_region && !empty_model) { if (!BU_SETJUMP) { /* try */ /* Write the region to the TANKILL file */ nmg_to_acad(r, pathp, tsp->ts_regionid); regions_written++; } else { /* catch */ char *sofar; BU_UNSETJUMP; sofar = db_path_to_string(pathp); bu_free((char *)sofar, "sofar"); /* Sometimes the NMG library adds debugging bits when * it detects an internal error, before bombing out. */ RTG.NMG_debug = NMG_debug; /* restore mode */ /* Release any intersector 2d tables */ nmg_isect2d_final_cleanup(); /* Get rid of (m)any other intermediate structures */ if ((*tsp->ts_m)->magic == NMG_MODEL_MAGIC) { nmg_km(*tsp->ts_m); } else { bu_log("WARNING: tsp->ts_m pointer corrupted, ignoring it.\n"); } /* Now, make a new, clean model structure for next pass. */ *tsp->ts_m = nmg_mm(); /* FIXME: leaking memory with curtree */ return TREE_NULL; } BU_UNSETJUMP; } if (!empty_model) nmg_kr(r); } /* * Dispose of original tree, so that all associated dynamic * memory is released now, not at the end of all regions. * A return of TREE_NULL from this routine signals an error, * and there is no point to adding _another_ message to our output, * so we need to cons up an OP_NOP node to return. */ if (regions_tried>0) { float npercent, tpercent; npercent = (float)(regions_converted * 100) / regions_tried; tpercent = (float)(regions_written * 100) / regions_tried; printf("Tried %d regions, %d conv. to NMG's %d conv. to tri. nmgper = %.2f%% triper = %.2f%% \n", regions_tried, regions_converted, regions_written, npercent, tpercent); } BU_ALLOC(curtree, union tree); RT_TREE_INIT(curtree); curtree->tr_op = OP_NOP; return curtree; }