1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <IGESData_ColorEntity.hxx>
16 #include <IGESData_DefList.hxx>
17 #include <IGESData_DirChecker.hxx>
18 #include <IGESData_IGESEntity.hxx>
19 #include <IGESData_LabelDisplayEntity.hxx>
20 #include <IGESData_LevelListEntity.hxx>
21 #include <IGESData_LineFontEntity.hxx>
22 #include <IGESData_ViewKindEntity.hxx>
23 #include <Interface_Check.hxx>
24 #include <Message_Msg.hxx>
29 // Chaque critere est par defaut inhibe
30 //=======================================================================
31 //function : IGESData_DirChecker
33 //=======================================================================
34 IGESData_DirChecker::IGESData_DirChecker ()
36 thetype = theform1 = theform2 = 0;
37 thestructure = thelinefont = thelineweig = thecolor = IGESData_ErrorRef;
38 thegraphier = -100; // ne pas tester GraphicsIgnored
39 theblankst = thesubordst = theuseflag = thehierst = -100; // ne pas tester
43 //=======================================================================
44 //function : IGESData_DirChecker
46 //=======================================================================
48 IGESData_DirChecker::IGESData_DirChecker (const Standard_Integer atype)
50 thetype = atype; theform1 = 0; theform2 = -1; // test de forme inhibe
51 thestructure = thelinefont = thelineweig = thecolor = IGESData_ErrorRef;
52 thegraphier = -100; // ne pas tester GraphicsIgnored
53 theblankst = thesubordst = theuseflag = thehierst = -100; // ne pas tester
57 //=======================================================================
58 //function : IGESData_DirChecker
60 //=======================================================================
62 IGESData_DirChecker::IGESData_DirChecker(const Standard_Integer atype,
63 const Standard_Integer aform)
65 thetype = atype; theform1 = theform2 = aform; // forme : valeur requise
66 thestructure = thelinefont = thelineweig = thecolor = IGESData_ErrorRef;
67 thegraphier = -100; // ne pas tester GraphicsIgnored
68 theblankst = thesubordst = theuseflag = thehierst = -100; // ne pas tester
72 //=======================================================================
73 //function : IGESData_DirChecker
75 //=======================================================================
77 IGESData_DirChecker::IGESData_DirChecker(const Standard_Integer atype,
78 const Standard_Integer aform1,
79 const Standard_Integer aform2)
81 thetype = atype; theform1 = aform1; theform2 = aform2; // forme : [...]
82 thestructure = thelinefont = thelineweig = thecolor = IGESData_ErrorRef;
83 thegraphier = -100; // ne pas tester GraphicsIgnored
84 theblankst = thesubordst = theuseflag = thehierst = -100; // ne pas tester
88 //=======================================================================
91 //=======================================================================
93 Standard_Boolean IGESData_DirChecker::IsSet () const
99 //=======================================================================
100 //function : SetDefault
102 //=======================================================================
104 void IGESData_DirChecker::SetDefault ()
106 Structure(IGESData_DefVoid);
107 } // Option par defaut
110 //=======================================================================
111 //function : Structure
113 //=======================================================================
115 void IGESData_DirChecker::Structure (const IGESData_DefType crit)
117 isitset = Standard_True;
122 //=======================================================================
123 //function : LineFont
125 //=======================================================================
127 void IGESData_DirChecker::LineFont (const IGESData_DefType crit)
129 isitset = Standard_True;
134 //=======================================================================
135 //function : LineWeight
137 //=======================================================================
139 void IGESData_DirChecker::LineWeight (const IGESData_DefType crit)
141 isitset = Standard_True;
146 //=======================================================================
149 //=======================================================================
151 void IGESData_DirChecker::Color (const IGESData_DefType crit)
153 isitset = Standard_True;
158 //=======================================================================
159 //function : GraphicsIgnored
161 //=======================================================================
163 void IGESData_DirChecker::GraphicsIgnored (const Standard_Integer hierarchy)
165 isitset = Standard_True;
166 thegraphier = hierarchy;
170 //=======================================================================
171 //function : BlankStatusIgnored
173 //=======================================================================
175 void IGESData_DirChecker::BlankStatusIgnored ()
177 isitset = Standard_True;
182 //=======================================================================
183 //function : BlankStatusRequired
185 //=======================================================================
187 void IGESData_DirChecker::BlankStatusRequired (const Standard_Integer val)
189 isitset = Standard_True;
194 //=======================================================================
195 //function : SubordinateStatusIgnored
197 //=======================================================================
199 void IGESData_DirChecker::SubordinateStatusIgnored ()
201 isitset = Standard_True;
206 //=======================================================================
207 //function : SubordinateStatusRequired
209 //=======================================================================
211 void IGESData_DirChecker::SubordinateStatusRequired(const Standard_Integer val)
213 isitset = Standard_True;
218 //=======================================================================
219 //function : UseFlagIgnored
221 //=======================================================================
223 void IGESData_DirChecker::UseFlagIgnored ()
225 isitset = Standard_True;
230 //=======================================================================
231 //function : UseFlagRequired
233 //=======================================================================
235 void IGESData_DirChecker::UseFlagRequired (const Standard_Integer val)
237 isitset = Standard_True;
242 //=======================================================================
243 //function : HierarchyStatusIgnored
245 //=======================================================================
247 void IGESData_DirChecker::HierarchyStatusIgnored ()
249 isitset = Standard_True;
254 //=======================================================================
255 //function : HierarchyStatusRequired
257 //=======================================================================
259 void IGESData_DirChecker::HierarchyStatusRequired (const Standard_Integer val)
261 isitset = Standard_True;
266 //=======================================================================
269 //=======================================================================
271 void IGESData_DirChecker::Check(Handle(Interface_Check)& ach,
272 const Handle(IGESData_IGESEntity)& ent) const
275 // =====================================
276 //Message_Msg Msg58 ("XSTEP_58");
277 //Message_Msg Msg59 ("XSTEP_59");
278 //Message_Msg Msg60 ("XSTEP_60");
279 //Message_Msg Msg65 ("XSTEP_65");
280 //Message_Msg Msg66 ("XSTEP_66");
281 //Message_Msg Msg67 ("XSTEP_67");
282 //Message_Msg Msg68 ("XSTEP_68");
283 //Message_Msg Msg69 ("XSTEP_69");
284 //Message_Msg Msg70 ("XSTEP_70");
285 //Message_Msg Msg71 ("XSTEP_71");
286 // =====================================
290 // Sending of message : Entity Type Number field is incorrect.
291 if (ent->TypeNumber() != thetype) {
292 Message_Msg Msg58 ("XSTEP_58");
293 ach->SendFail(Msg58);
296 // Sending of message : Form Number field is incorrect.
297 if (theform1 <= theform2) {
298 if (ent->FormNumber() < theform1 || ent->FormNumber() > theform2) {
299 Message_Msg Msg71 ("XSTEP_71");
300 ach->SendFail(Msg71);
305 // Sending of message : Structure field is undefined.
306 if (thestructure == IGESData_DefReference && !ent->HasStructure()) {
307 Message_Msg Msg59 ("XSTEP_59");
308 ach->SendFail (Msg59);
311 if (thegraphier == -1 || thegraphier == ent->HierarchyStatus()) { }
313 IGESData_DefType df = ent->DefLineFont();
315 // Sending of message : Line Font Pattern field is incorrect
316 if (df == IGESData_ErrorVal || df == IGESData_ErrorRef) {
317 Message_Msg Msg60 ("XSTEP_60");
318 ach->SendFail (Msg60);
320 else if (thelinefont == IGESData_DefValue && df != IGESData_DefValue) {
321 Message_Msg Msg60 ("XSTEP_60");
322 ach->SendWarning (Msg60);
325 Standard_Integer dlw = ent->LineWeightNumber();
326 Message_Msg Msg69 ("XSTEP_69");
327 // Sending of message : Line Weight Number is undefined.
328 if (thelineweig == IGESData_DefValue && dlw == 0) {
329 // Message_Msg Msg69 ("XSTEP_69");
330 ach->SendWarning (Msg69);
333 df = ent->DefColor();
335 // Sending of message : Color Number field is incorrect.
336 if (df == IGESData_ErrorVal || df == IGESData_ErrorRef) {
337 // Message_Msg Msg69 ("XSTEP_69");
338 ach->SendFail (Msg69);
340 else if (thecolor == IGESData_DefValue && df != IGESData_DefValue) {
341 // Message_Msg Msg69 ("XSTEP_69");
342 ach->SendWarning (Msg69);
346 Standard_Integer st = ent->BlankStatus();
348 // Sending of message : Blank Status field is incorrect.
349 if (st < 0 || st > 1) {
350 Message_Msg Msg65 ("XSTEP_65");
351 ach->SendFail (Msg65);
354 st = ent->SubordinateStatus();
356 // Sending of message : Subordinate Entity Switch field is incorrect.
357 if (st < 0 || st > 3) {
358 Message_Msg Msg66 ("XSTEP_66");
359 ach->SendFail(Msg66);
364 // Send of message : Entity Use Flag is incorrect.
365 if (st < 0 || st > 5) {
366 Message_Msg Msg67 ("XSTEP_67");
367 ach->SendFail(Msg67);
370 st = ent->HierarchyStatus();
372 //Sending of message : Hierarchy field is incorrect.
373 if (st < 0 || st > 2) {
374 Message_Msg Msg68 ("XSTEP_68");
375 ach->SendFail(Msg68);
381 //=======================================================================
382 //function : CheckTypeAndForm
384 //=======================================================================
386 void IGESData_DirChecker::CheckTypeAndForm(Handle(Interface_Check)& ach,
387 const Handle(IGESData_IGESEntity)& ent) const
389 // CKY 30 NOV 2001 : This method is called for immediate check on reading
390 // But an entity which can be read has ben already recognized.
391 // To produce a FAIL here is interpreted as "FAIL ON LOADING", which is
392 // not true (the entity has been recognized then properly loaded)
393 // Consequence (among other) : the entity is not explored by graph of dep.s
394 // so numerous "false roots" are detected
395 // Alternative to switch Fail to Warning here, should be to withdraw the calls
396 // to that method by all the "ReadOwn" methods, but it's heavier
397 // ANYWAY, the full Check method produces a Fail if Type/Form is not in scope,
398 // so it is well interpreted as "Syntactic error"
401 // =====================================
402 // Message_Msg Msg58 ("XSTEP_58");
403 // Message_Msg Msg71 ("XSTEP_71");
404 // =====================================
405 //char mess[80]; //szv#4:S4163:12Mar99 unused
408 if (ent->TypeNumber() != thetype){
409 Message_Msg Msg58 ("XSTEP_58");
410 ach->SendWarning(Msg58);
413 if (theform1 <= theform2)
414 if (ent->FormNumber() < theform1 || ent->FormNumber() > theform2) {
415 Message_Msg Msg71 ("XSTEP_71");
416 ach->SendWarning(Msg71);
423 //=======================================================================
426 //=======================================================================
428 Standard_Boolean IGESData_DirChecker::Correct
429 (const Handle(IGESData_IGESEntity)& ent) const
431 Standard_Boolean done = Standard_False;
432 Standard_Integer type = ent->TypeNumber();
433 Standard_Integer form = ent->FormNumber();
435 if (theform1 >= 0 && theform1 == theform2 && theform1 != form)
436 { ent->InitTypeAndForm (thetype,theform1); done = Standard_True; }
437 else if (thetype != type)
438 { ent->InitTypeAndForm (thetype,form); done = Standard_True; }
441 Handle(IGESData_IGESEntity) structure; // par defaut Nulle
442 if (thestructure != IGESData_DefVoid) structure = ent->Structure();
443 Handle(IGESData_ViewKindEntity) nulview;
444 Handle(IGESData_LineFontEntity) nulfont;
445 Handle(IGESData_LevelListEntity) nulevel;
446 Handle(IGESData_ColorEntity) nulcolor;
447 Handle(IGESData_LabelDisplayEntity) label; // par defaut Nulle
448 if (thegraphier != -1) label = ent->LabelDisplay();
449 Standard_Integer linew = 0;
450 if (thegraphier != -1 && thelineweig != IGESData_DefVoid)
451 linew = ent->LineWeightNumber();
453 if (thegraphier == -1 ||
454 (ent->RankLineFont() != 0 && thelinefont == IGESData_DefVoid) )
455 { ent->InitLineFont(nulfont); done = Standard_True; }
456 if (thegraphier == -1 ||
457 (ent->RankColor() != 0 && thecolor == IGESData_DefVoid) )
458 { ent->InitColor(nulcolor); done = Standard_True; }
459 if (thegraphier == -1 &&
460 (!ent->View().IsNull() || ent->Level() != 0) )
461 { ent->InitView(nulview); ent->InitLevel(nulevel); done = Standard_True; }
462 if ((thegraphier == -1 &&
463 (!ent->LabelDisplay().IsNull() || ent->LineWeightNumber() != 0)) ||
464 (ent->HasStructure() && thestructure == IGESData_DefVoid) ) // combines :
465 { ent->InitMisc (structure,label,linew); done = Standard_True; }
467 Standard_Boolean force = Standard_False;
468 Standard_Integer stb = ent->BlankStatus();
469 Standard_Integer sts = ent->SubordinateStatus();
470 Standard_Integer stu = ent->UseFlag();
471 Standard_Integer sth = ent->HierarchyStatus();
472 if (theblankst >= 0 && theblankst != stb)
473 { force = Standard_True; stb = theblankst; }
474 if (thesubordst >= 0 && thesubordst != sts)
475 { force = Standard_True; sts = thesubordst; }
476 if (theuseflag >= 0 && theuseflag != stu)
477 { force = Standard_True; stu = theuseflag; }
478 if (thehierst >= 0 && thehierst != sth)
479 { force = Standard_True; sth = thehierst; }
480 if (force) { ent->InitStatus(stb,sts,stu,sth); done = Standard_True; }