summaryrefslogtreecommitdiff
path: root/src/TFunction/TFunction_Logbook.cxx
blob: 4635d27caa26ca1c166a246c9d9b5bac7a2bb7ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// File:	TFunction_Logbook.cxx
// Created:	Tue Jul 20 15:03:19 1999
// Author:	Vladislav ROMASHKO
//		<vro@flox.nnov.matra-dtv.fr>


#include <TFunction_Logbook.ixx>

#include <TDF_Tool.hxx>
#include <TDF_Label.hxx>
#include <TDF_LabelMap.hxx>
#include <TDF_MapIteratorOfLabelMap.hxx>
#include <TDF_ChildIterator.hxx>

#include <TCollection_AsciiString.hxx>

#include <Standard_OStream.hxx>


//=======================================================================
//function : TFunction_Logbook
//purpose  : A Logbook creation
//=======================================================================

TFunction_Logbook::TFunction_Logbook():isDone(Standard_False)
{}

//=======================================================================
//function : Clear
//purpose  : Clears the valid and modified labels
//=======================================================================

void TFunction_Logbook::Clear()
{
  myTouched.Clear();
  myImpacted.Clear();
  myValid.Clear();
}

//=======================================================================
//function : IsEmpty
//purpose  : Returns Standard_True if the nothing is reccorded in the logbook
//=======================================================================

Standard_Boolean TFunction_Logbook::IsEmpty () const
{
  return (myTouched.IsEmpty() && myImpacted.IsEmpty() && myValid.IsEmpty());
}

//=======================================================================
//function : IsModified
//purpose  : Returns Standard_True if the label is modified
//=======================================================================

Standard_Boolean TFunction_Logbook::IsModified(const TDF_Label& L,
					       const Standard_Boolean WithChildren) const
{
  if (myTouched.Contains(L)) return Standard_True;
  if (myImpacted.Contains(L)) return Standard_True;
  if (WithChildren) {
    TDF_ChildIterator itr(L);
    for (; itr.More(); itr.Next())
      if (IsModified(itr.Value(), Standard_True))
	return Standard_True;
  }
  return Standard_False;
}

//=======================================================================
//function : SetValid
//purpose  : 
//=======================================================================

void TFunction_Logbook::SetValid(const TDF_Label& L,
				 const Standard_Boolean WithChildren)
{
  myValid.Add(L);
  if (WithChildren) {
    TDF_ChildIterator itr(L, Standard_True);
    for (; itr.More(); itr.Next()) {
      myValid.Add(itr.Value());
    }
  }
}

//=======================================================================
//function : SetImpacted
//purpose  : 
//=======================================================================

void TFunction_Logbook::SetImpacted(const TDF_Label& L,
				    const Standard_Boolean WithChildren)
{
  myImpacted.Add(L);
  if (WithChildren) {
    TDF_ChildIterator itr(L, Standard_True);
    for (; itr.More(); itr.Next()) {
      myImpacted.Add(itr.Value());
    }
  }  
}

//=======================================================================
//function : Dump
//purpose  : Dump of modifications
//=======================================================================

Standard_OStream& TFunction_Logbook::Dump(Standard_OStream& stream) const
{
  TDF_MapIteratorOfLabelMap itr;
  TCollection_AsciiString as;
  
  stream<<"Done = "<<isDone<<endl;
  stream<<"Touched labels: "<<endl;
  for (itr.Initialize(myTouched); itr.More(); itr.Next()) {
    TDF_Tool::Entry(itr.Key(), as);
    stream<<as<<endl;
  }
  stream<<"Impacted labels: "<<endl;
  for (itr.Initialize(myImpacted); itr.More(); itr.Next()) {
    TDF_Tool::Entry(itr.Key(), as);
    stream<<as<<endl;
  }  
  stream<<"Valid labels: "<<endl;
  for (itr.Initialize(myValid); itr.More(); itr.Next()) {
    TDF_Tool::Entry(itr.Key(), as);
    stream<<as<<endl;
  }  

  return stream;
}