973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | //==================================================================== |
15 | //#10 smh 22.12.99 Protection (case of unexisting directory entry in file) |
16 | //sln 21.01.2002 OCC133: Exception handling was added in method Interface_FileReaderData::BoundEntity |
17 | //==================================================================== |
18 | #include <Standard_ErrorHandler.hxx> |
19 | #include <Standard_Failure.hxx> |
20 | #include <Interface_FileReaderData.ixx> |
21 | |
22 | |
23 | // Stoque les Donnees issues d un Fichier (Conservees sous forme Litterale) |
24 | // Chaque norme peut s en servir comme base (listes de parametres litteraux, |
25 | // entites associees) et y ajoute ses donnees propres. |
26 | |
27 | // Travaille sous le controle de FileReaderTool |
28 | |
29 | // Optimisation : Champs pas possibles, car Param est const. Dommage |
30 | // Donc, on suppose qu on lit un fichier a la fois (hypothese raisonnable) |
31 | // On note en champ un numero de fichier, par rapport auquel on optimise |
32 | static Standard_Integer thefic = 0; |
33 | static Standard_Integer thenm0 = -1; |
34 | static Standard_Integer thenp0 = -1; |
35 | |
36 | |
37 | Interface_FileReaderData::Interface_FileReaderData (const Standard_Integer nbr, |
38 | const Standard_Integer npar) |
39 | : therrload (0), thenumpar (0,nbr), theents (0,nbr) |
40 | { |
41 | theparams = new Interface_ParamSet (npar); |
42 | thenumpar.Init(0); |
43 | thenm0 = -1; |
44 | thenum0 = ++thefic; |
45 | } |
46 | |
47 | Standard_Integer Interface_FileReaderData::NbRecords () const |
48 | { return thenumpar.Upper(); } |
49 | |
50 | Standard_Integer Interface_FileReaderData::NbEntities () const |
51 | { |
52 | Standard_Integer nb = 0; Standard_Integer num = 0; |
53 | while ( (num = FindNextRecord(num)) > 0) nb ++; |
54 | return nb; |
55 | } |
56 | |
57 | |
58 | // .... Gestion des Parametres attaches aux Records .... |
59 | |
60 | void Interface_FileReaderData::InitParams (const Standard_Integer num) |
61 | { |
62 | thenumpar.SetValue (num,theparams->NbParams()); |
7fd59977 |
63 | } |
64 | |
65 | void Interface_FileReaderData::AddParam |
35e08fe8 |
66 | (const Standard_Integer /*num*/, |
7fd59977 |
67 | const Standard_CString aval, const Interface_ParamType atype, |
68 | const Standard_Integer nument) |
69 | { |
7fd59977 |
70 | theparams->Append(aval,-1,atype,nument); |
7fd59977 |
71 | } |
72 | |
73 | void Interface_FileReaderData::AddParam |
35e08fe8 |
74 | (const Standard_Integer /*num*/, |
7fd59977 |
75 | const TCollection_AsciiString& aval, const Interface_ParamType atype, |
76 | const Standard_Integer nument) |
77 | { |
7fd59977 |
78 | theparams->Append(aval.ToCString(),aval.Length(),atype,nument); |
7fd59977 |
79 | } |
80 | |
81 | void Interface_FileReaderData::AddParam |
35e08fe8 |
82 | (const Standard_Integer /*num*/, |
7fd59977 |
83 | const Interface_FileParameter& FP) |
84 | { |
85 | theparams->Append(FP); |
7fd59977 |
86 | } |
87 | |
88 | |
89 | void Interface_FileReaderData::SetParam |
90 | (const Standard_Integer num, const Standard_Integer nump, |
91 | const Interface_FileParameter& FP) |
92 | { |
7fd59977 |
93 | theparams->SetParam(thenumpar(num-1)+nump,FP); |
94 | } |
95 | |
96 | Standard_Integer Interface_FileReaderData::NbParams |
97 | (const Standard_Integer num) const |
98 | { |
99 | if (num > 1) return (thenumpar(num) - thenumpar(num-1)); |
7dc9e047 |
100 | else if(num ==1) return thenumpar(num); |
7fd59977 |
101 | else return theparams->NbParams(); |
102 | } |
103 | |
104 | Handle(Interface_ParamList) Interface_FileReaderData::Params |
105 | (const Standard_Integer num) const |
106 | { |
107 | if (num == 0) return theparams->Params(0,0); // complet |
108 | else if(num ==1) return theparams->Params(0,thenumpar(1)); |
109 | else return theparams->Params ( thenumpar(num-1)+1, (thenumpar(num) - thenumpar(num-1)) ); |
110 | } |
111 | |
112 | const Interface_FileParameter& Interface_FileReaderData::Param |
113 | (const Standard_Integer num, const Standard_Integer nump) const |
114 | { |
115 | if (thefic != thenum0) return theparams->Param(thenumpar(num-1)+nump); |
116 | if (thenm0 != num) { thenp0 = thenumpar(num-1); thenm0 = num; } |
117 | return theparams->Param (thenp0+nump); |
118 | } |
119 | |
120 | Interface_FileParameter& Interface_FileReaderData::ChangeParam |
121 | (const Standard_Integer num, const Standard_Integer nump) |
122 | { |
123 | if (thefic != thenum0) return theparams->ChangeParam(thenumpar(num-1)+nump); |
124 | if (thenm0 != num) { thenp0 = thenumpar(num-1); thenm0 = num; } |
125 | return theparams->ChangeParam (thenp0+nump); |
126 | } |
127 | |
128 | Interface_ParamType Interface_FileReaderData::ParamType |
129 | (const Standard_Integer num, const Standard_Integer nump) const |
130 | { return Param(num,nump).ParamType(); } |
131 | |
132 | Standard_CString Interface_FileReaderData::ParamCValue |
133 | (const Standard_Integer num, const Standard_Integer nump) const |
134 | { return Param(num,nump).CValue(); } |
135 | |
136 | |
137 | Standard_Boolean Interface_FileReaderData::IsParamDefined |
138 | (const Standard_Integer num, const Standard_Integer nump) const |
139 | { return (Param(num,nump).ParamType() != Interface_ParamVoid); } |
140 | |
141 | Standard_Integer Interface_FileReaderData::ParamNumber |
142 | (const Standard_Integer num, const Standard_Integer nump) const |
143 | { return Param(num,nump).EntityNumber(); } |
144 | |
145 | const Handle(Standard_Transient)& Interface_FileReaderData::ParamEntity |
146 | (const Standard_Integer num, const Standard_Integer nump) const |
147 | { return BoundEntity (Param(num,nump).EntityNumber()); } |
148 | |
149 | Interface_FileParameter& Interface_FileReaderData::ChangeParameter |
150 | (const Standard_Integer numpar) |
151 | { return theparams->ChangeParam (numpar); } |
152 | |
153 | void Interface_FileReaderData::ParamPosition |
154 | (const Standard_Integer numpar, |
155 | Standard_Integer& num, Standard_Integer& nump) const |
156 | { |
157 | Standard_Integer nbe = thenumpar.Upper(); |
158 | if (numpar <= 0) { num = nump = 0; return; } |
159 | for (Standard_Integer i = 1; i <= nbe; i ++) { |
160 | if (thenumpar(i) > numpar) |
161 | { num = i; nump = numpar - thenumpar(i) +1; return; } |
162 | } |
163 | num = nbe; nump = numpar - thenumpar(nbe) +1; |
164 | } |
165 | |
166 | Standard_Integer Interface_FileReaderData::ParamFirstRank |
167 | (const Standard_Integer num) const |
168 | { return thenumpar(num); } |
169 | |
170 | void Interface_FileReaderData::SetErrorLoad (const Standard_Boolean val) |
171 | { therrload = (val ? 1 : -1); } |
172 | |
173 | Standard_Boolean Interface_FileReaderData::IsErrorLoad () const |
174 | { return (therrload != 0); } |
175 | |
176 | Standard_Boolean Interface_FileReaderData::ResetErrorLoad () |
177 | { Standard_Boolean res = (therrload > 0); therrload = 0; return res; } |
178 | |
179 | // .... Gestion des Entites Associees aux Donnees du Fichier .... |
180 | |
181 | |
182 | const Handle(Standard_Transient)& Interface_FileReaderData::BoundEntity |
183 | (const Standard_Integer num) const |
184 | // { return theents(num); } |
185 | { |
186 | if (num >= theents.Lower() && num <= theents.Upper()) { |
187 | return theents(num); |
188 | } |
189 | else { |
190 | static Handle(Standard_Transient) dummy; |
191 | return dummy; |
192 | } |
193 | } |
194 | /* //static Handle(Standard_Transient) dummy; |
195 | { |
196 | //smh#10 Protection. If iges entity does not exist, return null pointer. |
197 | try { |
198 | OCC_CATCH_SIGNALS |
199 | Handle(Standard_Transient) temp = theents.Value(num); |
200 | } |
201 | ////sln 21.01.2002 OCC133: Exception handling |
202 | // catch (Standard_OutOfRange) { |
203 | // cout<<" Catch of sln"<<endl; |
204 | |
205 | // return dummy; |
206 | // } |
207 | catch (Standard_Failure) { |
208 | |
209 | // some work-around, the best would be to modify CDL to |
210 | // return "Handle(Standard_Transient)" not "const Handle(Standard_Transient)&" |
211 | static Handle(Standard_Transient) dummy; |
212 | // cout<<" Catch of smh"<<endl; |
213 | return dummy; |
214 | } |
215 | } |
216 | //cout<<" Normal"<<endl; |
217 | if (theents.Value(num).IsImmutable()) cout << "IMMUTABLE:"<<num<<endl; |
218 | return theents(num); |
219 | } |
220 | */ |
221 | |
222 | void Interface_FileReaderData::BindEntity |
223 | (const Standard_Integer num, const Handle(Standard_Transient)& ent) |
224 | // { theents.SetValue(num,ent); } |
225 | { |
226 | // #ifdef DEB |
227 | // if (ent.IsImmutable()) |
228 | // cout << "Bind IMMUTABLE:"<<num<<endl; |
229 | // #endif |
230 | theents.SetValue(num,ent); |
231 | } |
232 | |
233 | void Interface_FileReaderData::Destroy () |
234 | { |
235 | } |
236 | |
237 | |
238 | #define MAXCHIF 80 |
239 | |
240 | static const Standard_Real vtab[] = |
241 | { 1., 2., 3., 4., 5., 6., 7., 8., 9., |
242 | 10., 20., 30., 40., 50., 60., 70., 80., 90., |
243 | 100., 200., 300., 400., 500., 600., 700., 800., 900., |
244 | 1000., 2000., 3000., 4000., 5000., 6000., 7000., 8000., 9000., |
245 | 10000., 20000., 30000., 40000., 50000., 60000., 70000., 80000., 90000., |
246 | 1.E+05, 2.E+05, 3.E+05, 4.E+05, 5.E+05, 6.E+05, 7.E+05, 8.E+05, 9.E+05, |
247 | 1.E+06, 2.E+06, 3.E+06, 4.E+06, 5.E+06, 6.E+06, 7.E+06, 8.E+06, 9.E+06, |
248 | 1.E+07, 2.E+07, 3.E+07, 4.E+07, 5.E+07, 6.E+07, 7.E+07, 8.E+07, 9.E+07, |
249 | 1.E+08, 2.E+08, 3.E+08, 4.E+08, 5.E+08, 6.E+08, 7.E+08, 8.E+08, 9.E+08, |
250 | 1.E+09, 2.E+09, 3.E+09, 4.E+09, 5.E+09, 6.E+09, 7.E+09, 8.E+09, 9.E+09, |
251 | 1.E+10, 2.E+10, 3.E+10, 4.E+10, 5.E+10, 6.E+10, 7.E+10, 8.E+10, 9.E+10, |
252 | 1.E+11, 2.E+11, 3.E+11, 4.E+11, 5.E+11, 6.E+11, 7.E+11, 8.E+11, 9.E+11, |
253 | 1.E+12, 2.E+12, 3.E+12, 4.E+12, 5.E+12, 6.E+12, 7.E+12, 8.E+12, 9.E+12, |
254 | 1.E+13, 2.E+13, 3.E+13, 4.E+13, 5.E+13, 6.E+13, 7.E+13, 8.E+13, 9.E+13, |
255 | 1.E+14, 2.E+14, 3.E+14, 4.E+14, 5.E+14, 6.E+14, 7.E+14, 8.E+14, 9.E+14, |
256 | 1.E+15, 2.E+15, 3.E+15, 4.E+15, 5.E+15, 6.E+15, 7.E+15, 8.E+15, 9.E+15, |
257 | 1.E+16, 2.E+16, 3.E+16, 4.E+16, 5.E+16, 6.E+16, 7.E+16, 8.E+16, 9.E+16, |
258 | 1.E+17, 2.E+17, 3.E+17, 4.E+17, 5.E+17, 6.E+17, 7.E+17, 8.E+17, 9.E+17, |
259 | 1.E+18, 2.E+18, 3.E+18, 4.E+18, 5.E+18, 6.E+18, 7.E+18, 8.E+18, 9.E+18, |
260 | 1.E+19, 2.E+19, 3.E+19, 4.E+19, 5.E+19, 6.E+19, 7.E+19, 8.E+19, 9.E+19, |
261 | 1.E+20, 2.E+20, 3.E+20, 4.E+20, 5.E+20, 6.E+20, 7.E+20, 8.E+20, 9.E+20, |
262 | 1.E+21, 2.E+21, 3.E+21, 4.E+21, 5.E+21, 6.E+21, 7.E+21, 8.E+21, 9.E+21, |
263 | 1.E+22, 2.E+22, 3.E+22, 4.E+22, 5.E+22, 6.E+22, 7.E+22, 8.E+22, 9.E+22, |
264 | 1.E+23, 2.E+23, 3.E+23, 4.E+23, 5.E+23, 6.E+23, 7.E+23, 8.E+23, 9.E+23, |
265 | 1.E+24, 2.E+24, 3.E+24, 4.E+24, 5.E+24, 6.E+24, 7.E+24, 8.E+24, 9.E+24, |
266 | 1.E+25, 2.E+25, 3.E+25, 4.E+25, 5.E+25, 6.E+25, 7.E+25, 8.E+25, 9.E+25, |
267 | 1.E+26, 2.E+26, 3.E+26, 4.E+26, 5.E+26, 6.E+26, 7.E+26, 8.E+26, 9.E+26, |
268 | 1.E+27, 2.E+27, 3.E+27, 4.E+27, 5.E+27, 6.E+27, 7.E+27, 8.E+27, 9.E+27, |
269 | 1.E+28, 2.E+28, 3.E+28, 4.E+28, 5.E+28, 6.E+28, 7.E+28, 8.E+28, 9.E+28, |
270 | 1.E+29, 2.E+29, 3.E+29, 4.E+29, 5.E+29, 6.E+29, 7.E+29, 8.E+29, 9.E+29, |
271 | 1.E+30, 2.E+30, 3.E+30, 4.E+30, 5.E+30, 6.E+30, 7.E+30, 8.E+30, 9.E+30, |
272 | 1.E+31, 2.E+31, 3.E+31, 4.E+31, 5.E+31, 6.E+31, 7.E+31, 8.E+31, 9.E+31, |
273 | 1.E+32, 2.E+32, 3.E+32, 4.E+32, 5.E+32, 6.E+32, 7.E+32, 8.E+32, 9.E+32, |
274 | 1.E+33, 2.E+33, 3.E+33, 4.E+33, 5.E+33, 6.E+33, 7.E+33, 8.E+33, 9.E+33, |
275 | 1.E+34, 2.E+34, 3.E+34, 4.E+34, 5.E+34, 6.E+34, 7.E+34, 8.E+34, 9.E+34, |
276 | 1.E+35, 2.E+35, 3.E+35, 4.E+35, 5.E+35, 6.E+35, 7.E+35, 8.E+35, 9.E+35, |
277 | 1.E+36, 2.E+36, 3.E+36, 4.E+36, 5.E+36, 6.E+36, 7.E+36, 8.E+36, 9.E+36, |
278 | 1.E+37, 2.E+37, 3.E+37, 4.E+37, 5.E+37, 6.E+37, 7.E+37, 8.E+37, 9.E+37, |
279 | 1.E+38, 2.E+38, 3.E+38, 4.E+38, 5.E+38, 6.E+38, 7.E+38, 8.E+38, 9.E+38, |
280 | 1.E+39, 2.E+39, 3.E+39, 4.E+39, 5.E+39, 6.E+39, 7.E+39, 8.E+39, 9.E+39, |
281 | 1.E+40, 2.E+40, 3.E+40, 4.E+40, 5.E+40, 6.E+40, 7.E+40, 8.E+40, 9.E+40, |
282 | 1.E+41, 2.E+41, 3.E+41, 4.E+41, 5.E+41, 6.E+41, 7.E+41, 8.E+41, 9.E+41, |
283 | 1.E+42, 2.E+42, 3.E+42, 4.E+42, 5.E+42, 6.E+42, 7.E+42, 8.E+42, 9.E+42, |
284 | 1.E+43, 2.E+43, 3.E+43, 4.E+43, 5.E+43, 6.E+43, 7.E+43, 8.E+43, 9.E+43, |
285 | 1.E+44, 2.E+44, 3.E+44, 4.E+44, 5.E+44, 6.E+44, 7.E+44, 8.E+44, 9.E+44, |
286 | 1.E+45, 2.E+45, 3.E+45, 4.E+45, 5.E+45, 6.E+45, 7.E+45, 8.E+45, 9.E+45, |
287 | 1.E+46, 2.E+46, 3.E+46, 4.E+46, 5.E+46, 6.E+46, 7.E+46, 8.E+46, 9.E+46, |
288 | 1.E+47, 2.E+47, 3.E+47, 4.E+47, 5.E+47, 6.E+47, 7.E+47, 8.E+47, 9.E+47, |
289 | 1.E+48, 2.E+48, 3.E+48, 4.E+48, 5.E+48, 6.E+48, 7.E+48, 8.E+48, 9.E+48, |
290 | 1.E+49, 2.E+49, 3.E+49, 4.E+49, 5.E+49, 6.E+49, 7.E+49, 8.E+49, 9.E+49, |
291 | 1.E+50, 2.E+50, 3.E+50, 4.E+50, 5.E+50, 6.E+50, 7.E+50, 8.E+50, 9.E+50, |
292 | 1.E+51, 2.E+51, 3.E+51, 4.E+51, 5.E+51, 6.E+51, 7.E+51, 8.E+51, 9.E+51, |
293 | 1.E+52, 2.E+52, 3.E+52, 4.E+52, 5.E+52, 6.E+52, 7.E+52, 8.E+52, 9.E+52, |
294 | 1.E+53, 2.E+53, 3.E+53, 4.E+53, 5.E+53, 6.E+53, 7.E+53, 8.E+53, 9.E+53, |
295 | 1.E+54, 2.E+54, 3.E+54, 4.E+54, 5.E+54, 6.E+54, 7.E+54, 8.E+54, 9.E+54, |
296 | 1.E+55, 2.E+55, 3.E+55, 4.E+55, 5.E+55, 6.E+55, 7.E+55, 8.E+55, 9.E+55, |
297 | 1.E+56, 2.E+56, 3.E+56, 4.E+56, 5.E+56, 6.E+56, 7.E+56, 8.E+56, 9.E+56, |
298 | 1.E+57, 2.E+57, 3.E+57, 4.E+57, 5.E+57, 6.E+57, 7.E+57, 8.E+57, 9.E+57, |
299 | 1.E+58, 2.E+58, 3.E+58, 4.E+58, 5.E+58, 6.E+58, 7.E+58, 8.E+58, 9.E+58, |
300 | 1.E+59, 2.E+59, 3.E+59, 4.E+59, 5.E+59, 6.E+59, 7.E+59, 8.E+59, 9.E+59, |
301 | 1.E+60, 2.E+60, 3.E+60, 4.E+60, 5.E+60, 6.E+60, 7.E+60, 8.E+60, 9.E+60, |
302 | 1.E+61, 2.E+61, 3.E+61, 4.E+61, 5.E+61, 6.E+61, 7.E+61, 8.E+61, 9.E+61, |
303 | 1.E+62, 2.E+62, 3.E+62, 4.E+62, 5.E+62, 6.E+62, 7.E+62, 8.E+62, 9.E+62, |
304 | 1.E+63, 2.E+63, 3.E+63, 4.E+63, 5.E+63, 6.E+63, 7.E+63, 8.E+63, 9.E+63, |
305 | 1.E+64, 2.E+64, 3.E+64, 4.E+64, 5.E+64, 6.E+64, 7.E+64, 8.E+64, 9.E+64, |
306 | 1.E+65, 2.E+65, 3.E+65, 4.E+65, 5.E+65, 6.E+65, 7.E+65, 8.E+65, 9.E+65, |
307 | 1.E+66, 2.E+66, 3.E+66, 4.E+66, 5.E+66, 6.E+66, 7.E+66, 8.E+66, 9.E+66, |
308 | 1.E+67, 2.E+67, 3.E+67, 4.E+67, 5.E+67, 6.E+67, 7.E+67, 8.E+67, 9.E+67, |
309 | 1.E+68, 2.E+68, 3.E+68, 4.E+68, 5.E+68, 6.E+68, 7.E+68, 8.E+68, 9.E+68, |
310 | 1.E+69, 2.E+69, 3.E+69, 4.E+69, 5.E+69, 6.E+69, 7.E+69, 8.E+69, 9.E+69, |
311 | 1.E+70, 2.E+70, 3.E+70, 4.E+70, 5.E+70, 6.E+70, 7.E+70, 8.E+70, 9.E+70, |
312 | 1.E+71, 2.E+71, 3.E+71, 4.E+71, 5.E+71, 6.E+71, 7.E+71, 8.E+71, 9.E+71, |
313 | 1.E+72, 2.E+72, 3.E+72, 4.E+72, 5.E+72, 6.E+72, 7.E+72, 8.E+72, 9.E+72, |
314 | 1.E+73, 2.E+73, 3.E+73, 4.E+73, 5.E+73, 6.E+73, 7.E+73, 8.E+73, 9.E+73, |
315 | 1.E+74, 2.E+74, 3.E+74, 4.E+74, 5.E+74, 6.E+74, 7.E+74, 8.E+74, 9.E+74, |
316 | 1.E+75, 2.E+75, 3.E+75, 4.E+75, 5.E+75, 6.E+75, 7.E+75, 8.E+75, 9.E+75, |
317 | 1.E+76, 2.E+76, 3.E+76, 4.E+76, 5.E+76, 6.E+76, 7.E+76, 8.E+76, 9.E+76, |
318 | 1.E+77, 2.E+77, 3.E+77, 4.E+77, 5.E+77, 6.E+77, 7.E+77, 8.E+77, 9.E+77, |
319 | 1.E+78, 2.E+78, 3.E+78, 4.E+78, 5.E+78, 6.E+78, 7.E+78, 8.E+78, 9.E+78, |
320 | 1.E+79, 2.E+79, 3.E+79, 4.E+79, 5.E+79, 6.E+79, 7.E+79, 8.E+79, 9.E+79, |
321 | 1.E+80, 2.E+80, 3.E+80, 4.E+80, 5.E+80, 6.E+80, 7.E+80, 8.E+80, 9.E+80, |
322 | 1.E+81, 2.E+81, 3.E+81, 4.E+81, 5.E+81, 6.E+81, 7.E+81, 8.E+81, 9.E+81, |
323 | 1.E+82, 2.E+82, 3.E+82, 4.E+82, 5.E+82, 6.E+82, 7.E+82, 8.E+82, 9.E+82, |
324 | 1.E+83, 2.E+83, 3.E+83, 4.E+83, 5.E+83, 6.E+83, 7.E+83, 8.E+83, 9.E+83, |
325 | 1.E+84, 2.E+84, 3.E+84, 4.E+84, 5.E+84, 6.E+84, 7.E+84, 8.E+84, 9.E+84, |
326 | 1.E+85, 2.E+85, 3.E+85, 4.E+85, 5.E+85, 6.E+85, 7.E+85, 8.E+85, 9.E+85, |
327 | 1.E+86, 2.E+86, 3.E+86, 4.E+86, 5.E+86, 6.E+86, 7.E+86, 8.E+86, 9.E+86, |
328 | 1.E+87, 2.E+87, 3.E+87, 4.E+87, 5.E+87, 6.E+87, 7.E+87, 8.E+87, 9.E+87, |
329 | 1.E+88, 2.E+88, 3.E+88, 4.E+88, 5.E+88, 6.E+88, 7.E+88, 8.E+88, 9.E+88, |
330 | 1.E+89, 2.E+89, 3.E+89, 4.E+89, 5.E+89, 6.E+89, 7.E+89, 8.E+89, 9.E+89, |
331 | 1.E+90, 2.E+90, 3.E+90, 4.E+90, 5.E+90, 6.E+90, 7.E+90, 8.E+90, 9.E+90, |
332 | 1.E+91, 2.E+91, 3.E+91, 4.E+91, 5.E+91, 6.E+91, 7.E+91, 8.E+91, 9.E+91, |
333 | 1.E+92, 2.E+92, 3.E+92, 4.E+92, 5.E+92, 6.E+92, 7.E+92, 8.E+92, 9.E+92, |
334 | 1.E+93, 2.E+93, 3.E+93, 4.E+93, 5.E+93, 6.E+93, 7.E+93, 8.E+93, 9.E+93, |
335 | 1.E+94, 2.E+94, 3.E+94, 4.E+94, 5.E+94, 6.E+94, 7.E+94, 8.E+94, 9.E+94, |
336 | 1.E+95, 2.E+95, 3.E+95, 4.E+95, 5.E+95, 6.E+95, 7.E+95, 8.E+95, 9.E+95, |
337 | 1.E+96, 2.E+96, 3.E+96, 4.E+96, 5.E+96, 6.E+96, 7.E+96, 8.E+96, 9.E+96, |
338 | 1.E+97, 2.E+97, 3.E+97, 4.E+97, 5.E+97, 6.E+97, 7.E+97, 8.E+97, 9.E+97, |
339 | 1.E+98, 2.E+98, 3.E+98, 4.E+98, 5.E+98, 6.E+98, 7.E+98, 8.E+98, 9.E+98, |
340 | 1.E+99, 2.E+99, 3.E+99, 4.E+99, 5.E+99, 6.E+99, 7.E+99, 8.E+99, 9.E+99 }; |
341 | |
342 | |
343 | Standard_Real Interface_FileReaderData::Fastof (const Standard_CString ligne) |
344 | { |
345 | Standard_Real val = 0., valdiv; |
346 | int i, jj, j, k, je, jx; |
347 | int chiffre[MAXCHIF]; int point, prem, moins, exp, grexp; |
348 | j = jj = je = jx = 0; |
349 | moins = exp = grexp = 0; |
350 | prem = MAXCHIF + 1; point = -1; // ligne[MAXCHIF+1] = '\0'; fin forcee |
351 | |
352 | /* Analyse de la ligne (reputee representer un Flottant) */ |
353 | for (i = 0; ; i ++) { // critere d arret : cf '\0' |
354 | const char& car = ligne[i]; |
355 | /* critere d arret : ne pas l oublier, mais eviter de freiner le traitement |
356 | DONC, une fois en fin, plus une fois pour 1er passage |
357 | if (car == '\0') |
358 | { if (point < 0) { point = i; jx = point - prem; }; break; } */ |
359 | |
360 | if (prem > MAXCHIF) { |
361 | if (car == '0') continue; |
362 | if (car == '.') { point = i; continue; } |
363 | if (car == '+') continue; |
364 | if (car == '-') { moins = 1; continue; } |
365 | if (car == '\0') |
366 | { if (point < 0) { point = i; jx = point - prem; }; break; } |
367 | if (car < 33) continue; |
368 | prem = i; |
369 | if (point >= 0) jx = point - prem + 1; |
370 | } |
371 | if (car > 48 && car <= 57) |
372 | { chiffre[j] = car - 48; jj = ++j; continue; } // j++ puis jj = j |
373 | if (car == '0') { chiffre[j] = 0; j ++; continue; } |
374 | if (car == '.') { point = i; jx = point - prem; continue; } |
375 | if ((car & 94) == 68) { // prend : e E d D |
376 | je = i; exp = atoi(&ligne[i+1]); jx += exp; |
377 | if (exp < -100 || exp > 100) grexp = 1; break; |
378 | } |
379 | if (car == '\0') |
380 | { if (point < 0) { point = i; jx = point - prem; }; break; } |
381 | } |
382 | |
383 | /* Interpretation : on decale le Point Decimal selon l Exposant |
384 | Puis on considere par rapport a <jj>, <prem> : |
385 | chiffre[i, pour i < point - prem] : partie entiere |
386 | chiffre[i, pour i >= point - prem] : partie decimale |
387 | */ |
388 | |
389 | // jx = (point < prem ? point - prem + 1 : point - prem) + exp; deja calcule |
390 | // Puissance de 10 premiere decimale <0> |
391 | // limite : le PLUS PETIT SIGNIFIANT doit etre >= 1e-99 |
392 | je = jx*9; |
393 | if (jx > jj) { |
394 | valdiv = 1.; |
91322f44 |
395 | if (jx >= 100 || grexp) return Atof(ligne); // issue de secours |
7fd59977 |
396 | } else { |
397 | k = jj*9; |
91322f44 |
398 | if (jj >= 100 || grexp || (k-je >= 900)) return Atof(ligne); // issue de secours |
7fd59977 |
399 | valdiv = vtab[k-je]; |
400 | je = k; |
401 | } |
402 | |
403 | je --; |
404 | // val = 0.; mis a la creation |
405 | for (i = 0; i < jj; i ++) { |
406 | je -= 9; |
407 | const int& chif = chiffre[i]; |
408 | if (chif != 0) val += vtab[chif+je]; |
409 | } |
410 | if (valdiv != 1.) val = val/valdiv; |
411 | if (moins) val = -val; |
412 | return val; |
413 | } |