// Created on: 1991-05-29 // Created by: Denis PASCAL // Copyright (c) 1991-1999 Matra Datavision // Copyright (c) 1999-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file // except in compliance with the License. Please obtain a copy of the License // at http://www.opencascade.org and read it completely before using this file. // // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. // // The Original Code and all software distributed under the License is // distributed on an "AS IS" basis, without warranty of any kind, and the // Initial Developer hereby disclaims all such warranties, including without // limitation, any warranties of merchantability, fitness for a particular // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. // // Revised by: Mireille MERCIEN // Sep,7 1992 #include #include //--------------------------------------------------------------------------- // Constructor //--------------------------------------------------------------------------- PCollection_Vertex:: PCollection_Vertex (const Item& Value, const Handle(PCollection_HDirectedGraph)& InGraph) { MyItem = Value; MyGraph = InGraph; MyFrontEdges = new PCollection_SetOfEdge; MyBackEdges = new PCollection_SetOfEdge; } //--------------------------------------------------------------------------- // GetItem //--------------------------------------------------------------------------- Item PCollection_Vertex::GetItem () const { return MyItem; } //--------------------------------------------------------------------------- // SetItem //--------------------------------------------------------------------------- void PCollection_Vertex::SetItem (const Item& Value) { MyItem = Value; } //--------------------------------------------------------------------------- // GetGraph //--------------------------------------------------------------------------- Handle(PCollection_HDirectedGraph) PCollection_Vertex::GetGraph () const { return MyGraph; } //--------------------------------------------------------------------------- // AddFrontEdge //--------------------------------------------------------------------------- Boolean PCollection_Vertex::AddFrontEdge (const Handle(PCollection_Edge)& E) { if (MyFrontEdges->Contains(E)) { return False; } else { MyFrontEdges->Add(E); return True; } } //--------------------------------------------------------------------------- // RemoveFrontEdge //--------------------------------------------------------------------------- void PCollection_Vertex::RemoveFrontEdge (const Handle(PCollection_Edge)& E) { if (MyFrontEdges->Contains(E)) { MyFrontEdges->Remove(E); } else { Standard_NoSuchObject::Raise(); } } //--------------------------------------------------------------------------- // NbFrontEdges //--------------------------------------------------------------------------- Integer PCollection_Vertex::NbFrontEdges () const { return MyFrontEdges->Extent(); } //--------------------------------------------------------------------------- // GetFrontEdges //--------------------------------------------------------------------------- Handle(PCollection_SetOfEdge) PCollection_Vertex::GetFrontEdges () const { return MyFrontEdges; } //--------------------------------------------------------------------------- // AddBackEdge //--------------------------------------------------------------------------- Boolean PCollection_Vertex::AddBackEdge (const Handle(PCollection_Edge)& E) { if (MyBackEdges->Contains(E)) { return False; } else { MyBackEdges->Add(E); return True; } } //--------------------------------------------------------------------------- // RemoveBackEdge //--------------------------------------------------------------------------- void PCollection_Vertex::RemoveBackEdge (const Handle(PCollection_Edge)& E) { if (MyBackEdges->Contains(E)) { MyBackEdges->Remove(E); } else { Standard_NoSuchObject::Raise(); } } //--------------------------------------------------------------------------- // NbBackEdges //--------------------------------------------------------------------------- Integer PCollection_Vertex::NbBackEdges () const { return MyBackEdges->Extent(); } //--------------------------------------------------------------------------- // GetBackEdges //--------------------------------------------------------------------------- Handle(PCollection_SetOfEdge) PCollection_Vertex::GetBackEdges () const { return MyBackEdges; } //--------------------------------------------------------------------------- // IsRoot //--------------------------------------------------------------------------- Boolean PCollection_Vertex::IsRoot () const { return (NbBackEdges() == 0); } //--------------------------------------------------------------------------- // IsLeaf //--------------------------------------------------------------------------- Boolean PCollection_Vertex::IsLeaf () const { return (NbFrontEdges() == 0); } //--------------------------------------------------------------------------- // IsDestination //--------------------------------------------------------------------------- Boolean PCollection_Vertex:: IsDestination (const Handle(PCollection_Vertex)& V) const { PCollection_SetIteratorOfSetOfEdge It(MyBackEdges); while (It.More()) { Handle(PCollection_Edge) E = It.Value(); if (E->Source() == V) return True; It.Next(); } return False; } //--------------------------------------------------------------------------- // IsSource //--------------------------------------------------------------------------- Boolean PCollection_Vertex:: IsSource (const Handle(PCollection_Vertex)& V) const { PCollection_SetIteratorOfSetOfEdge It(MyFrontEdges); while (It.More()) { Handle(PCollection_Edge) E = It.Value(); if ( E->Destination() == V) return True; It.Next(); } return False; }