35bae754019fc82b061efe51ec56f57353f24c0e
[occt.git] / src / GraphDS / GraphDS_RelationsIterator.gxx
1 // Created on: 1991-09-10
2 // Created by: Denis PASCAL
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //              <dp>
18
19 #include <Standard_NoMoreObject.hxx>
20 #include <Standard_NoSuchObject.hxx>
21 #include <GraphDS_DataMapIteratorOfEntityRoleMap.hxx>
22
23 //=======================================================================
24 //function : GraphDS_RelationsIterator
25 //purpose  : 
26 //=======================================================================
27
28 GraphDS_RelationsIterator::GraphDS_RelationsIterator ()
29 {
30 }
31
32 //=======================================================================
33 //function : GraphDS_RelationsIterator
34 //purpose  : 
35 //=======================================================================
36
37 GraphDS_RelationsIterator::GraphDS_RelationsIterator 
38   (const GraphDS_RelationGraph& G) 
39 {
40   Initialize (G);
41 }
42
43 //=======================================================================
44 //function : GraphDS_RelationsIterator
45 //purpose  : 
46 //=======================================================================
47
48 GraphDS_RelationsIterator::GraphDS_RelationsIterator 
49   (const GraphDS_RelationGraph& G,
50    const Handle(GraphDS_Entity)& E)
51 {
52   Initialize(G,E);
53 }
54
55 //=======================================================================
56 //function : GraphDS_RelationsIterator
57 //purpose  : 
58 //=======================================================================
59
60 GraphDS_RelationsIterator::GraphDS_RelationsIterator 
61   (const GraphDS_RelationGraph& G,
62    const Handle(GraphDS_Relation)& R)
63 {
64   Initialize(G,R);
65 }
66
67
68 //=======================================================================
69 //function : Initialize
70 //purpose  : 
71 //=======================================================================
72
73 void GraphDS_RelationsIterator::Initialize
74   (const GraphDS_RelationGraph& G) 
75 {
76   myRelations.Initialize(G.myRelations);
77 }     
78
79
80 //=======================================================================
81 //function : Initialize
82 //purpose  : 
83 //=======================================================================
84
85 void GraphDS_RelationsIterator::Initialize
86   (const GraphDS_RelationGraph&,
87    const Handle(GraphDS_Entity)& E)
88 {
89    myRelations.Initialize(E->GetRelations());
90 }
91
92
93 //=======================================================================
94 //function : Initialize
95 //purpose  : 
96 //=======================================================================
97
98 void GraphDS_RelationsIterator::Initialize
99   (const GraphDS_RelationGraph&,
100    const Handle(GraphDS_Relation)& R)
101 {
102   myMap.Clear();
103
104   Handle(GraphDS_Entity) ENT;  
105   Handle(GraphDS_Relation) REL;
106   GraphDS_DataMapIteratorOfEntityRoleMap itv; 
107   TColStd_MapIteratorOfMapOfTransient itr;
108
109   for (itv.Initialize(R->GetEntities());itv.More();itv.Next()) {
110     ENT = Handle(GraphDS_Entity)::DownCast(itv.Key());
111     if (itv.Value() != GraphDS_OnlyInput) {
112       for (itr.Initialize(ENT->GetRelations()); itr.More(); itr.Next()) {
113         REL = Handle(GraphDS_Relation)::DownCast(itr.Key());
114         if (REL->IsInput(ENT)) myMap.Add(REL);
115       }
116     }
117   }
118   myRelations.Initialize(myMap);
119 }
120
121
122 //=======================================================================
123 //function : More
124 //purpose  : 
125 //=======================================================================
126
127 Standard_Boolean GraphDS_RelationsIterator::More () const
128 {
129   return myRelations.More();
130 }
131
132
133 //=======================================================================
134 //function : Next
135 //purpose  : 
136 //=======================================================================
137
138 void GraphDS_RelationsIterator::Next () 
139 {
140   myRelations.Next();
141 }
142         
143
144 //=======================================================================
145 //function : Value
146 //purpose  : 
147 //=======================================================================
148
149 const Handle(GraphDS_Relation)& GraphDS_RelationsIterator::Value () const 
150 {  
151   return  *((Handle(GraphDS_Relation)*)& myRelations.Key());
152   //return Handle(GraphDS_Relation)::DownCast(myRelations.Key());
153 }
154
155
156