1 // Created on: 1991-05-29
2 // Created by: Denis PASCAL
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 // Revised by: Mireille MERCIEN
21 #include <Standard_NoSuchObject.hxx>
22 #include <Standard_NoMoreObject.hxx>
25 //---------------------------------------------------------------------------
27 //---------------------------------------------------------------------------
29 PCollection_Vertex (const Item& Value,
30 const Handle(PCollection_HDirectedGraph)& InGraph)
34 MyFrontEdges = new PCollection_SetOfEdge;
35 MyBackEdges = new PCollection_SetOfEdge;
38 //---------------------------------------------------------------------------
40 //---------------------------------------------------------------------------
41 Item PCollection_Vertex::GetItem () const
46 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
49 void PCollection_Vertex::SetItem (const Item& Value)
54 //---------------------------------------------------------------------------
56 //---------------------------------------------------------------------------
57 Handle(PCollection_HDirectedGraph) PCollection_Vertex::GetGraph () const
62 //---------------------------------------------------------------------------
64 //---------------------------------------------------------------------------
65 Boolean PCollection_Vertex::AddFrontEdge (const Handle(PCollection_Edge)& E)
67 if (MyFrontEdges->Contains(E)) {
76 //---------------------------------------------------------------------------
78 //---------------------------------------------------------------------------
79 void PCollection_Vertex::RemoveFrontEdge (const Handle(PCollection_Edge)& E)
81 if (MyFrontEdges->Contains(E)) {
82 MyFrontEdges->Remove(E);
85 Standard_NoSuchObject::Raise();
89 //---------------------------------------------------------------------------
91 //---------------------------------------------------------------------------
92 Integer PCollection_Vertex::NbFrontEdges () const
94 return MyFrontEdges->Extent();
97 //---------------------------------------------------------------------------
99 //---------------------------------------------------------------------------
100 Handle(PCollection_SetOfEdge) PCollection_Vertex::GetFrontEdges () const
105 //---------------------------------------------------------------------------
107 //---------------------------------------------------------------------------
108 Boolean PCollection_Vertex::AddBackEdge (const Handle(PCollection_Edge)& E)
110 if (MyBackEdges->Contains(E)) {
119 //---------------------------------------------------------------------------
121 //---------------------------------------------------------------------------
122 void PCollection_Vertex::RemoveBackEdge (const Handle(PCollection_Edge)& E)
124 if (MyBackEdges->Contains(E)) {
125 MyBackEdges->Remove(E);
128 Standard_NoSuchObject::Raise();
132 //---------------------------------------------------------------------------
134 //---------------------------------------------------------------------------
135 Integer PCollection_Vertex::NbBackEdges () const
137 return MyBackEdges->Extent();
140 //---------------------------------------------------------------------------
142 //---------------------------------------------------------------------------
143 Handle(PCollection_SetOfEdge) PCollection_Vertex::GetBackEdges () const
148 //---------------------------------------------------------------------------
150 //---------------------------------------------------------------------------
151 Boolean PCollection_Vertex::IsRoot () const
153 return (NbBackEdges() == 0);
156 //---------------------------------------------------------------------------
158 //---------------------------------------------------------------------------
159 Boolean PCollection_Vertex::IsLeaf () const
161 return (NbFrontEdges() == 0);
164 //---------------------------------------------------------------------------
166 //---------------------------------------------------------------------------
167 Boolean PCollection_Vertex::
168 IsDestination (const Handle(PCollection_Vertex)& V) const
170 PCollection_SetIteratorOfSetOfEdge It(MyBackEdges);
172 Handle(PCollection_Edge) E = It.Value();
173 if (E->Source() == V) return True;
179 //---------------------------------------------------------------------------
181 //---------------------------------------------------------------------------
182 Boolean PCollection_Vertex::
183 IsSource (const Handle(PCollection_Vertex)& V) const
185 PCollection_SetIteratorOfSetOfEdge It(MyFrontEdges);
187 Handle(PCollection_Edge) E = It.Value();
188 if ( E->Destination() == V) return True;