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 <Standard_Type.hxx> |
16 | #include <StepData_Described.hxx> |
17 | #include <StepData_ECDescr.hxx> |
ec357c5c |
18 | #include <StepData_ESDescr.hxx> |
42cf5bc1 |
19 | #include <StepData_Plex.hxx> |
ec357c5c |
20 | #include <StepData_Simple.hxx> |
42cf5bc1 |
21 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
22 | |
b311480e |
23 | StepData_ECDescr::StepData_ECDescr () { } |
7fd59977 |
24 | |
25 | void StepData_ECDescr::Add (const Handle(StepData_ESDescr)& member) |
26 | { |
27 | if (member.IsNull()) return; |
28 | Standard_CString name = member->TypeName(); |
29 | TCollection_AsciiString nam (name); |
30 | for (Standard_Integer i = NbMembers(); i > 0; i --) { |
31 | Handle(StepData_ESDescr) mem = Member(i); |
32 | if (nam.IsLess (mem->TypeName())) { thelist.InsertBefore (i,member); return; } |
33 | } |
34 | thelist.Append (member); |
35 | } |
36 | |
37 | Standard_Integer StepData_ECDescr::NbMembers () const |
38 | { return thelist.Length(); } |
39 | |
40 | Handle(StepData_ESDescr) StepData_ECDescr::Member |
41 | (const Standard_Integer num) const |
42 | { return Handle(StepData_ESDescr)::DownCast (thelist.Value(num)); } |
43 | |
44 | Handle(TColStd_HSequenceOfAsciiString) StepData_ECDescr::TypeList () const |
45 | { |
46 | Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString(); |
47 | Standard_Integer i, nb = NbMembers(); |
48 | for (i = 1; i <= nb; i ++) { |
49 | TCollection_AsciiString nam (Member(i)->TypeName()); |
50 | tl->Append(nam); |
51 | } |
52 | return tl; |
53 | } |
54 | |
55 | |
56 | Standard_Boolean StepData_ECDescr::Matches (const Standard_CString name) const |
57 | { |
58 | Standard_Integer i, nb = NbMembers(); |
59 | for (i = 1; i <= nb; i ++) { |
60 | Handle(StepData_ESDescr) member = Member(i); |
61 | if (member->Matches(name)) return Standard_True; |
62 | } |
63 | return Standard_False; |
64 | } |
65 | |
66 | Standard_Boolean StepData_ECDescr::IsComplex () const |
67 | { return Standard_True; } |
68 | |
69 | Handle(StepData_Described) StepData_ECDescr::NewEntity () const |
70 | { |
71 | Handle(StepData_Plex) ent = new StepData_Plex (this); |
72 | Standard_Integer i, nb = NbMembers(); |
73 | for (i = 1; i <= nb; i ++) { |
74 | Handle(StepData_ESDescr) member = Member(i); |
75 | Handle(StepData_Simple) mem = Handle(StepData_Simple)::DownCast(member->NewEntity()); |
76 | if (!mem.IsNull()) ent->Add (mem); |
77 | } |
78 | return ent; |
79 | } |