b311480e |
1 | // Created on: 1999-07-20 |
2 | // Created by: Vladislav ROMASHKO |
3 | // Copyright (c) 1999-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <TFunction_Logbook.ixx> |
24 | |
25 | #include <TDF_Tool.hxx> |
26 | #include <TDF_Label.hxx> |
27 | #include <TDF_LabelMap.hxx> |
28 | #include <TDF_MapIteratorOfLabelMap.hxx> |
29 | #include <TDF_ChildIterator.hxx> |
30 | |
31 | #include <TCollection_AsciiString.hxx> |
32 | |
33 | #include <Standard_OStream.hxx> |
34 | |
35 | |
36 | //======================================================================= |
37 | //function : TFunction_Logbook |
38 | //purpose : A Logbook creation |
39 | //======================================================================= |
40 | |
41 | TFunction_Logbook::TFunction_Logbook():isDone(Standard_False) |
42 | {} |
43 | |
44 | //======================================================================= |
45 | //function : Clear |
46 | //purpose : Clears the valid and modified labels |
47 | //======================================================================= |
48 | |
49 | void TFunction_Logbook::Clear() |
50 | { |
51 | myTouched.Clear(); |
52 | myImpacted.Clear(); |
53 | myValid.Clear(); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : IsEmpty |
58 | //purpose : Returns Standard_True if the nothing is reccorded in the logbook |
59 | //======================================================================= |
60 | |
61 | Standard_Boolean TFunction_Logbook::IsEmpty () const |
62 | { |
63 | return (myTouched.IsEmpty() && myImpacted.IsEmpty() && myValid.IsEmpty()); |
64 | } |
65 | |
66 | //======================================================================= |
67 | //function : IsModified |
68 | //purpose : Returns Standard_True if the label is modified |
69 | //======================================================================= |
70 | |
71 | Standard_Boolean TFunction_Logbook::IsModified(const TDF_Label& L, |
72 | const Standard_Boolean WithChildren) const |
73 | { |
74 | if (myTouched.Contains(L)) return Standard_True; |
75 | if (myImpacted.Contains(L)) return Standard_True; |
76 | if (WithChildren) { |
77 | TDF_ChildIterator itr(L); |
78 | for (; itr.More(); itr.Next()) |
79 | if (IsModified(itr.Value(), Standard_True)) |
80 | return Standard_True; |
81 | } |
82 | return Standard_False; |
83 | } |
84 | |
85 | //======================================================================= |
86 | //function : SetValid |
87 | //purpose : |
88 | //======================================================================= |
89 | |
90 | void TFunction_Logbook::SetValid(const TDF_Label& L, |
91 | const Standard_Boolean WithChildren) |
92 | { |
93 | myValid.Add(L); |
94 | if (WithChildren) { |
95 | TDF_ChildIterator itr(L, Standard_True); |
96 | for (; itr.More(); itr.Next()) { |
97 | myValid.Add(itr.Value()); |
98 | } |
99 | } |
100 | } |
101 | |
102 | //======================================================================= |
103 | //function : SetImpacted |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | void TFunction_Logbook::SetImpacted(const TDF_Label& L, |
108 | const Standard_Boolean WithChildren) |
109 | { |
110 | myImpacted.Add(L); |
111 | if (WithChildren) { |
112 | TDF_ChildIterator itr(L, Standard_True); |
113 | for (; itr.More(); itr.Next()) { |
114 | myImpacted.Add(itr.Value()); |
115 | } |
116 | } |
117 | } |
118 | |
119 | //======================================================================= |
120 | //function : Dump |
121 | //purpose : Dump of modifications |
122 | //======================================================================= |
123 | |
124 | Standard_OStream& TFunction_Logbook::Dump(Standard_OStream& stream) const |
125 | { |
126 | TDF_MapIteratorOfLabelMap itr; |
127 | TCollection_AsciiString as; |
128 | |
129 | stream<<"Done = "<<isDone<<endl; |
130 | stream<<"Touched labels: "<<endl; |
131 | for (itr.Initialize(myTouched); itr.More(); itr.Next()) { |
132 | TDF_Tool::Entry(itr.Key(), as); |
133 | stream<<as<<endl; |
134 | } |
135 | stream<<"Impacted labels: "<<endl; |
136 | for (itr.Initialize(myImpacted); itr.More(); itr.Next()) { |
137 | TDF_Tool::Entry(itr.Key(), as); |
138 | stream<<as<<endl; |
139 | } |
140 | stream<<"Valid labels: "<<endl; |
141 | for (itr.Initialize(myValid); itr.More(); itr.Next()) { |
142 | TDF_Tool::Entry(itr.Key(), as); |
143 | stream<<as<<endl; |
144 | } |
145 | |
146 | return stream; |
147 | } |