b311480e |
1 | // Created on: 1999-02-18 |
2 | // Created by: Pavel DURANDIN |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <Interface_InterfaceModel.hxx> |
19 | #include <Interface_Macros.hxx> |
7fd59977 |
20 | #include <RWStepAP214_GeneralModule.hxx> |
42cf5bc1 |
21 | #include <Standard_Transient.hxx> |
22 | #include <Standard_Type.hxx> |
23 | #include <StepData_ReadWriteModule.hxx> |
24 | #include <STEPSelections_SelectDerived.hxx> |
25 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
26 | #include <TColStd_SequenceOfAsciiString.hxx> |
7fd59977 |
27 | |
92efcf78 |
28 | IMPLEMENT_STANDARD_RTTIEXT(STEPSelections_SelectDerived,StepSelect_StepType) |
29 | |
7fd59977 |
30 | STEPSelections_SelectDerived::STEPSelections_SelectDerived():StepSelect_StepType() |
31 | { |
32 | } |
33 | |
34 | static Handle(Standard_Type) GetStepType(const Handle(StepData_ReadWriteModule)& module, |
35 | const TCollection_AsciiString& type) |
36 | { |
37 | Handle(Standard_Type) atype; |
38 | if(module.IsNull()) return atype; |
39 | Standard_Integer num = module->CaseStep(type); |
40 | if(num == 0) return atype; |
41 | Handle(Standard_Transient) ent; |
42 | RWStepAP214_GeneralModule genModul; |
43 | genModul.NewVoid(num,ent); |
44 | atype = ent->DynamicType(); |
45 | return atype; |
46 | } |
47 | |
48 | |
49 | Standard_Boolean STEPSelections_SelectDerived::Matches(const Handle(Standard_Transient)& ent, |
35e08fe8 |
50 | const Handle(Interface_InterfaceModel)& /*model*/, |
7fd59977 |
51 | const TCollection_AsciiString& text, |
35e08fe8 |
52 | const Standard_Boolean /*exact*/) const |
7fd59977 |
53 | { |
54 | Standard_Integer CN; |
55 | Handle(StepData_ReadWriteModule) module; |
56 | Standard_Boolean ok = thelib.Select (ent,module,CN); |
57 | if(!ok) return Standard_False; |
58 | Handle(Standard_Type) checker = GetStepType(module,text); |
59 | if(checker.IsNull()) return Standard_False; |
60 | |
61 | Standard_Boolean plex = module->IsComplex(CN); |
62 | if (!plex) { |
63 | DeclareAndCast(Standard_Type,atype,ent); |
64 | if (atype.IsNull()) atype = ent->DynamicType(); |
65 | return atype->SubType(checker); |
66 | } else { |
67 | TColStd_SequenceOfAsciiString list; |
68 | module->ComplexType (CN,list); |
69 | Standard_Integer nb = list.Length(); |
70 | for (Standard_Integer i = 1; i <= nb; i ++) { |
71 | Handle(Standard_Type) atype = GetStepType(module,list.Value(i)); |
72 | if(atype->SubType(checker)) return Standard_True; |
73 | } |
74 | } |
75 | return Standard_False; |
76 | } |