b311480e |
1 | // Created on: 1999-03-25 |
2 | // Created by: data exchange team |
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_EntityIterator.hxx> |
19 | #include <Interface_Graph.hxx> |
7fd59977 |
20 | #include <Interface_Macros.hxx> |
42cf5bc1 |
21 | #include <Standard_Transient.hxx> |
22 | #include <Standard_Type.hxx> |
7fd59977 |
23 | #include <StepRepr_MappedItem.hxx> |
42cf5bc1 |
24 | #include <StepRepr_NextAssemblyUsageOccurrence.hxx> |
25 | #include <StepRepr_ProductDefinitionShape.hxx> |
26 | #include <STEPSelections_SelectAssembly.hxx> |
27 | #include <StepShape_ContextDependentShapeRepresentation.hxx> |
7fd59977 |
28 | #include <StepShape_ShapeDefinitionRepresentation.hxx> |
42cf5bc1 |
29 | #include <StepShape_ShapeRepresentation.hxx> |
30 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
31 | |
92efcf78 |
32 | IMPLEMENT_STANDARD_RTTIEXT(STEPSelections_SelectAssembly,IFSelect_SelectExplore) |
33 | |
7fd59977 |
34 | STEPSelections_SelectAssembly::STEPSelections_SelectAssembly():IFSelect_SelectExplore (-1){ } |
35 | |
35e08fe8 |
36 | Standard_Boolean STEPSelections_SelectAssembly::Explore(const Standard_Integer /*level*/, |
7fd59977 |
37 | const Handle(Standard_Transient)& start, |
38 | const Interface_Graph& G, |
39 | Interface_EntityIterator& explored) const |
40 | { |
41 | if(start.IsNull()) return Standard_False; |
42 | |
43 | if(start->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) { |
44 | DeclareAndCast(StepShape_ContextDependentShapeRepresentation,sdsr,start); |
45 | Handle(StepRepr_ProductDefinitionShape) pds = sdsr->RepresentedProductRelation(); |
46 | if(pds.IsNull()) return Standard_False; |
47 | Handle(Standard_Transient) ent = pds->Definition().ProductDefinitionRelationship(); |
48 | if(ent.IsNull()) return Standard_False; |
49 | return (ent->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))); |
50 | } |
51 | |
52 | if(start->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) { |
53 | DeclareAndCast(StepRepr_MappedItem,mapped,start); |
54 | Interface_EntityIterator subs = G.Sharings(mapped); |
55 | Handle(StepShape_ShapeRepresentation) shrep; |
56 | for(subs.Start(); subs.More()&&shrep.IsNull(); subs.Next()) |
57 | if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) |
58 | shrep = Handle(StepShape_ShapeRepresentation)::DownCast(subs.Value()); |
59 | if(shrep.IsNull()) return Standard_False; |
60 | |
61 | subs = G.Sharings(shrep); |
62 | Handle(StepShape_ShapeDefinitionRepresentation) shdefrep; |
63 | for(subs.Start(); subs.More()&&shdefrep.IsNull(); subs.Next()) |
64 | if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) |
65 | shdefrep = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value()); |
66 | if(shdefrep.IsNull()) return Standard_False; |
67 | |
68 | Handle(StepRepr_ProductDefinitionShape) pds = |
69 | Handle(StepRepr_ProductDefinitionShape)::DownCast ( shdefrep->Definition().PropertyDefinition() ); |
70 | if(pds.IsNull()) return Standard_False; |
71 | Handle(Standard_Transient) ent = pds->Definition().ProductDefinitionRelationship(); |
72 | if(ent.IsNull()) return Standard_False; |
73 | return (ent->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))); |
74 | } |
75 | |
76 | Interface_EntityIterator subs = G.Shareds(start); |
77 | subs.Start(); |
78 | Standard_Boolean isSome = subs.More(); |
79 | for (; subs.More(); subs.Next()) |
80 | explored.AddItem (subs.Value()); |
81 | |
82 | return isSome; |
83 | } |
84 | |
85 | TCollection_AsciiString STEPSelections_SelectAssembly::ExploreLabel() const |
86 | { |
87 | return TCollection_AsciiString ("Assembly components"); |
88 | } |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | |