Integration of OCCT 6.5.0 from SVN
[occt.git] / src / TFunction / TFunction_Logbook.cxx
CommitLineData
7fd59977 1// File: TFunction_Logbook.cxx
2// Created: Tue Jul 20 15:03:19 1999
3// Author: Vladislav ROMASHKO
4// <vro@flox.nnov.matra-dtv.fr>
5
6
7#include <TFunction_Logbook.ixx>
8
9#include <TDF_Tool.hxx>
10#include <TDF_Label.hxx>
11#include <TDF_LabelMap.hxx>
12#include <TDF_MapIteratorOfLabelMap.hxx>
13#include <TDF_ChildIterator.hxx>
14
15#include <TCollection_AsciiString.hxx>
16
17#include <Standard_OStream.hxx>
18
19
20//=======================================================================
21//function : TFunction_Logbook
22//purpose : A Logbook creation
23//=======================================================================
24
25TFunction_Logbook::TFunction_Logbook():isDone(Standard_False)
26{}
27
28//=======================================================================
29//function : Clear
30//purpose : Clears the valid and modified labels
31//=======================================================================
32
33void TFunction_Logbook::Clear()
34{
35 myTouched.Clear();
36 myImpacted.Clear();
37 myValid.Clear();
38}
39
40//=======================================================================
41//function : IsEmpty
42//purpose : Returns Standard_True if the nothing is reccorded in the logbook
43//=======================================================================
44
45Standard_Boolean TFunction_Logbook::IsEmpty () const
46{
47 return (myTouched.IsEmpty() && myImpacted.IsEmpty() && myValid.IsEmpty());
48}
49
50//=======================================================================
51//function : IsModified
52//purpose : Returns Standard_True if the label is modified
53//=======================================================================
54
55Standard_Boolean TFunction_Logbook::IsModified(const TDF_Label& L,
56 const Standard_Boolean WithChildren) const
57{
58 if (myTouched.Contains(L)) return Standard_True;
59 if (myImpacted.Contains(L)) return Standard_True;
60 if (WithChildren) {
61 TDF_ChildIterator itr(L);
62 for (; itr.More(); itr.Next())
63 if (IsModified(itr.Value(), Standard_True))
64 return Standard_True;
65 }
66 return Standard_False;
67}
68
69//=======================================================================
70//function : SetValid
71//purpose :
72//=======================================================================
73
74void TFunction_Logbook::SetValid(const TDF_Label& L,
75 const Standard_Boolean WithChildren)
76{
77 myValid.Add(L);
78 if (WithChildren) {
79 TDF_ChildIterator itr(L, Standard_True);
80 for (; itr.More(); itr.Next()) {
81 myValid.Add(itr.Value());
82 }
83 }
84}
85
86//=======================================================================
87//function : SetImpacted
88//purpose :
89//=======================================================================
90
91void TFunction_Logbook::SetImpacted(const TDF_Label& L,
92 const Standard_Boolean WithChildren)
93{
94 myImpacted.Add(L);
95 if (WithChildren) {
96 TDF_ChildIterator itr(L, Standard_True);
97 for (; itr.More(); itr.Next()) {
98 myImpacted.Add(itr.Value());
99 }
100 }
101}
102
103//=======================================================================
104//function : Dump
105//purpose : Dump of modifications
106//=======================================================================
107
108Standard_OStream& TFunction_Logbook::Dump(Standard_OStream& stream) const
109{
110 TDF_MapIteratorOfLabelMap itr;
111 TCollection_AsciiString as;
112
113 stream<<"Done = "<<isDone<<endl;
114 stream<<"Touched labels: "<<endl;
115 for (itr.Initialize(myTouched); itr.More(); itr.Next()) {
116 TDF_Tool::Entry(itr.Key(), as);
117 stream<<as<<endl;
118 }
119 stream<<"Impacted labels: "<<endl;
120 for (itr.Initialize(myImpacted); itr.More(); itr.Next()) {
121 TDF_Tool::Entry(itr.Key(), as);
122 stream<<as<<endl;
123 }
124 stream<<"Valid labels: "<<endl;
125 for (itr.Initialize(myValid); itr.More(); itr.Next()) {
126 TDF_Tool::Entry(itr.Key(), as);
127 stream<<as<<endl;
128 }
129
130 return stream;
131}