1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
void copi_contour(const char *nomFichGeo) {
const char point[]="$points";
//const char courbe[]="$courbes"; // position curseur 808
const char calDeb[]="\n$debut du fichier\n";
const char calVers[]="\n$version\n";
const char noeud[]="$NOEUDS"; // position curseur : 306
int taille = strlen(point);
char*chaine[taille];
int nombre_point;
double version;
FILE* fichGeo = fopen(nomFichGeo,"r+"); // fichier.geo
//--------------------------------------------------------------
char nomFichCal[]={nomFichGeo};
strcpy(nomFichCal,nomFichGeo);
char *cal=".CAL";
strcat(nomFichCal,cal);
//--------------------------------------------------------------
FILE *fichCal= fopen(nomFichCal,"a+");// Création du fichier.cal
if(fichGeo!=NULL){
//---------------------------------------------------------------
rewind(fichGeo);
fseek(fichGeo,188,SEEK_SET);
fscanf(fichGeo,"%lf",&version);// récupère la version du logiciel
//---------------------------------------------------------------
while(fgets(chaine,sizeof(point),fichGeo)!= NULL){ // on lit tout le fichier ligne par ligne tant que celui-ci n'est pas vide
if (strcmp(chaine,point)==0){ // on s'arrète à la balise $points
fseek(fichGeo,2,SEEK_CUR); // on va à la ligne suivante
fscanf(fichGeo,"%d",&nombre_point); // on récupère le nombre de points
fseek(fichGeo,20,SEEK_CUR); // On se place à ligne contenant le premier point
//----------------------------------------------------------------------------------------------------------------------
if ( fichCal!=NULL){ /* formatage du fichGeoier *.CAL */
if (fgets(chaine,sizeof(calDeb),fichCal)==NULL){ // si le fichier est vide
fprintf(fichCal,calDeb);
fprintf(fichCal,calVers);
fprintf(fichCal,"%lf",version);
fprintf(fichCal,"\n\n$PROBLEME\nCONTRAINTES PLANES\n\n\n");
fprintf(fichCal,"\n$NOEUDS\n");
do { // boucle copiant les points du fichier .GEO vers le fichier .CAL pour avoir le contour
fgets(chaine,55,fichGeo);
fprintf(fichCal,"%s",chaine);
nombre_point=nombre_point--;
} while(nombre_point!=0);
fclose(fichCal);
}
}
//------------------------------------------------------------------------------------------------------------------------
}
}
fclose(fichGeo);
}
} |
Partager