2 Copyright (c) 1999-2014 OPEN CASCADE SAS
4 This file is part of Open CASCADE Technology software library.
6 This library is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License version 2.1 as published
8 by the Free Software Foundation, with special exception defined in the file
9 OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 distribution for complete text of the license and disclaimer of any warranty.
12 Alternatively, this file may be used under the terms of Open CASCADE
13 commercial license or contractual agreement.
18 /* Routine de base de lecture d'un fichier IGES
20 Cette routine lit une ligne, sauf si le statut "relire sur place" est mis
21 (utilise pour changement de section) : il est reannule ensuite
23 Cette routine retourne :
24 - statut (retour fonction) : no de section : S,G,D,P,T (car 73) ou
25 0 (EOF) ou -1 (tacher de sauter) ou -2 (car. 73 faux)
26 - un numero de ligne dans la section (car. 74 a 80)
27 - la ligne tronquee a 72 caracteres (0 binaire dans le 73ieme)
28 Il faut lui fournir (buffer) une ligne reservee a 81 caracteres
30 Cas d erreur : ligne fausse des le debut -> abandon. Sinon tacher d enjamber
33 static int iges_fautrelire = 0;
34 int iges_lire (FILE* lefic, int *numsec, char ligne[100], int modefnes)
35 /*int iges_lire (lefic,numsec,ligne,modefnes)*/
36 /*FILE* lefic; int *numsec; char ligne[100]; int modefnes;*/
38 int i,result; char typesec;
40 if (iges_fautrelire == 0) {
41 if (*numsec == 0) ligne[72] = ligne[79] = ' ';
44 fgets(ligne,99,lefic); /*for kept compatibility with fnes*/
46 /* PTV: 21.03.2002 it is neccessary for files that have only `\r` but no `\n`
47 examle file is 919-001-T02-04-CP-VL.iges */
48 while ( fgets ( ligne, 2, lefic ) && ( ligne[0] == '\r' || ligne[0] == '\n' ) )
51 fgets(&ligne[1],80,lefic);
52 /* fgets(ligne,81,lefic); */
54 if (*numsec == 0 && ligne[72] != 'S' && ligne[79] == ' ') {
55 /* ON A DU FNES : Sauter la 1re ligne */
58 fgets(ligne,99,lefic);/*for kept compatibility with fnes*/
60 while ( fgets ( ligne, 2, lefic ) && ( ligne[0] == '\r' || ligne[0] == '\n' ) )
63 fgets(&ligne[1],80,lefic);
64 /* fgets(ligne,81,lefic); */
67 if ((ligne[0] & 128)&&modefnes) {
68 for (i = 0; i < 80; i ++)
69 ligne[i] = (char)(ligne[i] ^ (150 + (i & 3)));
72 if (feof(lefic)) return 0;
74 if (ligne[0] == '\0' || ligne[0] == '\n' || ligne[0] == '\r')
75 return iges_lire(lefic,numsec,ligne,modefnes); /* 0 */
76 if (sscanf(&ligne[73],"%d",&result) == 0) return -1;
77 /* { printf("Erreur, ligne n0.%d :\n%s\n",*numl,ligne); return (*numsec > 0 ? -1 : -2); } */
81 case 'S' : ligne[72] = '\0'; return (1);
82 case 'G' : ligne[72] = '\0'; return (2);
83 case 'D' : ligne[72] = '\0'; return (3);
84 case 'P' : ligne[72] = '\0'; return (4);
85 case 'T' : ligne[72] = '\0'; return (5);
86 default :; /* printf("Ligne incorrecte, ignoree n0.%d :\n%s\n",*numl,ligne); */
88 /* the column 72 is empty, try to check the neghbour*/
90 && (ligne[79]=='\n' || ligne[79]=='\r') && (ligne[0]<='9' && ligne[0]>='0')) {
91 /*check if the case of losted .*/
93 for(index = 1; ligne[index]<='9' && ligne[index]>='0'; index++);
94 if (ligne[index]=='D' || ligne[index]=='d') {
95 for(index = 79; index > 0; index--)
96 ligne[index] = ligne[index-1];
102 case 'S' : ligne[72] = '\0'; return (1);
103 case 'G' : ligne[72] = '\0'; return (2);
104 case 'D' : ligne[72] = '\0'; return (3);
105 case 'P' : ligne[72] = '\0'; return (4);
106 case 'T' : ligne[72] = '\0'; return (5);
107 default :; /* printf("Ligne incorrecte, ignoree n0.%d :\n%s\n",*numl,ligne); */
114 /* Pour commander la relecture sur place */
117 { iges_fautrelire = 1; }