b311480e |
1 | // Created on: 1999-07-20 |
2 | // Created by: Vladislav ROMASHKO |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
973c2be1 |
8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public 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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <TFunction_Logbook.ixx> |
18 | |
19 | #include <TDF_Tool.hxx> |
20 | #include <TDF_Label.hxx> |
21 | #include <TDF_LabelMap.hxx> |
22 | #include <TDF_MapIteratorOfLabelMap.hxx> |
23 | #include <TDF_ChildIterator.hxx> |
24 | |
25 | #include <TCollection_AsciiString.hxx> |
26 | |
27 | #include <Standard_OStream.hxx> |
28 | |
29 | |
30 | //======================================================================= |
31 | //function : TFunction_Logbook |
32 | //purpose : A Logbook creation |
33 | //======================================================================= |
34 | |
35 | TFunction_Logbook::TFunction_Logbook():isDone(Standard_False) |
36 | {} |
37 | |
38 | //======================================================================= |
39 | //function : Clear |
40 | //purpose : Clears the valid and modified labels |
41 | //======================================================================= |
42 | |
43 | void TFunction_Logbook::Clear() |
44 | { |
45 | myTouched.Clear(); |
46 | myImpacted.Clear(); |
47 | myValid.Clear(); |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : IsEmpty |
52 | //purpose : Returns Standard_True if the nothing is reccorded in the logbook |
53 | //======================================================================= |
54 | |
55 | Standard_Boolean TFunction_Logbook::IsEmpty () const |
56 | { |
57 | return (myTouched.IsEmpty() && myImpacted.IsEmpty() && myValid.IsEmpty()); |
58 | } |
59 | |
60 | //======================================================================= |
61 | //function : IsModified |
62 | //purpose : Returns Standard_True if the label is modified |
63 | //======================================================================= |
64 | |
65 | Standard_Boolean TFunction_Logbook::IsModified(const TDF_Label& L, |
66 | const Standard_Boolean WithChildren) const |
67 | { |
68 | if (myTouched.Contains(L)) return Standard_True; |
69 | if (myImpacted.Contains(L)) return Standard_True; |
70 | if (WithChildren) { |
71 | TDF_ChildIterator itr(L); |
72 | for (; itr.More(); itr.Next()) |
73 | if (IsModified(itr.Value(), Standard_True)) |
74 | return Standard_True; |
75 | } |
76 | return Standard_False; |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : SetValid |
81 | //purpose : |
82 | //======================================================================= |
83 | |
84 | void TFunction_Logbook::SetValid(const TDF_Label& L, |
85 | const Standard_Boolean WithChildren) |
86 | { |
87 | myValid.Add(L); |
88 | if (WithChildren) { |
89 | TDF_ChildIterator itr(L, Standard_True); |
90 | for (; itr.More(); itr.Next()) { |
91 | myValid.Add(itr.Value()); |
92 | } |
93 | } |
94 | } |
95 | |
96 | //======================================================================= |
97 | //function : SetImpacted |
98 | //purpose : |
99 | //======================================================================= |
100 | |
101 | void TFunction_Logbook::SetImpacted(const TDF_Label& L, |
102 | const Standard_Boolean WithChildren) |
103 | { |
104 | myImpacted.Add(L); |
105 | if (WithChildren) { |
106 | TDF_ChildIterator itr(L, Standard_True); |
107 | for (; itr.More(); itr.Next()) { |
108 | myImpacted.Add(itr.Value()); |
109 | } |
110 | } |
111 | } |
112 | |
113 | //======================================================================= |
114 | //function : Dump |
115 | //purpose : Dump of modifications |
116 | //======================================================================= |
117 | |
118 | Standard_OStream& TFunction_Logbook::Dump(Standard_OStream& stream) const |
119 | { |
120 | TDF_MapIteratorOfLabelMap itr; |
121 | TCollection_AsciiString as; |
122 | |
123 | stream<<"Done = "<<isDone<<endl; |
124 | stream<<"Touched labels: "<<endl; |
125 | for (itr.Initialize(myTouched); itr.More(); itr.Next()) { |
126 | TDF_Tool::Entry(itr.Key(), as); |
127 | stream<<as<<endl; |
128 | } |
129 | stream<<"Impacted labels: "<<endl; |
130 | for (itr.Initialize(myImpacted); itr.More(); itr.Next()) { |
131 | TDF_Tool::Entry(itr.Key(), as); |
132 | stream<<as<<endl; |
133 | } |
134 | stream<<"Valid labels: "<<endl; |
135 | for (itr.Initialize(myValid); itr.More(); itr.Next()) { |
136 | TDF_Tool::Entry(itr.Key(), as); |
137 | stream<<as<<endl; |
138 | } |
139 | |
140 | return stream; |
141 | } |