0024624: Lost word in license statement in source files
[occt.git] / src / IFGraph / IFGraph_Articulations.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <IFGraph_Articulations.ixx>
15#include <Interface_InterfaceModel.hxx>
16
17
18
19// Points d'Articulation d'un Graphe : ce sont les "passages obliges" du graphe
20// Algorithme tire du Sedgewick, p 392
21
b311480e 22IFGraph_Articulations::IFGraph_Articulations
7fd59977 23 (const Interface_Graph& agraph, const Standard_Boolean whole)
24 : thegraph (agraph)
25 { if (whole) thegraph.GetFromModel(); }
26
27
28 void IFGraph_Articulations::GetFromEntity
29 (const Handle(Standard_Transient)& ent)
30 { thegraph.GetFromEntity(ent,Standard_True); }
31
32 void IFGraph_Articulations::GetFromIter(const Interface_EntityIterator& iter)
33 { thegraph.GetFromIter(iter,0); }
34
35
36 void IFGraph_Articulations::ResetData ()
37{ Reset(); thegraph.Reset(); thelist = new TColStd_HSequenceOfInteger(); }
38
39 void IFGraph_Articulations::Evaluate ()
40{
41// Algorithme, cf Sedgewick "Algorithms", p 392
42 thelist = new TColStd_HSequenceOfInteger();
43// Utilisation de Visit
44 Standard_Integer nb = thegraph.Size();
45 for (Standard_Integer i = 1; i <= nb; i ++) {
7fd59977 46 thenow = 0;
96a95605 47 if (thegraph.IsPresent(i)) Visit(i);
7fd59977 48 }
49// Resultat dans thelist
50 Reset();
51 Standard_Integer nbres = thelist->Length();
52 for (Standard_Integer ires = 1; ires <= nbres; ires ++) {
53 Standard_Integer num = thelist->Value(ires);
54 GetOneItem(thegraph.Model()->Value(num));
55 }
56}
57
58 Standard_Integer IFGraph_Articulations::Visit (const Standard_Integer num)
59{
60 thenow ++;
61 thegraph.SetStatus(num,thenow);
62 Standard_Integer min = thenow;
63
64 for (Interface_EntityIterator iter = thegraph.Shareds(thegraph.Entity(num));
65 iter.More(); iter.Next()) {
66 Handle(Standard_Transient) ent = iter.Value();
67 Standard_Integer nument = thegraph.EntityNumber(ent);
68 if (!thegraph.IsPresent(num)) {
69 thegraph.GetFromEntity(ent,Standard_False);
70 nument = thegraph.EntityNumber(ent);
71 }
72 Standard_Integer statent = thegraph.Status(nument); // pas reevalue
73 if (statent == 0) {
74 Standard_Integer mm = Visit(nument);
75 if (mm < min) min = mm;
76 if (mm > thegraph.Status(num)) thelist->Append(num); // ON EN A UN : num
77 }
78 else if (statent < min) min = statent;
79 }
80 return min;
81}