0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / StepData / StepData_ECDescr.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Standard_Type.hxx>
16 #include <StepData_Described.hxx>
17 #include <StepData_ECDescr.hxx>
18 #include <StepData_ESDescr.hxx>
19 #include <StepData_Plex.hxx>
20 #include <StepData_Simple.hxx>
21 #include <TCollection_AsciiString.hxx>
22
23 IMPLEMENT_STANDARD_RTTIEXT(StepData_ECDescr,StepData_EDescr)
24
25 StepData_ECDescr::StepData_ECDescr  ()    {  }
26
27     void  StepData_ECDescr::Add (const Handle(StepData_ESDescr)& member)
28 {
29   if (member.IsNull()) return;
30   Standard_CString name = member->TypeName();
31   TCollection_AsciiString nam (name);
32   for (Standard_Integer i = NbMembers(); i > 0; i --) {
33     Handle(StepData_ESDescr) mem = Member(i);
34     if (nam.IsLess (mem->TypeName())) { thelist.InsertBefore (i,member); return; }
35   }
36   thelist.Append (member);
37 }
38
39     Standard_Integer  StepData_ECDescr::NbMembers () const
40       {  return thelist.Length();  }
41
42     Handle(StepData_ESDescr)  StepData_ECDescr::Member
43   (const Standard_Integer num) const
44       {  return Handle(StepData_ESDescr)::DownCast (thelist.Value(num));  }
45
46     Handle(TColStd_HSequenceOfAsciiString)  StepData_ECDescr::TypeList () const
47 {
48   Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString();
49   Standard_Integer i, nb = NbMembers();
50   for (i = 1; i <= nb; i ++) {
51     TCollection_AsciiString nam (Member(i)->TypeName());
52     tl->Append(nam);
53   }
54   return tl;
55 }
56
57
58     Standard_Boolean  StepData_ECDescr::Matches (const Standard_CString name) const
59 {
60   Standard_Integer i, nb = NbMembers();
61   for (i = 1; i <= nb; i ++) {
62     Handle(StepData_ESDescr) member = Member(i);
63     if (member->Matches(name)) return Standard_True;
64   }
65   return Standard_False;
66 }
67
68     Standard_Boolean  StepData_ECDescr::IsComplex () const
69       {  return Standard_True;  }
70
71     Handle(StepData_Described)  StepData_ECDescr::NewEntity () const
72 {
73   Handle(StepData_Plex) ent = new StepData_Plex (this);
74   Standard_Integer i, nb = NbMembers();
75   for (i = 1; i <= nb; i ++) {
76     Handle(StepData_ESDescr) member = Member(i);
77     Handle(StepData_Simple) mem = Handle(StepData_Simple)::DownCast(member->NewEntity());
78     if (!mem.IsNull()) ent->Add (mem);
79   }
80   return ent;
81 }