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 | |
42cf5bc1 |
15 | #include <IGESData_IGESEntity.hxx> |
16 | #include <IGESSelect_SignStatus.hxx> |
17 | #include <Interface_InterfaceModel.hxx> |
18 | #include <Standard_Transient.hxx> |
19 | #include <Standard_Type.hxx> |
20 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
21 | |
42cf5bc1 |
22 | #include <stdio.h> |
92efcf78 |
23 | IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SignStatus,IFSelect_Signature) |
24 | |
7fd59977 |
25 | static char theval[10]; |
26 | |
27 | IGESSelect_SignStatus::IGESSelect_SignStatus () |
28 | : IFSelect_Signature ("D.E. Status") { } |
29 | |
30 | Standard_CString IGESSelect_SignStatus::Value |
31 | (const Handle(Standard_Transient)& ent, |
35e08fe8 |
32 | const Handle(Interface_InterfaceModel)& /*model*/) const |
7fd59977 |
33 | { |
34 | Handle(IGESData_IGESEntity) igesent = Handle(IGESData_IGESEntity)::DownCast(ent); |
35 | if (igesent.IsNull()) return ""; |
36 | Standard_Integer i,j,k,l; |
37 | i = igesent->BlankStatus (); |
38 | j = igesent->SubordinateStatus (); |
39 | k = igesent->UseFlag (); |
40 | l = igesent->HierarchyStatus (); |
41 | sprintf (theval,"%d,%d,%d,%d",i,j,k,l); |
42 | return theval; |
43 | } |
44 | |
45 | Standard_Boolean IGESSelect_SignStatus::Matches |
46 | (const Handle(Standard_Transient)& ent, |
35e08fe8 |
47 | const Handle(Interface_InterfaceModel)& /*model*/, |
7fd59977 |
48 | const TCollection_AsciiString& text, const Standard_Boolean exact) const |
49 | { |
50 | Handle(IGESData_IGESEntity) igesent = Handle(IGESData_IGESEntity)::DownCast(ent); |
51 | if (igesent.IsNull()) return Standard_False; |
52 | Standard_Integer i,j,k,l; |
53 | i = igesent->BlankStatus (); |
54 | j = igesent->SubordinateStatus (); |
55 | k = igesent->UseFlag (); |
56 | l = igesent->HierarchyStatus (); |
57 | Standard_Integer n,nb = text.Length(); |
58 | if (nb > 9) nb = 9; |
59 | for (n = 1; n <= nb; n ++) theval[n-1] = text.Value(n); |
60 | theval[nb] = '\0'; |
61 | |
62 | Standard_Integer vir = 0, val = 0; |
63 | for (n = 0; n < nb; n ++) { |
64 | char car = theval[n]; |
65 | if (car == ',') { vir ++; continue; } |
66 | val = Standard_Integer (car-48); |
67 | if (car == 'V' && vir == 0) val = 0; |
68 | if (car == 'B' && vir == 0) val = 1; |
69 | if (car == 'I' && vir == 1) val = 0; |
70 | if (car == 'P' && vir == 1) val = 1; |
71 | if (car == 'L' && vir == 1) val = 2; |
72 | if (car == 'D' && vir == 1) val = 3; |
73 | // Matches ? |
74 | if (vir == 0) { // Blank |
75 | if (i == val && !exact) return Standard_True; |
76 | if (i != val && exact) return Standard_False; |
77 | } |
78 | if (vir == 1) { // Subord. |
79 | if (j == val && !exact) return Standard_True; |
80 | if (j != val && exact) return Standard_False; |
81 | } |
82 | if (vir == 2) { // UseFlag |
83 | if (k == val && !exact) return Standard_True; |
84 | if (k != val && exact) return Standard_False; |
85 | } |
86 | if (vir == 3) { // Hierarchy |
87 | if (l == val && !exact) return Standard_True; |
88 | if (l != val && exact) return Standard_False; |
89 | } |
90 | } |
91 | return exact; // un brin de reflexion pour arriver |
92 | } |