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 | //pdn 11.01.99 modification for linking on NT |
15 | //#73 rln 10.03.99 S4135: "read.scale.unit" does not affect GlobalSection |
16 | //#13 smh 13.01.2000 : Parsing long year date |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <IGESData_BasicEditor.hxx> |
42cf5bc1 |
19 | #include <IGESData_GlobalSection.hxx> |
20 | #include <IGESData_IGESEntity.hxx> |
21 | #include <IGESData_IGESModel.hxx> |
22 | #include <IGESData_Protocol.hxx> |
23 | #include <Interface_Check.hxx> |
24 | #include <Interface_InterfaceError.hxx> |
25 | #include <Interface_InterfaceModel.hxx> |
7fd59977 |
26 | #include <Interface_Macros.hxx> |
42cf5bc1 |
27 | #include <Interface_Static.hxx> |
7fd59977 |
28 | #include <Message_Msg.hxx> |
42cf5bc1 |
29 | #include <Standard_Transient.hxx> |
30 | #include <Standard_Type.hxx> |
31 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
32 | |
33 | #include <stdio.h> |
92efcf78 |
34 | IMPLEMENT_STANDARD_RTTIEXT(IGESData_IGESModel,Interface_InterfaceModel) |
35 | |
7fd59977 |
36 | static Standard_CString voidline = ""; |
37 | |
38 | // Routine interne utilisee pour VerifyCheck |
39 | void IGESData_VerifyDate |
40 | (const Handle(TCollection_HAsciiString)& str, |
41 | Handle(Interface_Check)& ach, const Standard_CString mess); |
42 | |
43 | |
44 | |
45 | //======================================================================= |
46 | //function : IGESData_IGESModel |
47 | //purpose : |
48 | //======================================================================= |
49 | |
50 | IGESData_IGESModel::IGESData_IGESModel () |
51 | { |
52 | thestart = new TColStd_HSequenceOfHAsciiString(); |
53 | // thecheckstx = new Interface_Check; |
54 | // thechecksem = new Interface_Check; |
55 | } |
56 | |
57 | |
58 | //======================================================================= |
59 | //function : ClearHeader |
60 | //purpose : |
61 | //======================================================================= |
62 | |
63 | void IGESData_IGESModel::ClearHeader () |
64 | { |
65 | IGESData_GlobalSection newheader; // Un peu brutal, certes |
66 | theheader = newheader; |
67 | thestart = new TColStd_HSequenceOfHAsciiString(); |
68 | } |
69 | |
70 | |
71 | //======================================================================= |
72 | //function : DumpHeader |
73 | //purpose : |
74 | //======================================================================= |
75 | |
76 | void IGESData_IGESModel::DumpHeader |
0ebe5b0a |
77 | (Standard_OStream& S, const Standard_Integer ) const |
7fd59977 |
78 | { |
79 | Standard_Integer ns = thestart->Length(); |
0ebe5b0a |
80 | S <<"**** Dump of IGES Model , Start and Global Sections ****"<<std::endl; |
7fd59977 |
81 | if (ns > 0) { |
586db386 |
82 | S << "**** Start Section : "<<ns<<" Line(s) ****\n"; |
7fd59977 |
83 | for (Standard_Integer i = 1; i <= ns; i ++) |
0ebe5b0a |
84 | S <<"["<<(i<10 ? " ": "")<<i<<"]:"<<thestart->Value(i)->ToCString()<<std::endl; |
7fd59977 |
85 | } |
586db386 |
86 | S << "\n**** Global Section ****\n"; |
7fd59977 |
87 | char sep = theheader.Separator(); |
88 | if (sep == ',') S << "[ 1] Default Separator : " << sep; |
89 | else S << "[ 1] Non Default Separator : " << sep; |
90 | char emk = theheader.EndMark(); |
91 | if (emk == ';') S << " [ 2] Default End Mark : " << emk; |
92 | else S << " [ 2] Non Default End Mark : " << emk; |
0ebe5b0a |
93 | S <<"\n"; |
7fd59977 |
94 | Handle(TCollection_HAsciiString) str; |
95 | str = theheader.SendName(); |
0ebe5b0a |
96 | if (!str.IsNull()) S <<"[ 3] Sender : "<<str->ToCString()<<std::endl; |
7fd59977 |
97 | str = theheader.FileName(); |
0ebe5b0a |
98 | if (!str.IsNull()) S <<"[ 4] (recorded) File Name : "<<str->ToCString()<<std::endl; |
7fd59977 |
99 | str = theheader.SystemId(); |
0ebe5b0a |
100 | if (!str.IsNull()) S <<"[ 5] System Identification : "<<str->ToCString()<<std::endl; |
7fd59977 |
101 | str = theheader.InterfaceVersion(); |
0ebe5b0a |
102 | if (!str.IsNull()) S <<"[ 6] Interface Version : "<<str->ToCString()<<std::endl; |
103 | S <<std::endl; |
7fd59977 |
104 | S << "[ 7] Integer Bits : " << theheader.IntegerBits() |
0ebe5b0a |
105 | << " Features for Reals : " << std::endl; |
7fd59977 |
106 | S << "[ 8] Single Max.Power(10) : " << theheader.MaxPower10Single(); |
107 | S << " [ 9] Digits : " << theheader.MaxDigitsSingle()<<"\n"; |
108 | S << "[10] Double Max.Power(10) : " << theheader.MaxPower10Double(); |
109 | S << " [11] Digits : " << theheader.MaxDigitsDouble() << "\n\n"; |
110 | str = theheader.ReceiveName(); |
0ebe5b0a |
111 | if (!str.IsNull()) S <<"[12] Receiver : "<<str->ToCString()<<"\n"; |
7fd59977 |
112 | S << "[13] Scale : " << theheader.Scale()<<"\n"; |
113 | S << "[14] Unit Flag : " << theheader.UnitFlag(); |
114 | // if (Interface_Static::IVal("read.scale.unit") == 1) |
115 | //#73 rln 10.03.99 S4135: "read.scale.unit" does not affect GlobalSection |
0ebe5b0a |
116 | // S << " -> Value (in Meter) = " << theheader.UnitValue() / 1000 <<"\n"; |
7fd59977 |
117 | // else S << " -> Value (in Millimeter) = " << theheader.UnitValue()<<"\n"; |
118 | //abv 02 Mar 00: no unit parameter in OCC |
119 | S << " -> Value (in CASCADE units) = " << theheader.UnitValue() <<"\n"; |
120 | |
121 | str = theheader.UnitName(); |
0ebe5b0a |
122 | if (!str.IsNull()) S <<"[15] Unit Name : " << str->ToCString()<<"\n\n"; |
7fd59977 |
123 | S << "[16] Line Weight Gradient : " << theheader.LineWeightGrad()<<"\n"; |
124 | S << "[17] Line Weight Max Value: " << theheader.MaxLineWeight()<<"\n"; |
125 | |
126 | str = theheader.Date(); |
0ebe5b0a |
127 | if (!str.IsNull()) S <<"[18] (Creation) Date : "<<str->ToCString() |
7fd59977 |
128 | <<" i.e. "<<IGESData_GlobalSection::NewDateString(str,1)->ToCString()<<"\n"; |
129 | S << "[19] Resolution : " << theheader.Resolution()<<"\n"; |
130 | if (theheader.HasMaxCoord()) |
0ebe5b0a |
131 | S <<"[20] Maximum Coord : " << theheader.MaxCoord() << "\n\n"; |
132 | else S <<"[20] Maximum Coord not defined\n\n"; |
7fd59977 |
133 | |
134 | str = theheader.AuthorName(); |
0ebe5b0a |
135 | if (!str.IsNull()) S <<"[21] Author : "<<str->ToCString()<<"\n"; |
7fd59977 |
136 | str = theheader.CompanyName(); |
0ebe5b0a |
137 | if (!str.IsNull()) S <<"[22] Company : "<<str->ToCString()<<"\n"; |
7fd59977 |
138 | Standard_Integer num = theheader.IGESVersion(); |
139 | S << "[23] IGES Version Number : " << num << " -> Name : " |
140 | << IGESData_BasicEditor::IGESVersionName(num); |
141 | |
142 | num = theheader.DraftingStandard(); |
586db386 |
143 | S << "\n[24] Drafting Standard : " << num; |
0ebe5b0a |
144 | if (num > 0) S << " -> Name : " << IGESData_BasicEditor::DraftingName(num); |
145 | S <<std::endl; |
7fd59977 |
146 | |
147 | if (theheader.HasLastChangeDate()) { |
148 | str = theheader.LastChangeDate(); |
149 | S << "[25] Last Change Date : " << str->ToCString() |
0ebe5b0a |
150 | <<" i.e. "<<IGESData_GlobalSection::NewDateString(str,1)->ToCString()<<std::endl; |
7fd59977 |
151 | } |
0ebe5b0a |
152 | else S <<"[25] Last Change Date not defined (version IGES < 5.1)" << std::endl; |
7fd59977 |
153 | |
154 | if (theheader.HasApplicationProtocol()) { |
155 | str = theheader.ApplicationProtocol(); |
0ebe5b0a |
156 | S << "[26] Application Protocol : " << str->ToCString() <<std::endl; |
7fd59977 |
157 | } |
158 | |
0ebe5b0a |
159 | S << " **** End of Dump ****"<<std::endl; |
7fd59977 |
160 | } |
161 | |
162 | |
163 | //======================================================================= |
164 | //function : StartSection |
165 | //purpose : |
166 | //======================================================================= |
167 | |
168 | Handle(TColStd_HSequenceOfHAsciiString) IGESData_IGESModel::StartSection |
169 | () const |
170 | { return thestart; } |
171 | |
172 | |
173 | //======================================================================= |
174 | //function : NbStartLines |
175 | //purpose : |
176 | //======================================================================= |
177 | |
178 | Standard_Integer IGESData_IGESModel::NbStartLines () const |
179 | { return thestart->Length(); } |
180 | |
181 | |
182 | //======================================================================= |
183 | //function : StartLine |
184 | //purpose : |
185 | //======================================================================= |
186 | |
187 | Standard_CString IGESData_IGESModel::StartLine |
188 | (const Standard_Integer num) const |
189 | { |
190 | if (num > 0 && num <= thestart->Length()) return |
191 | thestart->Value(num)->ToCString(); |
192 | return voidline; |
193 | } |
194 | |
195 | |
196 | //======================================================================= |
197 | //function : ClearStartSection |
198 | //purpose : |
199 | //======================================================================= |
200 | |
201 | void IGESData_IGESModel::ClearStartSection () |
202 | { thestart->Clear(); } |
203 | |
204 | void IGESData_IGESModel::SetStartSection |
205 | (const Handle(TColStd_HSequenceOfHAsciiString)& list, |
206 | const Standard_Boolean copy) |
207 | { |
208 | if (copy) { |
209 | thestart = new TColStd_HSequenceOfHAsciiString(); |
210 | if (list.IsNull()) return; |
211 | Standard_Integer i, nb = list->Length(); |
212 | for (i = 1; i <= nb; i ++) thestart->Append |
213 | (new TCollection_HAsciiString(list->Value(i)->ToCString())); |
214 | } |
215 | else if (list.IsNull()) thestart = new TColStd_HSequenceOfHAsciiString(); |
216 | else thestart = list; |
217 | } |
218 | |
219 | |
220 | //======================================================================= |
221 | //function : AddStartLine |
222 | //purpose : |
223 | //======================================================================= |
224 | |
225 | void IGESData_IGESModel::AddStartLine |
226 | (const Standard_CString line, const Standard_Integer atnum) |
227 | { |
228 | if (atnum <= 0 || atnum > thestart->Length()) |
229 | thestart->Append (new TCollection_HAsciiString(line)); |
230 | else thestart->InsertBefore (atnum,new TCollection_HAsciiString(line)); |
231 | } |
232 | |
233 | |
234 | |
235 | //======================================================================= |
236 | //function : GlobalSection |
237 | //purpose : |
238 | //======================================================================= |
239 | |
240 | const IGESData_GlobalSection& IGESData_IGESModel::GlobalSection () const |
241 | { return theheader; } |
242 | |
243 | |
244 | //======================================================================= |
245 | //function : SetGlobalSection |
246 | //purpose : |
247 | //======================================================================= |
248 | |
249 | void IGESData_IGESModel::SetGlobalSection |
250 | (const IGESData_GlobalSection& header) |
251 | { theheader = header; } |
252 | |
253 | |
254 | //======================================================================= |
255 | //function : ApplyStatic |
256 | //purpose : |
257 | //======================================================================= |
258 | |
259 | Standard_Boolean IGESData_IGESModel::ApplyStatic |
260 | (const Standard_CString param) |
261 | { |
262 | if (param[0] == '\0') { |
263 | //Standard_Boolean ret = Standard_True; //szv#4:S4163:12Mar99 not needed |
264 | ApplyStatic("receiver"); //szv#4:S4163:12Mar99 'ret =' not needed |
265 | ApplyStatic("author"); //szv#4:S4163:12Mar99 'ret =' not needed |
266 | ApplyStatic("company"); //szv#4:S4163:12Mar99 'ret =' not needed |
267 | return Standard_True; |
268 | } |
269 | |
270 | Standard_CString val; |
271 | if (param[0] == 'r') { |
272 | val = Interface_Static::CVal("write.iges.header.receiver"); |
273 | if (!val || val[0] == '\0') return Standard_False; |
274 | theheader.SetReceiveName (new TCollection_HAsciiString(val)); |
275 | } |
276 | if (param[0] == 'a') { |
277 | val = Interface_Static::CVal("write.iges.header.author"); |
278 | if (!val || val[0] == '\0') return Standard_False; |
279 | theheader.SetAuthorName (new TCollection_HAsciiString(val)); |
280 | } |
281 | if (param[0] == 'c') { |
282 | val = Interface_Static::CVal("write.iges.header.company"); |
283 | if (!val || val[0] == '\0') return Standard_False; |
284 | theheader.SetCompanyName (new TCollection_HAsciiString(val)); |
285 | } |
286 | return Standard_True; |
287 | } |
288 | |
289 | |
290 | //======================================================================= |
291 | //function : Entity |
292 | //purpose : |
293 | //======================================================================= |
294 | |
295 | Handle(IGESData_IGESEntity) IGESData_IGESModel::Entity |
296 | (const Standard_Integer num) const |
297 | { return GetCasted(IGESData_IGESEntity,Value(num)); } |
298 | |
299 | |
300 | //======================================================================= |
301 | //function : DNum |
302 | //purpose : |
303 | //======================================================================= |
304 | |
305 | Standard_Integer IGESData_IGESModel::DNum |
306 | (const Handle(IGESData_IGESEntity)& ent) const |
307 | { |
308 | Standard_Integer num = Number(ent); |
309 | if (num == 0) return 0; |
310 | else return 2*num-1; |
311 | } |
312 | |
313 | |
314 | //======================================================================= |
315 | //function : GetFromAnother |
316 | //purpose : |
317 | //======================================================================= |
318 | |
319 | void IGESData_IGESModel::GetFromAnother |
320 | (const Handle(Interface_InterfaceModel)& other) |
321 | { |
322 | DeclareAndCast(IGESData_IGESModel,another,other); |
323 | theheader = another->GlobalSection(); |
324 | theheader.CopyRefs(); |
325 | SetStartSection (another->StartSection(),Standard_True); |
326 | } |
327 | |
328 | |
329 | //======================================================================= |
330 | //function : NewEmptyModel |
331 | //purpose : |
332 | //======================================================================= |
333 | |
334 | Handle(Interface_InterfaceModel) IGESData_IGESModel::NewEmptyModel () const |
335 | { return new IGESData_IGESModel; } |
336 | |
337 | |
338 | //======================================================================= |
339 | //function : VerifyCheck |
340 | //purpose : |
341 | //======================================================================= |
342 | |
343 | void IGESData_IGESModel::VerifyCheck (Handle(Interface_Check)& ach) const |
344 | { |
345 | // MGE 23/07/98 |
346 | // ===================================== |
347 | //Message_Msg Msg40 ("XSTEP_40"); |
348 | //Message_Msg Msg41 ("XSTEP_41"); |
349 | //Message_Msg Msg42 ("XSTEP_42"); |
350 | //Message_Msg Msg43 ("XSTEP_43"); |
351 | //Message_Msg Msg44 ("XSTEP_44"); |
352 | //Message_Msg Msg45 ("XSTEP_45"); |
353 | //Message_Msg Msg46 ("XSTEP_46"); |
354 | //Message_Msg Msg47 ("XSTEP_47"); |
355 | //Message_Msg Msg48 ("XSTEP_48"); |
356 | //Message_Msg Msg50 ("XSTEP_50"); |
357 | //Message_Msg Msg51 ("XSTEP_51"); |
358 | //Message_Msg Msg52 ("XSTEP_52"); |
359 | //Message_Msg Msg53 ("XSTEP_53"); |
360 | //Message_Msg Msg54 ("XSTEP_54"); |
361 | //Message_Msg Msg55 ("XSTEP_55"); |
362 | // ===================================== |
363 | |
364 | char del[2]; |
365 | del[0] = theheader.Separator(); |
366 | del[1] = theheader.EndMark(); |
367 | // Sending of message : Parameter Delimiter Character and Record Delimiter Character must be different. |
368 | if (del[0] == del[1]) { |
369 | Message_Msg Msg40 ("XSTEP_40"); |
370 | ach->SendFail(Msg40); |
371 | } |
372 | for (int i = 0; i <= 1; i ++) { |
373 | if ( del[i] <= 32 || del[i] == 43 || del[i] == 45 || del[i] == 46 || |
374 | (del[i] >= 48 && del[i] <= 57) || del[i] == 68 || del[i] == 69 || |
375 | del [i] == 72 || del[i] >= 127) { |
376 | // Sending of message : Parameter Delimiter Character is incorrect. |
377 | if (i == 0) { |
378 | Message_Msg Msg41 ("XSTEP_41"); |
379 | ach->SendFail(Msg41); |
380 | } |
381 | // Sending of message : Character Record Delimiter parameter is incorrect. |
382 | else { |
383 | Message_Msg Msg42 ("XSTEP_42"); |
384 | ach->SendFail (Msg42); |
385 | } |
386 | } |
387 | } |
388 | // Sending of message : Single Precision Magnitude parameter is incorrect. |
389 | if (theheader.MaxPower10Single() <= 0) { |
390 | Message_Msg Msg43 ("XSTEP_43"); |
391 | ach->SendFail(Msg43); |
392 | } |
393 | |
394 | // Sending of message : Precision Significance parameter is incorrect. |
395 | if (theheader.MaxDigitsSingle() <= 0) { |
396 | Message_Msg Msg44 ("XSTEP_44"); |
397 | ach->SendFail(Msg44); |
398 | } |
399 | |
400 | // Sending of messages : Double Precision Magnitude parameter is incorrect. |
401 | if (theheader.MaxPower10Double() <= 0) { |
402 | Message_Msg Msg45 ("XSTEP_45"); |
403 | ach->SendFail(Msg45); |
404 | } |
405 | |
406 | // Sending of message : Double Precision Significance parameter is incorrect. |
407 | if (theheader.MaxDigitsDouble() <= 0) { |
408 | Message_Msg Msg46 ("XSTEP_46"); |
409 | ach->SendFail(Msg46); |
410 | } |
411 | |
412 | // Sending of message : Model Space Scale parameter is incorrect. |
413 | if (theheader.Scale() <= 0.) { |
414 | Message_Msg Msg47 ("XSTEP_47"); |
415 | ach->SendFail(Msg47); |
416 | } |
417 | |
418 | Standard_Integer unf = theheader.UnitFlag(); |
419 | |
420 | // Sending of message : Unit Flag parameter is incorrect. |
421 | if (unf < 1 || unf > 11) { |
422 | Message_Msg Msg48 ("XSTEP_48"); |
423 | ach->SendFail(Msg48); |
424 | } |
425 | |
426 | // .. verifie-t-on UnitName en accord avec UnitFlag ? |
427 | if (theheader.UnitName().IsNull()) { |
428 | // Sending of message : Unit Name parameter is undefined. |
429 | if (unf == 3) { |
430 | Message_Msg Msg50 ("XSTEP_50"); |
431 | ach->SendFail(Msg50); |
432 | } |
433 | } |
434 | else { |
435 | Standard_CString unm = theheader.UnitName()->ToCString(); |
436 | Standard_Boolean unok = Standard_True; |
437 | switch (unf) { |
438 | case 1 : unok = (!strcmp(unm,"IN") || !strcmp(unm,"INCH")); break; |
439 | case 2 : unok = !strcmp(unm,"MM"); break; |
440 | case 3 : unok = Standard_True; break; // nom libre |
441 | case 4 : unok = !strcmp(unm,"FT"); break; |
442 | case 5 : unok = !strcmp(unm,"MI"); break; |
443 | case 6 : unok = !strcmp(unm,"M"); break; |
444 | case 7 : unok = !strcmp(unm,"KM"); break; |
445 | case 8 : unok = !strcmp(unm,"MIL"); break; |
446 | case 9 : unok = !strcmp(unm,"UM"); break; |
447 | case 10 : unok = !strcmp(unm,"CM"); break; |
448 | case 11 : unok = !strcmp(unm,"UIN"); break; |
449 | default : Message_Msg Msg48 ("XSTEP_48"); ach->SendFail(Msg48); |
450 | break; |
451 | } |
452 | // Sending of message : Flag parameter doesn`t correspond to the Unit Name parameter. |
453 | if (!unok) { |
454 | Message_Msg Msg51 ("XSTEP_51"); |
455 | ach->SendFail(Msg51); |
456 | } |
457 | } |
458 | |
459 | IGESData_VerifyDate (theheader.Date(),ach,"Creation Date"); |
460 | // Sending of message : Minimum Resolution parameter is incorrect. |
461 | if (theheader.Resolution() <= 0.) { |
462 | Message_Msg Msg52 ("XSTEP_52"); |
463 | ach->SendFail(Msg52); |
464 | } |
465 | // .. comment verifier les coordonnees max ? |
466 | |
467 | // Sending of message : Version Flag parameter is incorrect. |
468 | if (theheader.IGESVersion() < 1 || |
469 | theheader.IGESVersion() > IGESData_BasicEditor::IGESVersionMax()) { |
470 | Message_Msg Msg53 ("XSTEP_53"); |
471 | ach->SendWarning(Msg53); |
472 | } |
473 | |
474 | // Sending of message : Drafting Standard Flag parameter is incorrect. |
475 | if (theheader.DraftingStandard() < 0 || |
476 | theheader.DraftingStandard() > IGESData_BasicEditor::DraftingMax()) { |
477 | Message_Msg Msg54 ("XSTEP_54"); |
478 | ach->SendWarning(Msg54); |
479 | } |
480 | |
481 | // Sending of message : |
482 | if (theheader.IGESVersion() >= 9) { |
483 | // Sending of message : Last change Date parameter is undefined. |
484 | if (!theheader.HasLastChangeDate()) { |
485 | Message_Msg Msg55 ("XSTEP_55"); |
486 | ach->SendWarning(Msg55); |
487 | } |
488 | else IGESData_VerifyDate (theheader.LastChangeDate(),ach,"Last Change Date"); |
489 | } |
490 | } |
491 | |
492 | |
493 | void IGESData_VerifyDate(const Handle(TCollection_HAsciiString)& str, |
494 | Handle(Interface_Check)& ach, |
495 | const Standard_CString mess) |
496 | { |
497 | // MGE 23/07/98 |
498 | // ===================================== |
499 | Message_Msg Msg57 ("XSTEP_57"); |
500 | // ===================================== |
501 | |
502 | // Attention c est du Hollerith |
503 | if (str.IsNull()) |
504 | { ach->SendFail(Msg57); return; } |
505 | |
506 | Handle(TCollection_HAsciiString) stdvar = str; |
507 | if (strcmp(mess,"Last Change Date")==0) |
508 | Msg57.Arg(25); |
509 | else |
510 | Msg57.Arg(18); |
511 | if (((stdvar->Length() != 13) && (stdvar->Length() != 15)) || !stdvar->IsRealValue()) ach->SendFail(Msg57); |
512 | //smh#13 For short year date |
513 | else if ((stdvar->Value(3) > '1' || |
514 | (stdvar->Value(3) == '1' && stdvar->Value(4) > '2'))&&(stdvar->Length() == 13)) ach->SendFail(Msg57); |
515 | |
516 | else if ((stdvar->Value(5) > '3' || |
517 | (stdvar->Value(5) == '3' && stdvar->Value(6) > '1'))&&(stdvar->Length() == 13)) ach->SendFail(Msg57); |
518 | else if ((stdvar->Value(7) != '.' || stdvar->Value(10) > '5' || stdvar->Value(12) > '5')&&(stdvar->Length() == 13)) |
519 | ach->SendFail(Msg57); |
0ebaa4db |
520 | else if ((stdvar->Value(8) > '2' || (stdvar->Value(8) == '2' && stdvar->Value(9) > '3')) && |
521 | (stdvar->Length() == 13)) ach->SendFail(Msg57); |
7fd59977 |
522 | //smh#13 For long year date |
523 | else if ( (stdvar->Value(5) > '1' || |
524 | (stdvar->Value(5) == '1' && stdvar->Value(6) > '2'))&&(stdvar->Length() == 15)) ach->SendFail(Msg57); |
525 | else if ((stdvar->Value(7) > '3' || |
526 | (stdvar->Value(7) == '3' && stdvar->Value(8) > '1'))&&(stdvar->Length() == 15)) ach->SendFail(Msg57); |
527 | else if ((stdvar->Value(9) != '.' || stdvar->Value(12) > '5' || stdvar->Value(14) > '5')&&(stdvar->Length() == 15)) |
528 | ach->SendFail(Msg57); |
529 | else if ((stdvar->Value(10) > '2' || |
0ebaa4db |
530 | (stdvar->Value(10) == '2' && stdvar->Value(11) > '3'))&&(stdvar->Length() == 15)) ach->SendFail(Msg57); |
7fd59977 |
531 | |
532 | } |
533 | |
534 | |
535 | //======================================================================= |
536 | //function : SetLineWeights |
537 | //purpose : |
538 | //======================================================================= |
539 | |
540 | void IGESData_IGESModel::SetLineWeights (const Standard_Real defw) |
541 | { |
542 | Standard_Integer nb = NbEntities(); |
543 | Standard_Integer lwg = theheader.LineWeightGrad(); |
544 | Standard_Real maxw = theheader.MaxLineWeight(); |
545 | if (lwg > 0) { maxw = maxw/lwg; lwg = 1; } |
546 | for (Standard_Integer i = 1; i <= nb; i ++) |
547 | Entity(i)->SetLineWeight(defw,maxw,lwg); |
548 | } |
549 | |
550 | |
551 | //======================================================================= |
552 | //function : ClearLabels |
553 | //purpose : |
554 | //======================================================================= |
555 | |
556 | void IGESData_IGESModel::ClearLabels () |
557 | { |
558 | } |
559 | |
560 | |
561 | //======================================================================= |
562 | //function : PrintLabel |
563 | //purpose : |
564 | //======================================================================= |
565 | |
566 | void IGESData_IGESModel::PrintLabel |
0ebe5b0a |
567 | (const Handle(Standard_Transient)& ent, Standard_OStream& S) const |
7fd59977 |
568 | { |
569 | DeclareAndCast(IGESData_IGESEntity,igesent,ent); |
0ebe5b0a |
570 | if (igesent.IsNull()) S <<"Null"; |
7fd59977 |
571 | else { |
572 | Standard_Integer num = Number(ent); |
0ebe5b0a |
573 | if (num == 0) S <<"??"; |
574 | else S <<"D"<<(2*num-1); |
7fd59977 |
575 | } |
576 | } |
577 | |
578 | |
579 | //======================================================================= |
580 | //function : PrintToLog |
581 | //purpose : |
582 | //======================================================================= |
583 | |
584 | void IGESData_IGESModel::PrintToLog |
0ebe5b0a |
585 | (const Handle(Standard_Transient)& ent, Standard_OStream& S) const |
7fd59977 |
586 | { |
587 | DeclareAndCast(IGESData_IGESEntity,igesent,ent); |
588 | if (!igesent.IsNull()) { |
589 | Standard_Integer num = Number(ent); |
0ebe5b0a |
590 | if (num == 0) S <<"??"; |
7fd59977 |
591 | else { |
0ebe5b0a |
592 | S <<" DE : "<<(2*num-1) << " type : " << igesent->TypeNumber(); |
7fd59977 |
593 | // Standard_Integer num2 = igesent->TypeNumber(); |
594 | } |
595 | } |
596 | } |
597 | |
598 | |
599 | //======================================================================= |
600 | //function : PrintInfo |
601 | //purpose : |
602 | //======================================================================= |
603 | |
604 | void IGESData_IGESModel::PrintInfo |
0ebe5b0a |
605 | (const Handle(Standard_Transient)& ent, Standard_OStream& S) const |
7fd59977 |
606 | { |
607 | DeclareAndCast(IGESData_IGESEntity,igesent,ent); |
0ebe5b0a |
608 | if (igesent.IsNull()) S <<"(NOT IGES)"; |
7fd59977 |
609 | else { |
610 | Standard_Integer num = Number(ent); |
0ebe5b0a |
611 | if (num == 0) S <<"??"; |
7fd59977 |
612 | else { |
0ebe5b0a |
613 | S <<(2*num-1) << "type " << Type(ent)->Name(); |
7fd59977 |
614 | } |
615 | } |
616 | } |
617 | |
618 | |
619 | //======================================================================= |
620 | //function : StringLabel |
621 | //purpose : |
622 | //======================================================================= |
623 | |
624 | Handle(TCollection_HAsciiString) IGESData_IGESModel::StringLabel(const Handle(Standard_Transient)& ent) const |
625 | { |
626 | Handle(TCollection_HAsciiString) label; |
627 | DeclareAndCast(IGESData_IGESEntity,igesent,ent); |
628 | if (igesent.IsNull()) return new TCollection_HAsciiString("(NOT IGES)"); |
629 | else { |
630 | char text[20]; |
631 | Standard_Integer num = Number(ent); |
632 | if (num > 0) sprintf(text,"D%d",2*num-1); |
633 | else sprintf(text,"D0..."); |
634 | label = new TCollection_HAsciiString(text); |
635 | } |
636 | return label; |
637 | } |