int verifier_fin_photon() { if((nb_element_ph) < nb_expected_ph) { error_lecture_elements(ERR_PHOTON, ERR_PAS_ASSEZ); return 1; } else if((nb_element_ph) > nb_expected_ph) { error_lecture_elements(ERR_PHOTON, ERR_TROP); return 1; } return 0; }
int photon_load(char * tab) { char *deb = tab; PHOTON ph; if(tete == NULL && started == 0) { if(sscanf(deb, "%d", &nb_expected_ph) != 1) { error_lect_nb_elements(ERR_PHOTON); return 1; } if(nb_expected_ph < 0) { error_lect_nb_elements(ERR_PHOTON); return 1; } started = 1; } else { if(sscanf(deb,"%lf %lf %lf", &ph.position.x, &ph.position.y, &ph.alpha) != 3) { error_lecture_elements(ERR_PHOTON, ERR_PAS_ASSEZ); return 1; } photon_add_ph(ph); } return 0; }
int absorbeurSet(char line[MAX_LINE]) { int _nbPt, j = 0, i = 0; char* start = line; char * end = NULL; POINT _points[MAX_PT]; //lecture _nbPt = (int)strtod(line, &end); if(_nbPt < MIN_PT || _nbPt > MAX_PT) { error_lect_nb_points_absorbeur(); return NO; } start = end; for(j = 0; j < _nbPt; j++) { _points[j].x = strtod(start, &end); if(start == end) { error_lecture_elements(ERR_ABSORBEUR, ERR_PAS_ASSEZ); return NO; } start = end; _points[j].y = strtod(start, &end); if(start == end) { error_lecture_elements(ERR_ABSORBEUR, ERR_PAS_ASSEZ); return NO; } start = end; } //vérifies les points for(i = 1;i < _nbPt; i++) { if(!absorbeurDistanceRequise( _points[i], _points[i-1])) { error_lecture_point_trop_proche(ERR_ABSORBEUR, n); return NO; } } addAbsorbeur(_nbPt, _points); return OK; }
_Bool reflecteur_lecture(char * table, int i) { int counter; counter = sscanf(table, "%lg %lg %lg %lg", &tab_r[i].p1.x, &tab_r[i].p1.y, &tab_r[i].p2.x, &tab_r[i].p2.y); if(counter == REFLECTEUR_NUM_ARGU) { if(utilitaire_distance(tab_r[i].p1, tab_r[i].p2) > EPSIL_CREATION) return 1; error_lecture_point_trop_proche(ERR_REFLECTEUR, i); } else error_lecture_elements(ERR_REFLECTEUR, ERR_PAS_ASSEZ); return 0; }
int reflecteurSet(char line[MAX_LINE]) { POINT _a, _b; if(sscanf(line, "%lf %lf %lf %lf", &_a.x, &_a.y, &_b.x, &_b.y) != NB_ELEM) { error_lecture_elements(ERR_REFLECTEUR, ERR_PAS_ASSEZ); return NO; } if(!reflecteurDistanceRequise(_a, _b)) { error_lecture_point_trop_proche(ERR_REFLECTEUR, n); return NO; } addReflecteur(_a, _b); return OK; }
int setReflecteur(char line[MAX_LINE]) { POINT _a, _b; if(sscanf(line, "%lf %lf %lf %lf", &_a.x, &_a.y, &_b.x, &_b.y) != 4) { error_lecture_elements(ERR_REFLECTEUR, ERR_PAS_ASSEZ); return NO; } if(!distanceRequise(_a, _b)) { error_lecture_point_trop_proche(ERR_REFLECTEUR, 1); return NO; } tabReflecteur[n].a.x = _a.x; tabReflecteur[n].a.y = _a.y; tabReflecteur[n].b.x = _b.x; tabReflecteur[n].b.y = _b.y; n++; return OK; }