b311480e |
1 | // Created on: 2000-09-29 |
2 | // Created by: data exchange team |
973c2be1 |
3 | // Copyright (c) 2000-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #include <PXCAFDoc_GraphNode.ixx> |
17 | #include <Standard_GUID.hxx> |
18 | |
19 | //======================================================================= |
20 | //function : Constructor |
21 | //purpose : |
22 | //======================================================================= |
23 | |
24 | PXCAFDoc_GraphNode::PXCAFDoc_GraphNode() |
25 | { |
26 | myFathers = new PXCAFDoc_GraphNodeSequence; |
27 | myChildren = new PXCAFDoc_GraphNodeSequence; |
28 | } |
29 | |
30 | //======================================================================= |
31 | //function : SetGraphID |
32 | //purpose : |
33 | //======================================================================= |
34 | |
35 | void PXCAFDoc_GraphNode::SetGraphID (const Standard_GUID& explicitID) |
36 | { |
37 | myGraphID = explicitID; |
38 | } |
39 | |
40 | //======================================================================= |
41 | //function : GetGraphID |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | Standard_GUID PXCAFDoc_GraphNode::GetGraphID() const |
46 | { |
47 | return myGraphID; |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : SetFather |
52 | //purpose : |
53 | //======================================================================= |
54 | |
55 | Standard_Integer PXCAFDoc_GraphNode::SetFather(const Handle(PXCAFDoc_GraphNode)& F) |
56 | { |
57 | Standard_Integer Findex = myFathers->Length(); |
58 | myFathers->Append(F); |
59 | return ++Findex; |
60 | } |
61 | |
62 | //======================================================================= |
63 | //function : SetChild |
64 | //purpose : |
65 | //======================================================================= |
66 | |
67 | Standard_Integer PXCAFDoc_GraphNode::SetChild(const Handle(PXCAFDoc_GraphNode)& Ch) |
68 | { |
69 | Standard_Integer Chindex = myChildren->Length(); |
70 | myChildren->Append(Ch); |
71 | return ++Chindex; |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : GetFather |
76 | //purpose : |
77 | //======================================================================= |
78 | |
79 | Handle(PXCAFDoc_GraphNode) PXCAFDoc_GraphNode::GetFather(const Standard_Integer Findex) const |
80 | { |
81 | Handle(PXCAFDoc_GraphNode) F = myFathers->Value(Findex); |
82 | return F; |
83 | } |
84 | |
85 | //======================================================================= |
86 | //function : GetChild |
87 | //purpose : |
88 | //======================================================================= |
89 | |
90 | Handle(PXCAFDoc_GraphNode) PXCAFDoc_GraphNode::GetChild(const Standard_Integer Chindex) const |
91 | { |
92 | Handle(PXCAFDoc_GraphNode) Ch = myChildren->Value(Chindex); |
93 | return Ch; |
94 | } |
95 | |
96 | //======================================================================= |
97 | //function : FatherIndex |
98 | //purpose : |
99 | //======================================================================= |
100 | |
101 | Standard_Integer PXCAFDoc_GraphNode::FatherIndex(const Handle(PXCAFDoc_GraphNode)& F) const |
102 | { |
103 | Standard_Integer Findex = 0; |
104 | for ( ; Findex <= NbFathers(); Findex++) { |
105 | if ( F == myFathers->Value(Findex)) return Findex; |
106 | } |
107 | return 0; |
108 | } |
109 | |
110 | //======================================================================= |
111 | //function : ChildIndex |
112 | //purpose : |
113 | //======================================================================= |
114 | |
115 | Standard_Integer PXCAFDoc_GraphNode::ChildIndex(const Handle(PXCAFDoc_GraphNode)& Ch) const |
116 | { |
117 | Standard_Integer Chindex = 0; |
118 | for ( ; Chindex <= NbChildren(); Chindex++) { |
119 | if ( Ch == myChildren->Value(Chindex)) return Chindex; |
120 | } |
121 | return 0; |
122 | } |
123 | |
124 | //======================================================================= |
125 | //function : NbFathers |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | Standard_Integer PXCAFDoc_GraphNode::NbFathers() const |
130 | { |
131 | return myFathers->Length(); |
132 | } |
133 | |
134 | //======================================================================= |
135 | //function : NbChildren |
136 | //purpose : |
137 | //======================================================================= |
138 | |
139 | Standard_Integer PXCAFDoc_GraphNode::NbChildren() const |
140 | { |
141 | return myChildren->Length(); |
142 | } |