blob: 292f9ba5459b94ba584dc3c6b946ff12fc0c76c8 (
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
|
// File: TDataStd_DeltaOnModificationOfIntPackedMap.cxx
// Created: Wed Jan 23 11:05:47 2008
// Author: Sergey ZARITCHNY
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2008
#include <TDataStd_DeltaOnModificationOfIntPackedMap.ixx>
#include <TDF_DeltaOnModification.hxx>
#include <TDF_Label.hxx>
#include <TColStd_PackedMapOfInteger.hxx>
#include <TColStd_HPackedMapOfInteger.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#ifdef DEB
#define MAXUP 1000
#endif
//=======================================================================
//function : TDataStd_DeltaOnModificationOfIntPackedMap
//purpose :
//=======================================================================
TDataStd_DeltaOnModificationOfIntPackedMap::TDataStd_DeltaOnModificationOfIntPackedMap(
const Handle(TDataStd_IntPackedMap)& OldAtt)
: TDF_DeltaOnModification(OldAtt)
{
Handle(TDataStd_IntPackedMap) CurrAtt;
if (Label().FindAttribute(OldAtt->ID(),CurrAtt)) {
{
Handle(TColStd_HPackedMapOfInteger) aMap1, aMap2;
aMap1 = OldAtt->GetHMap();
aMap2 = CurrAtt->GetHMap();
#ifdef DEB
if(aMap1.IsNull())
cout <<"DeltaOnModificationOfIntPackedMap:: Old Map is Null" <<endl;
if(aMap2.IsNull())
cout <<"DeltaOnModificationOfIntPackedMap:: Current Map is Null" <<endl;
#endif
if(aMap1.IsNull() || aMap2.IsNull()) return;
if(aMap1 != aMap2) {
if(!aMap1->Map().HasIntersection(aMap2->Map()))
return; // no intersection: use full-scale backup
if(aMap1->Map().IsSubset(aMap2->Map())) {
myDeletion = new TColStd_HPackedMapOfInteger();
myDeletion->ChangeMap().Subtraction(aMap2->Map(), aMap1->Map());
} else if(aMap2->Map().IsSubset(aMap1->Map())) {
myAddition = new TColStd_HPackedMapOfInteger();
myAddition->ChangeMap().Subtraction(aMap1->Map(), aMap2->Map());
} else {
myAddition = new TColStd_HPackedMapOfInteger();
myAddition->ChangeMap().Subtraction(aMap1->Map(), aMap2->Map());
myDeletion = new TColStd_HPackedMapOfInteger();
myDeletion->ChangeMap().Subtraction(aMap2->Map(), aMap1->Map());
}
}
}
OldAtt->RemoveMap();
#ifdef DEB
if(OldAtt->GetHMap().IsNull())
cout << "BackUp Arr is Nullified" << endl;
#endif
}
}
//=======================================================================
//function : Apply
//purpose :
//=======================================================================
void TDataStd_DeltaOnModificationOfIntPackedMap::Apply()
{
Handle(TDF_Attribute) aTDFAttribute = Attribute();
Handle(TDataStd_IntPackedMap) aBackAtt = (*((Handle(TDataStd_IntPackedMap)*)&aTDFAttribute));
if(aBackAtt.IsNull()) {
#ifdef DEB
cout << "DeltaOnModificationOfIntPAckedMap::Apply: OldAtt is Null" <<endl;
#endif
return;
}
Handle(TDataStd_IntPackedMap) aCurAtt;
if (!Label().FindAttribute(aBackAtt->ID(),aCurAtt)) {
Label().AddAttribute(aBackAtt);
}
if(aCurAtt.IsNull()) {
#ifdef DEB
cout << "DeltaOnModificationOfIntAPckedMAp::Apply: CurAtt is Null" <<endl;
#endif
return;
}
else
aCurAtt->Backup();
Handle(TColStd_HPackedMapOfInteger) IntMap = aCurAtt->GetHMap();
if(IntMap.IsNull()) return;
if(myDeletion.IsNull() && myAddition.IsNull())
return;
else {
if(!myDeletion.IsNull()) {
if(myDeletion->Map().Extent())
IntMap->ChangeMap().Subtract(myDeletion->Map());
}
if(!myAddition.IsNull()) {
if(myAddition->Map().Extent())
IntMap->ChangeMap().Unite(myAddition->Map());
}
}
#ifdef DEB
cout << " << Map Dump after Delta Apply >>" <<endl;
Handle(TColStd_HPackedMapOfInteger) aIntMap = aCurAtt->GetHMap();
TColStd_MapIteratorOfPackedMapOfInteger it(aIntMap->Map());
for (Standard_Integer i=1;it.More() && i <= MAXUP; it.Next(), i++)
cout << it.Key() << " ";
cout <<endl;
#endif
}
|