b311480e |
1 | // Created on: 1999-02-18 |
2 | // Created by: Pavel DURANDIN |
3 | // Copyright (c) 1999-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <STEPSelections_SelectDerived.ixx> |
24 | #include <StepData_ReadWriteModule.hxx> |
25 | #include <RWStepAP214_GeneralModule.hxx> |
26 | #include <TColStd_SequenceOfAsciiString.hxx> |
27 | #include <Interface_Macros.hxx> |
28 | |
29 | STEPSelections_SelectDerived::STEPSelections_SelectDerived():StepSelect_StepType() |
30 | { |
31 | } |
32 | |
33 | static Handle(Standard_Type) GetStepType(const Handle(StepData_ReadWriteModule)& module, |
34 | const TCollection_AsciiString& type) |
35 | { |
36 | Handle(Standard_Type) atype; |
37 | if(module.IsNull()) return atype; |
38 | Standard_Integer num = module->CaseStep(type); |
39 | if(num == 0) return atype; |
40 | Handle(Standard_Transient) ent; |
41 | RWStepAP214_GeneralModule genModul; |
42 | genModul.NewVoid(num,ent); |
43 | atype = ent->DynamicType(); |
44 | return atype; |
45 | } |
46 | |
47 | |
48 | Standard_Boolean STEPSelections_SelectDerived::Matches(const Handle(Standard_Transient)& ent, |
35e08fe8 |
49 | const Handle(Interface_InterfaceModel)& /*model*/, |
7fd59977 |
50 | const TCollection_AsciiString& text, |
35e08fe8 |
51 | const Standard_Boolean /*exact*/) const |
7fd59977 |
52 | { |
53 | Standard_Integer CN; |
54 | Handle(StepData_ReadWriteModule) module; |
55 | Standard_Boolean ok = thelib.Select (ent,module,CN); |
56 | if(!ok) return Standard_False; |
57 | Handle(Standard_Type) checker = GetStepType(module,text); |
58 | if(checker.IsNull()) return Standard_False; |
59 | |
60 | Standard_Boolean plex = module->IsComplex(CN); |
61 | if (!plex) { |
62 | DeclareAndCast(Standard_Type,atype,ent); |
63 | if (atype.IsNull()) atype = ent->DynamicType(); |
64 | return atype->SubType(checker); |
65 | } else { |
66 | TColStd_SequenceOfAsciiString list; |
67 | module->ComplexType (CN,list); |
68 | Standard_Integer nb = list.Length(); |
69 | for (Standard_Integer i = 1; i <= nb; i ++) { |
70 | Handle(Standard_Type) atype = GetStepType(module,list.Value(i)); |
71 | if(atype->SubType(checker)) return Standard_True; |
72 | } |
73 | } |
74 | return Standard_False; |
75 | } |