Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // | |
3 | // The content of this file is subject to the Open CASCADE Technology Public | |
4 | // License Version 6.5 (the "License"). You may not use the content of this file | |
5 | // except in compliance with the License. Please obtain a copy of the License | |
6 | // at http://www.opencascade.org and read it completely before using this file. | |
7 | // | |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
10 | // | |
11 | // The Original Code and all software distributed under the License is | |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
13 | // Initial Developer hereby disclaims all such warranties, including without | |
14 | // limitation, any warranties of merchantability, fitness for a particular | |
15 | // purpose or non-infringement. Please see the License for the specific terms | |
16 | // and conditions governing the rights and limitations under the License. | |
17 | ||
7fd59977 | 18 | //#52 rln 06.01.99 writing value 1.e-07 |
19 | //gka 19.01.99 changing size of ParamSet | |
20 | //#65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000 and YYYYMMDD.HHMMSS after Y2000) | |
21 | //#66 rln Setting IGES 5.3 by default | |
22 | //#73 rln 10.03.99 S4135: "read.scale.unit" is applied after translation | |
23 | #include <IGESData_GlobalSection.ixx> | |
24 | #include <Interface_ParamType.hxx> | |
25 | #include <Interface_FloatWriter.hxx> | |
26 | #include <Interface_FileReaderData.hxx> | |
27 | #include <Interface_FileParameter.hxx> | |
28 | #include <OSD_Process.hxx> | |
29 | #include <Quantity_Date.hxx> | |
30 | #include <Interface_Static.hxx> | |
31 | #include <IGESData_BasicEditor.hxx> | |
32 | #include <stdio.h> | |
33 | ||
34 | // MGE 21/07/98 | |
35 | #include <Message_Msg.hxx> | |
36 | ||
37 | #include <UnitsMethods.hxx> | |
38 | ||
39 | // valeurs en MILLIMETRE pardefaut, reajustable | |
40 | //static Standard_Real convunit = 1000.; | |
41 | ||
42 | ||
43 | // Routines locales copiant une string [l`ideal serait : astr = astr->Copy()] | |
44 | // et transformant un CString (Hollerith ou non) en HAsciiString non Holl. | |
45 | // et l inverse | |
46 | ||
47 | ||
48 | static void CopyString (Handle(TCollection_HAsciiString)& astr); | |
49 | ||
50 | static void MakeHollerith(const Handle(TCollection_HAsciiString)& astr, | |
51 | char* text, Standard_Integer& lt); | |
52 | ||
53 | void CopyString (Handle(TCollection_HAsciiString)& astr) | |
54 | { | |
55 | if (astr.IsNull()) return; // ne rien faire si String pas definie ! | |
56 | Handle(TCollection_HAsciiString) S = new TCollection_HAsciiString(""); | |
57 | S->AssignCat(astr); astr = S; | |
58 | } | |
59 | ||
60 | void MakeHollerith(const Handle(TCollection_HAsciiString)& astr, | |
61 | char* text, Standard_Integer& lt) | |
62 | { | |
63 | lt = 0; text[0] = '\0'; | |
64 | if (astr.IsNull()) return; | |
65 | Standard_Integer ln = astr->Length(); | |
66 | if (ln == 0) return; | |
67 | sprintf (text,"%dH%s",ln,astr->ToCString()); | |
68 | lt = ln+2; if (ln >= 10) lt ++; if (ln >= 100) lt ++; // strlen text | |
69 | } | |
70 | ||
71 | ||
72 | //======================================================================= | |
73 | //function : IGESData_GlobalSection | |
74 | //purpose : | |
75 | //======================================================================= | |
76 | ||
77 | IGESData_GlobalSection::IGESData_GlobalSection () | |
78 | { | |
79 | // convunit = 1000.; | |
80 | //#73 rln 10.03.99 S4135: "read.scale.unit" is applied after translation | |
81 | //if (Interface_Static::IVal("read.scale.unit") == 1) convunit = 1; | |
82 | } | |
83 | ||
84 | ||
85 | // pourrait etre une methode generale au package en fait | |
86 | //======================================================================= | |
87 | //function : TranslatedFromHollerith | |
88 | //purpose : | |
89 | //======================================================================= | |
90 | ||
91 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::TranslatedFromHollerith | |
92 | (const Handle(TCollection_HAsciiString)& astr) const | |
93 | { | |
94 | Handle(TCollection_HAsciiString) res; | |
95 | if (astr.IsNull()) return res; | |
96 | Standard_Integer n = astr->Search("H"); | |
97 | if (n > 1) { | |
98 | if (!astr->Token("H")->IsIntegerValue()) n = 0; | |
99 | } | |
100 | if (n > 1 && n < astr->Length()) res = astr->SubString(n+1,astr->Length()); | |
101 | else if(astr->ToCString()== NULL) | |
102 | res = new TCollection_HAsciiString; | |
103 | else res = new TCollection_HAsciiString(astr->ToCString()); | |
104 | return res; | |
105 | } | |
106 | ||
107 | ||
108 | //======================================================================= | |
109 | //function : Init | |
110 | //purpose : | |
111 | //======================================================================= | |
112 | ||
113 | void IGESData_GlobalSection::Init(const Handle(Interface_ParamSet)& params, | |
114 | Handle(Interface_Check)& ach) | |
115 | { | |
116 | // MGE 21/07/98 | |
117 | // Building of messages | |
118 | //====================================== | |
119 | //Message_Msg Msg39 ("XSTEP_39"); | |
120 | //Message_Msg Msg48 ("XSTEP_48"); | |
121 | //Message_Msg Msg49 ("XSTEP_49"); | |
122 | //====================================== | |
123 | ||
124 | theSeparator = ','; theEndMark = ';'; | |
125 | theSendName.Nullify(); theFileName.Nullify(); theSystemId.Nullify(); | |
126 | theInterfaceVersion.Nullify(); | |
127 | theIntegerBits = 32; // par defaut, simple = entier = 32b, double = 64 | |
128 | theMaxPower10Single = 38; theMaxDigitsSingle = 6; | |
129 | theMaxPower10Double = 308; theMaxDigitsDouble = 15; | |
130 | theReceiveName.Nullify(); | |
131 | theScale = 1.0; | |
132 | theUnitFlag = 0; theUnitName.Nullify(); | |
133 | theLineWeightGrad = 1; theMaxLineWeight = 0.; | |
134 | theDate.Nullify(); | |
135 | theResolution = 0.; theMaxCoord = 0.; hasMaxCoord = Standard_False; | |
136 | theAuthorName.Nullify(); theCompanyName.Nullify(); | |
137 | theIGESVersion = 11;//3 //#66 rln Setting IGES 5.3 by default(To avoid misleading fails below) | |
138 | theDraftingStandard = 0; | |
139 | theLastChangeDate.Nullify(); // nouveaute 5.1 (peut etre absente) | |
140 | theAppliProtocol.Nullify(); // nouveaute 5.3 (peut etre absente) | |
141 | ||
142 | Standard_Integer nbp = params->NbParams(); | |
143 | ||
7fd59977 | 144 | for (Standard_Integer i = 1; i <= nbp; i ++) { |
145 | Standard_Integer intval = 0; Standard_Real realval = 0.0; | |
146 | Handle(TCollection_HAsciiString) strval; // doit repartir a null | |
147 | //char message[80]; //szv#4:S4163:12Mar99 unused | |
148 | Standard_CString val = params->Param(i).CValue(); | |
149 | Interface_ParamType fpt = params->Param(i).ParamType(); | |
150 | if (fpt == Interface_ParamVoid) continue; | |
151 | ||
152 | // if the param is an Integer | |
153 | if (fpt == Interface_ParamInteger) { | |
154 | // but a real is expected | |
155 | if ( i == 13 || i == 17 || i == 19 || i == 20) | |
91322f44 | 156 | realval = Atof(val); |
7fd59977 | 157 | intval = atoi(val); |
158 | } | |
159 | ||
160 | // if the param is a Real | |
161 | else if (fpt == Interface_ParamReal || fpt == Interface_ParamEnum) { | |
162 | char text[50]; | |
163 | Standard_Integer k , j = 0; | |
164 | for (k = 0; k < 50; k ++) { | |
165 | if (val[k] == 'D' || val[k] == 'd') | |
166 | text[j++] = 'e'; | |
167 | else | |
168 | text[j++] = val[k]; | |
169 | if (val[k] == '\0') break; | |
170 | } | |
91322f44 | 171 | realval = Atof(text); |
7fd59977 | 172 | } |
173 | ||
174 | // if the param is a text | |
175 | else if (fpt == Interface_ParamText) { | |
176 | strval = new TCollection_HAsciiString (val); | |
177 | if (val[0] != '\0') { | |
178 | Standard_Integer nhol = strval->Search("H"); | |
179 | Standard_Integer lhol = strval->Length(); | |
180 | if (nhol > 1) | |
181 | if (!strval->Token("H")->IsIntegerValue()) nhol = 0; | |
182 | if (nhol > 1 && nhol < lhol) | |
183 | strval = strval->SubString(nhol+1,lhol); | |
184 | } | |
185 | } | |
186 | ||
187 | char sepend = '\0'; | |
188 | if (i < 3) { | |
189 | if (val[0] != '\0') sepend = val[0]; | |
190 | if (val[1] == 'H') sepend = val[2]; // prioritaire | |
191 | } | |
192 | ||
193 | switch (i) | |
194 | { | |
195 | case 1 : if (sepend != '\0') theSeparator = sepend; break; | |
196 | case 2 : if (sepend != '\0') theEndMark = sepend; break; | |
197 | case 3 : theSendName = strval; break; | |
198 | case 4 : theFileName = strval; break; | |
199 | case 5 : theSystemId = strval; break; | |
200 | case 6 : theInterfaceVersion = strval; break; | |
201 | case 7 : theIntegerBits = intval; break; | |
202 | case 8 : theMaxPower10Single = intval; break; | |
203 | case 9 : theMaxDigitsSingle = intval; break; | |
204 | case 10 : theMaxPower10Double = intval; break; | |
205 | case 11 : theMaxDigitsDouble = intval; break; | |
206 | case 12 : theReceiveName = strval; break; | |
207 | case 13 : theScale = realval; break; | |
208 | case 14 : theUnitFlag = intval; break; | |
209 | case 15 : theUnitName = strval; break; | |
210 | case 16 : theLineWeightGrad = intval; break; | |
211 | case 17 : theMaxLineWeight = realval; break; | |
212 | case 18 : theDate = strval; break; | |
213 | case 19 : theResolution = realval; break; | |
214 | case 20 : theMaxCoord = realval; | |
215 | hasMaxCoord = Standard_True; break; | |
216 | case 21 : theAuthorName = strval; break; | |
217 | case 22 : theCompanyName = strval; break; | |
218 | case 23 : theIGESVersion = intval; break; | |
219 | case 24 : theDraftingStandard = intval; break; | |
220 | case 25 : theLastChangeDate = strval; break; | |
221 | case 26 : theAppliProtocol = strval; break; | |
222 | default : break; | |
223 | } | |
224 | } | |
44d9ae89 A |
225 | |
226 | // Sending of message : Incorrect number of parameters (following the IGES version) | |
227 | // Version less than 5.3 | |
228 | if (theIGESVersion < 11) | |
229 | { | |
230 | if ((nbp < 24) || (nbp > 25)) { | |
231 | // 24 or 25 parameters are expected (parameter 25 is not required) | |
232 | Message_Msg Msg39 ("XSTEP_39"); | |
233 | Msg39.Arg(24); | |
234 | Msg39.Arg(25); | |
235 | if (nbp < 24) ach->SendFail(Msg39); | |
236 | else ach->SendWarning(Msg39); | |
237 | } | |
238 | } | |
239 | // Version 5.3 | |
240 | else if ((nbp < 25) || (nbp > 26)) { | |
241 | // 25 or 26 parameters are expected (parameter 25 is not required) | |
242 | Message_Msg Msg39 ("XSTEP_39"); | |
243 | Msg39.Arg(25); | |
244 | Msg39.Arg(26); | |
245 | if (nbp < 25) ach->SendFail(Msg39); | |
246 | else ach->SendWarning(Msg39); | |
247 | } | |
7fd59977 | 248 | |
249 | //:45 by abv 11.12.97: if UnitFlag is not defined in the file, | |
250 | // restore it from UnitName. Repris par CKY 13-FEV-1998 | |
251 | if ( theUnitFlag == 0 || theUnitFlag == 3 ) { | |
252 | Standard_Integer corrected = 0 ; | |
253 | if(theUnitName.IsNull()) | |
254 | //default (inches) value taken | |
255 | corrected = 1; | |
256 | else | |
257 | corrected = IGESData_BasicEditor::UnitNameFlag (theUnitName->ToCString()); | |
258 | if (corrected > 0) theUnitFlag = corrected; | |
259 | else if (theUnitFlag == 3) { | |
260 | Message_Msg Msg49 ("XSTEP_49"); | |
261 | ach->SendWarning (Msg49); | |
262 | } | |
263 | else { | |
264 | Message_Msg Msg48 ("XSTEP_48"); | |
265 | ach->SendFail (Msg48); | |
266 | } | |
267 | } | |
268 | } | |
269 | ||
270 | ||
271 | //======================================================================= | |
272 | //function : CopyRefs | |
273 | //purpose : | |
274 | //======================================================================= | |
275 | ||
276 | void IGESData_GlobalSection::CopyRefs () | |
277 | { | |
278 | CopyString(theSendName); CopyString(theFileName); CopyString(theSystemId); | |
279 | CopyString(theInterfaceVersion); CopyString(theReceiveName); | |
280 | CopyString(theUnitName); CopyString(theDate); | |
281 | CopyString(theAuthorName); CopyString(theCompanyName); | |
282 | CopyString(theLastChangeDate); CopyString(theAppliProtocol); | |
283 | } | |
284 | ||
285 | ||
286 | //======================================================================= | |
287 | //function : Params | |
288 | //purpose : | |
289 | //======================================================================= | |
290 | ||
291 | Handle(Interface_ParamSet) IGESData_GlobalSection::Params () const | |
292 | { | |
293 | char vide[1]; char uncar[2]; char nombre[20]; char text[200]; | |
294 | Standard_Integer lt; | |
295 | vide[0] = uncar[1] = '\0'; uncar[0] = ','; | |
296 | Handle(Interface_ParamSet) res = new Interface_ParamSet(26); //gka 19.01.99 | |
297 | if (theSeparator == ',') res->Append (vide,0,Interface_ParamVoid,0); | |
298 | else { uncar[0] = theSeparator; res->Append (uncar,1,Interface_ParamMisc,0); } | |
299 | ||
300 | if (theEndMark == ';') res->Append (vide,0,Interface_ParamVoid,0); | |
301 | else { uncar[0] = theEndMark; res->Append (uncar,1,Interface_ParamMisc,0); } | |
302 | ||
303 | MakeHollerith (theSendName,text,lt); | |
304 | res->Append (text,lt, Interface_ParamText,0); | |
305 | ||
306 | MakeHollerith (theFileName,text,lt); | |
307 | res->Append (text,lt, Interface_ParamText,0); | |
308 | ||
309 | MakeHollerith (theSystemId,text,lt); | |
310 | res->Append (text,lt, Interface_ParamText,0); | |
311 | ||
312 | MakeHollerith (theInterfaceVersion,text,lt); | |
313 | res->Append (text,lt, Interface_ParamText,0); | |
314 | ||
315 | sprintf(nombre,"%d",theIntegerBits); | |
316 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
317 | ||
318 | sprintf(nombre,"%d",theMaxPower10Single); | |
319 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
320 | ||
321 | sprintf(nombre,"%d",theMaxDigitsSingle); | |
322 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
323 | ||
324 | sprintf(nombre,"%d",theMaxPower10Double); | |
325 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
326 | ||
327 | sprintf(nombre,"%d",theMaxDigitsDouble); | |
328 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
329 | ||
330 | MakeHollerith (theReceiveName,text,lt); | |
331 | res->Append (text,lt, Interface_ParamText,0); | |
332 | ||
333 | Interface_FloatWriter::Convert (theScale,nombre,Standard_True,0.,0.,"%f","%f"); | |
334 | // sprintf(nombre,"%f",theScale); | |
335 | res->Append (nombre,strlen(nombre),Interface_ParamReal,0); | |
336 | ||
337 | sprintf(nombre,"%d",theUnitFlag); | |
338 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
339 | ||
340 | MakeHollerith (theUnitName,text,lt); | |
341 | res->Append (text,lt, Interface_ParamText,0); | |
342 | ||
343 | sprintf(nombre,"%d",theLineWeightGrad); | |
344 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
345 | ||
346 | Interface_FloatWriter::Convert (theMaxLineWeight,nombre,Standard_True,0.,0.,"%f","%f"); | |
347 | // sprintf(nombre,"%f",theMaxLineWeight); | |
348 | res->Append (nombre,strlen(nombre),Interface_ParamReal,0); | |
349 | ||
350 | MakeHollerith (theDate,text,lt); | |
351 | res->Append (text,lt, Interface_ParamText,0); | |
352 | ||
353 | Interface_FloatWriter::Convert (theResolution,nombre,Standard_True,0.,0.,"%g","%g"); | |
354 | // sprintf(nombre,"%f",theResolution); | |
355 | res->Append (nombre,strlen(nombre),Interface_ParamReal,0); | |
356 | ||
357 | if (hasMaxCoord) | |
358 | Interface_FloatWriter::Convert (theMaxCoord,nombre,Standard_True,0.,0.,"%f","%f"); | |
359 | // sprintf(nombre,"%f",theMaxCoord); | |
360 | else nombre[0] = '\0'; | |
361 | res->Append (nombre,strlen(nombre),Interface_ParamReal,0); | |
362 | ||
363 | MakeHollerith (theAuthorName,text,lt); | |
364 | res->Append (text,lt, Interface_ParamText,0); | |
365 | ||
366 | MakeHollerith (theCompanyName,text,lt); | |
367 | res->Append (text,lt, Interface_ParamText,0); | |
368 | ||
369 | sprintf(nombre,"%d",theIGESVersion); | |
370 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
371 | ||
372 | sprintf(nombre,"%d",theDraftingStandard); | |
373 | res->Append (nombre,strlen(nombre),Interface_ParamInteger,0); | |
374 | ||
375 | if (!theLastChangeDate.IsNull()) { | |
376 | MakeHollerith (theLastChangeDate,text,lt); | |
377 | res->Append (text,lt, Interface_ParamText,0); | |
378 | } | |
379 | ||
380 | if (!theAppliProtocol.IsNull()) { | |
381 | MakeHollerith (theAppliProtocol,text,lt); | |
382 | res->Append (text,lt, Interface_ParamText,0); | |
383 | } | |
384 | // Ici : parametre absent ignore | |
385 | ||
386 | return res; | |
387 | } | |
388 | ||
389 | ||
390 | // ############### QUERIES ############### | |
391 | ||
392 | ||
393 | //======================================================================= | |
394 | //function : Separator | |
395 | //purpose : | |
396 | //======================================================================= | |
397 | ||
398 | Standard_Character IGESData_GlobalSection::Separator () const | |
399 | { | |
400 | return theSeparator; | |
401 | } | |
402 | ||
403 | ||
404 | //======================================================================= | |
405 | //function : EndMark | |
406 | //purpose : | |
407 | //======================================================================= | |
408 | ||
409 | Standard_Character IGESData_GlobalSection::EndMark () const | |
410 | { | |
411 | return theEndMark; | |
412 | } | |
413 | ||
414 | ||
415 | //======================================================================= | |
416 | //function : SendName | |
417 | //purpose : | |
418 | //======================================================================= | |
419 | ||
420 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::SendName () const | |
421 | { | |
422 | return theSendName; | |
423 | } | |
424 | ||
425 | ||
426 | //======================================================================= | |
427 | //function : FileName | |
428 | //purpose : | |
429 | //======================================================================= | |
430 | ||
431 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::FileName () const | |
432 | { | |
433 | return theFileName; | |
434 | } | |
435 | ||
436 | ||
437 | //======================================================================= | |
438 | //function : SystemId | |
439 | //purpose : | |
440 | //======================================================================= | |
441 | ||
442 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::SystemId () const | |
443 | { | |
444 | return theSystemId; | |
445 | } | |
446 | ||
447 | ||
448 | //======================================================================= | |
449 | //function : InterfaceVersion | |
450 | //purpose : | |
451 | //======================================================================= | |
452 | ||
453 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::InterfaceVersion () const | |
454 | { | |
455 | return theInterfaceVersion; | |
456 | } | |
457 | ||
458 | ||
459 | //======================================================================= | |
460 | //function : IntegerBits | |
461 | //purpose : | |
462 | //======================================================================= | |
463 | ||
464 | Standard_Integer IGESData_GlobalSection::IntegerBits () const | |
465 | { | |
466 | return theIntegerBits; | |
467 | } | |
468 | ||
469 | ||
470 | //======================================================================= | |
471 | //function : MaxPower10Single | |
472 | //purpose : | |
473 | //======================================================================= | |
474 | ||
475 | Standard_Integer IGESData_GlobalSection::MaxPower10Single () const | |
476 | { | |
477 | return theMaxPower10Single; | |
478 | } | |
479 | ||
480 | ||
481 | //======================================================================= | |
482 | //function : MaxDigitsSingle | |
483 | //purpose : | |
484 | //======================================================================= | |
485 | ||
486 | Standard_Integer IGESData_GlobalSection::MaxDigitsSingle () const | |
487 | { | |
488 | return theMaxDigitsSingle; | |
489 | } | |
490 | ||
491 | ||
492 | //======================================================================= | |
493 | //function : MaxPower10Double | |
494 | //purpose : | |
495 | //======================================================================= | |
496 | ||
497 | Standard_Integer IGESData_GlobalSection::MaxPower10Double () const | |
498 | { | |
499 | return theMaxPower10Double; | |
500 | } | |
501 | ||
502 | ||
503 | //======================================================================= | |
504 | //function : MaxDigitsDouble | |
505 | //purpose : | |
506 | //======================================================================= | |
507 | ||
508 | Standard_Integer IGESData_GlobalSection::MaxDigitsDouble () const | |
509 | { | |
510 | return theMaxDigitsDouble; | |
511 | } | |
512 | ||
513 | ||
514 | //======================================================================= | |
515 | //function : ReceiveName | |
516 | //purpose : | |
517 | //======================================================================= | |
518 | ||
519 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::ReceiveName () const | |
520 | { | |
521 | return theReceiveName; | |
522 | } | |
523 | ||
524 | ||
525 | //======================================================================= | |
526 | //function : Scale | |
527 | //purpose : | |
528 | //======================================================================= | |
529 | ||
530 | Standard_Real IGESData_GlobalSection::Scale () const | |
531 | { | |
532 | return theScale; | |
533 | } | |
534 | ||
535 | ||
536 | //======================================================================= | |
537 | //function : UnitFlag | |
538 | //purpose : | |
539 | //======================================================================= | |
540 | ||
541 | Standard_Integer IGESData_GlobalSection::UnitFlag () const | |
542 | { | |
543 | return theUnitFlag; | |
544 | } | |
545 | ||
546 | ||
547 | //======================================================================= | |
548 | //function : UnitName | |
549 | //purpose : | |
550 | //======================================================================= | |
551 | ||
552 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::UnitName () const | |
553 | { | |
554 | return theUnitName; | |
555 | } | |
556 | ||
557 | ||
558 | //======================================================================= | |
559 | //function : LineWeightGrad | |
560 | //purpose : | |
561 | //======================================================================= | |
562 | ||
563 | Standard_Integer IGESData_GlobalSection::LineWeightGrad () const | |
564 | { | |
565 | return theLineWeightGrad; | |
566 | } | |
567 | ||
568 | ||
569 | //======================================================================= | |
570 | //function : MaxLineWeight | |
571 | //purpose : | |
572 | //======================================================================= | |
573 | ||
574 | Standard_Real IGESData_GlobalSection::MaxLineWeight () const | |
575 | { | |
576 | return theMaxLineWeight; | |
577 | } | |
578 | ||
579 | ||
580 | //======================================================================= | |
581 | //function : Date | |
582 | //purpose : | |
583 | //======================================================================= | |
584 | ||
585 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::Date () const | |
586 | { | |
587 | return theDate; | |
588 | } | |
589 | ||
590 | ||
591 | //======================================================================= | |
592 | //function : Resolution | |
593 | //purpose : | |
594 | //======================================================================= | |
595 | ||
596 | Standard_Real IGESData_GlobalSection::Resolution () const | |
597 | { | |
598 | return theResolution; | |
599 | } | |
600 | ||
601 | ||
602 | //======================================================================= | |
603 | //function : MaxCoord | |
604 | //purpose : | |
605 | //======================================================================= | |
606 | ||
607 | Standard_Real IGESData_GlobalSection::MaxCoord () const | |
608 | { | |
609 | return theMaxCoord; | |
610 | } | |
611 | ||
612 | ||
613 | //======================================================================= | |
614 | //function : HasMaxCoord | |
615 | //purpose : | |
616 | //======================================================================= | |
617 | ||
618 | Standard_Boolean IGESData_GlobalSection::HasMaxCoord () const | |
619 | { | |
620 | return hasMaxCoord; | |
621 | } | |
622 | ||
623 | ||
624 | //======================================================================= | |
625 | //function : AuthorName | |
626 | //purpose : | |
627 | //======================================================================= | |
628 | ||
629 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::AuthorName () const | |
630 | { | |
631 | return theAuthorName; | |
632 | } | |
633 | ||
634 | ||
635 | //======================================================================= | |
636 | //function : CompanyName | |
637 | //purpose : | |
638 | //======================================================================= | |
639 | ||
640 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::CompanyName () const | |
641 | { | |
642 | return theCompanyName; | |
643 | } | |
644 | ||
645 | ||
646 | //======================================================================= | |
647 | //function : IGESVersion | |
648 | //purpose : | |
649 | //======================================================================= | |
650 | ||
651 | Standard_Integer IGESData_GlobalSection::IGESVersion () const | |
652 | { | |
653 | return theIGESVersion; | |
654 | } | |
655 | ||
656 | ||
657 | //======================================================================= | |
658 | //function : DraftingStandard | |
659 | //purpose : | |
660 | //======================================================================= | |
661 | ||
662 | Standard_Integer IGESData_GlobalSection::DraftingStandard () const | |
663 | { | |
664 | return theDraftingStandard; | |
665 | } | |
666 | ||
667 | ||
668 | //======================================================================= | |
669 | //function : LastChangeDate | |
670 | //purpose : | |
671 | //======================================================================= | |
672 | ||
673 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::LastChangeDate () const | |
674 | { | |
675 | return theLastChangeDate; | |
676 | } | |
677 | ||
678 | ||
679 | //======================================================================= | |
680 | //function : HasLastChangeDate | |
681 | //purpose : | |
682 | //======================================================================= | |
683 | ||
684 | Standard_Boolean IGESData_GlobalSection::HasLastChangeDate () const | |
685 | { | |
686 | return (!theLastChangeDate.IsNull()); | |
687 | } | |
688 | ||
689 | ||
690 | //======================================================================= | |
691 | //function : SetLastChangeDate | |
692 | //purpose : | |
693 | //======================================================================= | |
694 | ||
695 | void IGESData_GlobalSection::SetLastChangeDate () | |
696 | { | |
697 | if (HasLastChangeDate()) return; | |
698 | Standard_Integer mois,jour,annee,heure,minute,seconde,millisec,microsec; | |
699 | OSD_Process system; | |
700 | Quantity_Date ladate = system.SystemDate(); | |
701 | ladate.Values (mois,jour,annee,heure,minute,seconde,millisec,microsec); | |
702 | if (annee < 2000) | |
703 | //#65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000) | |
704 | theLastChangeDate = NewDateString (annee,mois,jour,heure,minute,seconde,0); | |
705 | else | |
706 | //#65 rln 12.02.99 S4151 (explicitly force YYYYMMDD.HHMMSS after Y2000) | |
707 | theLastChangeDate = NewDateString (annee,mois,jour,heure,minute,seconde, -1); | |
708 | } | |
709 | ||
710 | ||
711 | //======================================================================= | |
712 | //function : HasApplicationProtocol | |
713 | //purpose : | |
714 | //======================================================================= | |
715 | ||
716 | Standard_Boolean IGESData_GlobalSection::HasApplicationProtocol () const | |
717 | { | |
718 | return !theAppliProtocol.IsNull(); | |
719 | } | |
720 | ||
721 | ||
722 | //======================================================================= | |
723 | //function : ApplicationProtocol | |
724 | //purpose : | |
725 | //======================================================================= | |
726 | ||
727 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::ApplicationProtocol () const | |
728 | { | |
729 | return theAppliProtocol; | |
730 | } | |
731 | ||
732 | ||
733 | //======================================================================= | |
734 | //function : NewDateString | |
735 | //purpose : | |
736 | //======================================================================= | |
737 | ||
738 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::NewDateString | |
739 | (const Standard_Integer annee, const Standard_Integer mois, | |
740 | const Standard_Integer jour, const Standard_Integer heure, | |
741 | const Standard_Integer minute, const Standard_Integer seconde, | |
742 | const Standard_Integer mode) | |
743 | { | |
744 | // 0 : IGES annee a l ancienne 00-99 -1 IGES annee complete 1 lisible | |
745 | char madate[60]; | |
746 | Standard_Integer moi = mois , jou = jour , anne = annee; | |
747 | Standard_Integer heur = heure , minut = minute , second = seconde; | |
748 | if (annee == 0) { | |
749 | Standard_Integer millisec,microsec; | |
750 | OSD_Process system; | |
751 | Quantity_Date ladate = system.SystemDate(); | |
752 | ladate.Values (moi,jou,anne,heur,minut,second,millisec,microsec); | |
753 | } | |
754 | if (mode == 0 || mode == -1) { | |
755 | Standard_Integer an = anne % 100; | |
756 | Standard_Boolean dizaine = (an >= 10); | |
757 | if (!dizaine) an += 10; | |
758 | if (mode < 0) { an = anne; dizaine = Standard_True; } | |
759 | Standard_Integer date1 = (an) * 10000 + moi * 100 + jou; | |
760 | Standard_Integer date2 = (heur + 100) * 10000 + minut * 100 + second; | |
761 | sprintf (madate,"%d%d",date1,date2); | |
762 | madate[(mode == 0 ? 6: 8)] = '.'; | |
763 | if (!dizaine) madate[0] = '0'; | |
764 | } else if (mode == 1) { | |
765 | sprintf (madate,"%4.4d-%2.2d-%2.2d:%2.2d-%2.2d-%2.2d", | |
766 | anne,moi,jou,heur,minut,second); | |
767 | } | |
768 | return new TCollection_HAsciiString(madate); | |
769 | } | |
770 | ||
771 | ||
772 | //======================================================================= | |
773 | //function : NewDateString | |
774 | //purpose : | |
775 | //======================================================================= | |
776 | ||
777 | Handle(TCollection_HAsciiString) IGESData_GlobalSection::NewDateString | |
778 | (const Handle(TCollection_HAsciiString)& date, const Standard_Integer mode) | |
779 | { | |
780 | Standard_Integer anne,moi,jou,heur,minut,second; | |
781 | if (date.IsNull()) return date; | |
782 | Standard_Integer i0 = 0; | |
783 | if (date->Length() == 15) i0 = 2; | |
784 | else if (date->Length() != 13) return date; | |
785 | if (date->Value(i0+7) != '.') return date; | |
786 | anne = (date->Value(i0+ 1) - 48) * 10 + (date->Value(i0+ 2) - 48); | |
787 | if (i0 == 0) { | |
788 | anne = anne + 1900; | |
789 | if (anne < 1980) anne += 100; | |
790 | } else { | |
791 | anne = anne + (date->Value(1) - 48) *1000 + (date->Value(2) - 48) * 100; | |
792 | } | |
793 | moi = (date->Value(i0+ 3) - 48) * 10 + (date->Value(i0+ 4) - 48); | |
794 | jou = (date->Value(i0+ 5) - 48) * 10 + (date->Value(i0+ 6) - 48); | |
795 | heur = (date->Value(i0+ 8) - 48) * 10 + (date->Value(i0+ 9) - 48); | |
796 | minut = (date->Value(i0+10) - 48) * 10 + (date->Value(i0+11) - 48); | |
797 | second = (date->Value(i0+12) - 48) * 10 + (date->Value(i0+13) - 48); | |
798 | ||
799 | return IGESData_GlobalSection::NewDateString (anne,moi,jou,heur,minut,second,mode); | |
800 | } | |
801 | ||
802 | ||
803 | //======================================================================= | |
804 | //function : UnitValue | |
805 | //purpose : | |
806 | //======================================================================= | |
807 | ||
808 | Standard_Real IGESData_GlobalSection::UnitValue () const | |
809 | { | |
810 | return UnitsMethods::GetLengthFactorValue ( theUnitFlag ) / | |
811 | UnitsMethods::GetCasCadeLengthUnit(); //abv 22 Feb 00: adding cascade unit factor | |
812 | } | |
813 | ||
814 | ||
815 | // ############### UPDATES ############### | |
816 | ||
817 | void IGESData_GlobalSection::SetSeparator (const Standard_Character val) | |
818 | { theSeparator = val; } | |
819 | ||
820 | void IGESData_GlobalSection::SetEndMark (const Standard_Character val) | |
821 | { theEndMark = val; } | |
822 | ||
823 | void IGESData_GlobalSection::SetSendName (const Handle(TCollection_HAsciiString)& val) | |
824 | { theSendName = TranslatedFromHollerith(val); } | |
825 | ||
826 | void IGESData_GlobalSection::SetFileName (const Handle(TCollection_HAsciiString)& val) | |
827 | { theFileName = TranslatedFromHollerith(val); } | |
828 | ||
829 | void IGESData_GlobalSection::SetSystemId (const Handle(TCollection_HAsciiString)& val) | |
830 | { theSystemId = TranslatedFromHollerith(val); } | |
831 | ||
832 | void IGESData_GlobalSection::SetInterfaceVersion (const Handle(TCollection_HAsciiString)& val) | |
833 | { theInterfaceVersion = TranslatedFromHollerith(val); } | |
834 | ||
835 | void IGESData_GlobalSection::SetIntegerBits (const Standard_Integer val) | |
836 | { theIntegerBits = val; } | |
837 | ||
838 | void IGESData_GlobalSection::SetMaxPower10Single (const Standard_Integer val) | |
839 | { theMaxPower10Single = val; } | |
840 | ||
841 | void IGESData_GlobalSection::SetMaxDigitsSingle (const Standard_Integer val) | |
842 | { theMaxDigitsSingle = val; } | |
843 | ||
844 | void IGESData_GlobalSection::SetMaxPower10Double (const Standard_Integer val) | |
845 | { theMaxPower10Double = val; } | |
846 | ||
847 | void IGESData_GlobalSection::SetMaxDigitsDouble (const Standard_Integer val) | |
848 | { theMaxDigitsDouble = val; } | |
849 | ||
850 | void IGESData_GlobalSection::SetReceiveName (const Handle(TCollection_HAsciiString)& val) | |
851 | { theReceiveName = TranslatedFromHollerith(val); } | |
852 | ||
853 | void IGESData_GlobalSection::SetScale (const Standard_Real val) | |
854 | { theScale = val; } | |
855 | ||
856 | void IGESData_GlobalSection::SetUnitFlag (const Standard_Integer val) | |
857 | { theUnitFlag = val; } | |
858 | ||
859 | void IGESData_GlobalSection::SetUnitName (const Handle(TCollection_HAsciiString)& val) | |
860 | { theUnitName = TranslatedFromHollerith(val); } | |
861 | ||
862 | void IGESData_GlobalSection::SetLineWeightGrad (const Standard_Integer val) | |
863 | { theLineWeightGrad = val; } | |
864 | ||
865 | void IGESData_GlobalSection::SetMaxLineWeight (const Standard_Real val) | |
866 | { theMaxLineWeight = val; } | |
867 | ||
868 | void IGESData_GlobalSection::SetDate (const Handle(TCollection_HAsciiString)& val) | |
869 | { theDate = TranslatedFromHollerith(val); } | |
870 | ||
871 | void IGESData_GlobalSection::SetResolution (const Standard_Real val) | |
872 | { theResolution = val; } | |
873 | ||
874 | void IGESData_GlobalSection::SetMaxCoord (const Standard_Real val) | |
875 | { | |
876 | hasMaxCoord = (val > 0.); | |
877 | theMaxCoord = (hasMaxCoord ? val : 0.); | |
878 | } | |
879 | ||
880 | void IGESData_GlobalSection::MaxMaxCoord (const Standard_Real val) | |
881 | { | |
882 | Standard_Real aval = Abs(val); | |
883 | if (hasMaxCoord) { if (aval > theMaxCoord) theMaxCoord = aval; } | |
884 | else SetMaxCoord (aval); | |
885 | } | |
886 | ||
887 | void IGESData_GlobalSection::MaxMaxCoords (const gp_XYZ& xyz) | |
888 | { MaxMaxCoord (xyz.X()); MaxMaxCoord (xyz.Y()); MaxMaxCoord (xyz.Z()); } | |
889 | ||
890 | ||
891 | void IGESData_GlobalSection::SetAuthorName (const Handle(TCollection_HAsciiString)& val) | |
892 | { theAuthorName = TranslatedFromHollerith(val); } | |
893 | ||
894 | void IGESData_GlobalSection::SetCompanyName (const Handle(TCollection_HAsciiString)& val) | |
895 | { theCompanyName = TranslatedFromHollerith(val); } | |
896 | ||
897 | void IGESData_GlobalSection::SetIGESVersion (const Standard_Integer val) | |
898 | { theIGESVersion = val; } | |
899 | ||
900 | void IGESData_GlobalSection::SetDraftingStandard (const Standard_Integer val) | |
901 | { theDraftingStandard = val; } | |
902 | ||
903 | void IGESData_GlobalSection::SetLastChangeDate (const Handle(TCollection_HAsciiString)& val) | |
904 | { theLastChangeDate = TranslatedFromHollerith(val); } | |
905 | ||
906 | void IGESData_GlobalSection::SetApplicationProtocol (const Handle(TCollection_HAsciiString)& val) | |
907 | { theAppliProtocol = TranslatedFromHollerith(val); } |