2 Copyright (c) 1999-2012 OPEN CASCADE SAS
4 The content of this file is subject to the Open CASCADE Technology Public
5 License Version 6.5 (the "License"). You may not use the content of this file
6 except in compliance with the License. Please obtain a copy of the License
7 at http://www.opencascade.org and read it completely before using this file.
9 The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 The Original Code and all software distributed under the License is
13 distributed on an "AS IS" basis, without warranty of any kind, and the
14 Initial Developer hereby disclaims all such warranties, including without
15 limitation, any warranties of merchantability, fitness for a particular
16 purpose or non-infringement. Please see the License for the specific terms
17 and conditions governing the rights and limitations under the License.
23 /* Routine de base de lecture d'un fichier IGES
25 Cette routine lit une ligne, sauf si le statut "relire sur place" est mis
26 (utilise pour changement de section) : il est reannule ensuite
28 Cette routine retourne :
29 - statut (retour fonction) : no de section : S,G,D,P,T (car 73) ou
30 0 (EOF) ou -1 (tacher de sauter) ou -2 (car. 73 faux)
31 - un numero de ligne dans la section (car. 74 a 80)
32 - la ligne tronquee a 72 caracteres (0 binaire dans le 73ieme)
33 Il faut lui fournir (buffer) une ligne reservee a 81 caracteres
35 Cas d erreur : ligne fausse des le debut -> abandon. Sinon tacher d enjamber
38 static int iges_fautrelire = 0;
39 int iges_lire (FILE* lefic, int *numsec, char ligne[100], int modefnes)
40 /*int iges_lire (lefic,numsec,ligne,modefnes)*/
41 /*FILE* lefic; int *numsec; char ligne[100]; int modefnes;*/
43 int i,result; char typesec;
45 if (iges_fautrelire == 0) {
46 if (*numsec == 0) ligne[72] = ligne[79] = ' ';
49 fgets(ligne,99,lefic); /*for kept compatibility with fnes*/
51 /* PTV: 21.03.2002 it is neccessary for files that have only `\r` but no `\n`
52 examle file is 919-001-T02-04-CP-VL.iges */
53 while ( fgets ( ligne, 2, lefic ) && ( ligne[0] == '\r' || ligne[0] == '\n' ) )
56 fgets(&ligne[1],80,lefic);
57 /* fgets(ligne,81,lefic); */
59 if (*numsec == 0 && ligne[72] != 'S' && ligne[79] == ' ') {
60 /* ON A DU FNES : Sauter la 1re ligne */
63 fgets(ligne,99,lefic);/*for kept compatibility with fnes*/
65 while ( fgets ( ligne, 2, lefic ) && ( ligne[0] == '\r' || ligne[0] == '\n' ) )
68 fgets(&ligne[1],80,lefic);
69 /* fgets(ligne,81,lefic); */
72 if ((ligne[0] & 128)&&modefnes) {
73 for (i = 0; i < 80; i ++) ligne[i] = ligne[i] ^ (150 + (i & 3));
76 if (feof(lefic)) return 0;
78 if (ligne[0] == '\0' || ligne[0] == '\n' || ligne[0] == '\r')
79 return iges_lire(lefic,numsec,ligne,modefnes); /* 0 */
80 if (sscanf(&ligne[73],"%d",&result) == 0) return -1;
81 /* { printf("Erreur, ligne n0.%d :\n%s\n",*numl,ligne); return (*numsec > 0 ? -1 : -2); } */
85 case 'S' : ligne[72] = '\0'; return (1);
86 case 'G' : ligne[72] = '\0'; return (2);
87 case 'D' : ligne[72] = '\0'; return (3);
88 case 'P' : ligne[72] = '\0'; return (4);
89 case 'T' : ligne[72] = '\0'; return (5);
90 default :; /* printf("Ligne incorrecte, ignoree n0.%d :\n%s\n",*numl,ligne); */
92 /* the column 72 is empty, try to check the neghbour*/
94 && (ligne[79]=='\n' || ligne[79]=='\r') && (ligne[0]<='9' && ligne[0]>='0')) {
95 /*check if the case of losted .*/
97 for(index = 1; ligne[index]<='9' && ligne[index]>='0'; index++);
98 if (ligne[index]=='D' || ligne[index]=='d') {
99 for(index = 79; index > 0; index--)
100 ligne[index] = ligne[index-1];
106 case 'S' : ligne[72] = '\0'; return (1);
107 case 'G' : ligne[72] = '\0'; return (2);
108 case 'D' : ligne[72] = '\0'; return (3);
109 case 'P' : ligne[72] = '\0'; return (4);
110 case 'T' : ligne[72] = '\0'; return (5);
111 default :; /* printf("Ligne incorrecte, ignoree n0.%d :\n%s\n",*numl,ligne); */
118 /* Pour commander la relecture sur place */
121 { iges_fautrelire = 1; }