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.
16 /* Regroupement des sources "C" pour compilation */
19 #include <OSD_OpenFile.hxx>
22 void IGESFile_Check21 (int mode,char * code, int num, char * str);
24 void IGESFile_Check3 (int mode,char * code);
25 void IGESFile_Check2 (int mode,char * code, int num, char * str);
27 /* #include "structiges.c" ... fait par analiges qui en a l'usage ... */
29 int iges_lire (FILE* lefic, int *numsec, char ligne[100], int modefnes);
30 void iges_newparam(int typarg,int longval, char *parval);
31 void iges_param(int *Pstat,char *ligne,char c_separ,char c_fin,int lonlin);
32 void iges_Dsect (int *Dstat,int numsec,char* ligne);
33 void iges_Psect(int numsec,char ligne[80]);
37 /* Routine de lecture generale d'un fichier IGES
38 Assure l'enchainement des appels necessaires
39 Il en resulte un ensemble de donnees (struct C) interrogeables par
40 routines ad hoc (cf igesread.h qui les recapitule pour appel par C++)
42 Retourne : 0 si OK, 1 si fichier pas pu etre ouvert
48 /*#include <string.h>*/
49 /* To use Msg class */
50 /*#include <MoniTool_Msg.hxx>*/
52 static char sects [] = " SGDPT ";
55 int igesread (char* nomfic, int lesect[6], int modefnes)
59 FILE* lefic; char ligne[100]; int numsec, numl; int i; int i0;int j;
62 int Dstat = 0; int Pstat = 0; char c_separ = ','; char c_fin = ';';
64 lefic = stdin; i0 = numsec = 0; numl = 0;
65 if (nomfic[0] != '\0')
66 lefic = OSD_OpenFile(nomfic,"r");
67 if (lefic == NULL) return -1; /* fichier pas pu etre ouvert */
68 for (i = 1; i < 6; i++) lesect[i] = 0;
69 for (j = 0; j < 100; j++) ligne[j] = 0;
72 i = iges_lire(lefic,&numsec,ligne,modefnes);
73 if (i <= 0 || i < i0) {
75 /* Sending of message : Syntax error */
79 IGESFile_Check2 (0,"XSTEP_18",numl,str); /* //gka 15 Sep 98: str instead of sects[i0]); */
82 if (i0 == 0) return -1;
87 if (numsec != lesect[i]) {
88 /* Sending of message : Syntax error */
91 IGESFile_Check2 (0,"XSTEP_19",numl,str); /* //gka 15 Sep 98: str instead of sects[i0]); */
94 if (i == 1) { /* Start Section (comm.) */
96 iges_newparam (0,72,ligne);
98 if (i == 2) { /* Header (Global sect) */
101 if (lesect[i] == 1) { /* Separation specifique */
103 if (ligne[0] != ',') { c_separ = ligne[2]; n0 = 3; }
104 if (ligne[n0+1] != c_separ) { c_fin = ligne[n0+3]; }
106 iges_param(&Pstat,ligne,c_separ,c_fin,72);
107 if (Pstat != 2) break;
110 if (i == 3) iges_Dsect(&Dstat,numsec,ligne); /* Directory (Dsect) */
111 if (i == 4) { /* Parametres (Psect) */
112 iges_Psect(numsec,ligne);
114 iges_param(&Pstat,ligne,c_separ,c_fin,64);
115 if (Pstat != 2) break;
120 /* Sending of message : No Terminal Section */
121 if (lesect[5] == 0) {
122 IGESFile_Check3 (1, "XSTEP_20");