0024002: Overall code and build procedure refactoring -- automatic
[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
42cf5bc1 15#include <IFGraph_Articulations.hxx>
16#include <Interface_EntityIterator.hxx>
17#include <Interface_Graph.hxx>
18#include <Interface_InterfaceModel.hxx>
19#include <Standard_Transient.hxx>
7fd59977 20
21// Points d'Articulation d'un Graphe : ce sont les "passages obliges" du graphe
22// Algorithme tire du Sedgewick, p 392
b311480e 23IFGraph_Articulations::IFGraph_Articulations
7fd59977 24 (const Interface_Graph& agraph, const Standard_Boolean whole)
25 : thegraph (agraph)
26 { if (whole) thegraph.GetFromModel(); }
27
28
29 void IFGraph_Articulations::GetFromEntity
30 (const Handle(Standard_Transient)& ent)
31 { thegraph.GetFromEntity(ent,Standard_True); }
32
33 void IFGraph_Articulations::GetFromIter(const Interface_EntityIterator& iter)
34 { thegraph.GetFromIter(iter,0); }
35
36
37 void IFGraph_Articulations::ResetData ()
38{ Reset(); thegraph.Reset(); thelist = new TColStd_HSequenceOfInteger(); }
39
40 void IFGraph_Articulations::Evaluate ()
41{
42// Algorithme, cf Sedgewick "Algorithms", p 392
43 thelist = new TColStd_HSequenceOfInteger();
44// Utilisation de Visit
45 Standard_Integer nb = thegraph.Size();
46 for (Standard_Integer i = 1; i <= nb; i ++) {
7fd59977 47 thenow = 0;
96a95605 48 if (thegraph.IsPresent(i)) Visit(i);
7fd59977 49 }
50// Resultat dans thelist
51 Reset();
52 Standard_Integer nbres = thelist->Length();
53 for (Standard_Integer ires = 1; ires <= nbres; ires ++) {
54 Standard_Integer num = thelist->Value(ires);
55 GetOneItem(thegraph.Model()->Value(num));
56 }
57}
58
59 Standard_Integer IFGraph_Articulations::Visit (const Standard_Integer num)
60{
61 thenow ++;
62 thegraph.SetStatus(num,thenow);
63 Standard_Integer min = thenow;
64
65 for (Interface_EntityIterator iter = thegraph.Shareds(thegraph.Entity(num));
66 iter.More(); iter.Next()) {
67 Handle(Standard_Transient) ent = iter.Value();
68 Standard_Integer nument = thegraph.EntityNumber(ent);
69 if (!thegraph.IsPresent(num)) {
70 thegraph.GetFromEntity(ent,Standard_False);
71 nument = thegraph.EntityNumber(ent);
72 }
73 Standard_Integer statent = thegraph.Status(nument); // pas reevalue
74 if (statent == 0) {
75 Standard_Integer mm = Visit(nument);
76 if (mm < min) min = mm;
77 if (mm > thegraph.Status(num)) thelist->Append(num); // ON EN A UN : num
78 }
79 else if (statent < min) min = statent;
80 }
81 return min;
82}