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 | |
42cf5bc1 |
14 | |
15 | #include <Interface_Check.hxx> |
16 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
17 | #include <Interface_InterfaceMismatch.hxx> |
42cf5bc1 |
18 | #include <Standard_Type.hxx> |
ec357c5c |
19 | #include <StepData_ECDescr.hxx> |
42cf5bc1 |
20 | #include <StepData_Field.hxx> |
21 | #include <StepData_Plex.hxx> |
ec357c5c |
22 | #include <StepData_Simple.hxx> |
42cf5bc1 |
23 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
24 | |
92efcf78 |
25 | IMPLEMENT_STANDARD_RTTIEXT(StepData_Plex,StepData_Described) |
26 | |
7fd59977 |
27 | static StepData_Field bid; |
28 | |
29 | StepData_Plex::StepData_Plex (const Handle(StepData_ECDescr)& descr) |
30 | : StepData_Described (descr) { } |
31 | |
32 | void StepData_Plex::Add (const Handle(StepData_Simple)& member) |
33 | { themembers.Append (member); } |
34 | |
35 | Handle(StepData_ECDescr) StepData_Plex::ECDescr () const |
36 | { return Handle(StepData_ECDescr)::DownCast(Description()); } |
37 | |
38 | |
39 | Standard_Boolean StepData_Plex::IsComplex () const |
40 | { return Standard_True; } |
41 | |
42 | Standard_Boolean StepData_Plex::Matches (const Standard_CString steptype) const |
43 | { |
44 | Standard_Integer i, nb = NbMembers(); |
45 | for (i = 1; i <= nb; i ++) { |
46 | if (Member(i)->Matches (steptype)) return Standard_True; |
47 | } |
48 | return Standard_False; |
49 | } |
50 | |
51 | Handle(StepData_Simple) StepData_Plex::As (const Standard_CString steptype) const |
52 | { |
53 | Handle(StepData_Simple) ent; |
54 | Standard_Integer i, nb = NbMembers(); |
55 | for (i = 1; i <= nb; i ++) { |
56 | ent = Member(i); |
57 | if (ent->Matches(steptype)) return ent; |
58 | } |
59 | ent.Nullify(); |
60 | return ent; |
61 | } |
62 | |
63 | Standard_Boolean StepData_Plex::HasField (const Standard_CString name) const |
64 | { |
65 | Standard_Integer i, nb = NbMembers(); |
66 | for (i = 1; i <= nb; i ++) { |
67 | if (Member(i)->HasField (name)) return Standard_True; |
68 | } |
69 | return Standard_False; |
70 | } |
71 | |
72 | const StepData_Field& StepData_Plex::Field (const Standard_CString name) const |
73 | { |
74 | Handle(StepData_Simple) ent; |
75 | Standard_Integer i, nb = NbMembers(); |
76 | for (i = 1; i <= nb; i ++) { |
77 | ent = Member(i); |
78 | if (ent->HasField (name)) return ent->Field (name); |
79 | } |
9775fa61 |
80 | throw Interface_InterfaceMismatch("StepData_Plex : Field"); |
7fd59977 |
81 | } |
82 | |
83 | |
84 | StepData_Field& StepData_Plex::CField (const Standard_CString name) |
85 | { |
86 | Handle(StepData_Simple) ent; |
87 | Standard_Integer i, nb = NbMembers(); |
88 | for (i = 1; i <= nb; i ++) { |
89 | ent = Member(i); |
90 | if (ent->HasField (name)) return ent->CField (name); |
91 | } |
9775fa61 |
92 | throw Interface_InterfaceMismatch("StepData_Plex : Field"); |
7fd59977 |
93 | } |
94 | |
95 | |
96 | Standard_Integer StepData_Plex::NbMembers () const |
97 | { return themembers.Length(); } |
98 | |
99 | Handle(StepData_Simple) StepData_Plex::Member (const Standard_Integer num) const |
100 | { return Handle(StepData_Simple)::DownCast (themembers.Value(num)); } |
101 | |
102 | Handle(TColStd_HSequenceOfAsciiString) StepData_Plex::TypeList () const |
103 | { |
104 | Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString(); |
105 | Standard_Integer i, nb = NbMembers(); |
106 | for (i = 1; i <= nb; i ++) { |
107 | TCollection_AsciiString nam (Member(i)->StepType()); |
108 | tl->Append (nam); |
109 | } |
110 | return tl; |
111 | } |
112 | |
113 | |
114 | void StepData_Plex::Check(Handle(Interface_Check)& ach) const |
115 | { |
116 | Standard_Integer i, nb = NbMembers(); |
117 | for (i = 1; i <= nb; i ++) { |
118 | Handle(StepData_Simple) si = Member(i); |
119 | si->Check(ach); |
120 | } |
121 | } |
122 | |
123 | |
124 | void StepData_Plex::Shared (Interface_EntityIterator& list) const |
125 | { |
126 | Standard_Integer i, nb = NbMembers(); |
127 | for (i = 1; i <= nb; i ++) { |
128 | Handle(StepData_Simple) si = Member(i); |
129 | si->Shared (list); |
130 | } |
131 | } |