7fd59977 |
1 | // File: TNaming_UsedShapes.cxx |
2 | // Created: Tue Feb 18 15:33:00 1997 |
3 | // Author: Yves FRICAUD |
4 | // <yfr@claquox.paris1.matra-dtv.fr> |
5 | |
6 | |
7 | #include <TNaming_UsedShapes.ixx> |
8 | |
9 | #include <TDF_DeltaOnAddition.hxx> |
10 | #include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx> |
11 | #include <TNaming_RefShape.hxx> |
12 | |
13 | #define BUC60862 |
14 | |
15 | #ifdef BUC60862 |
16 | #include <TopoDS_Shape.hxx> |
17 | #endif |
18 | |
19 | #define BUC60921 //SRN 15/05/01 : Fixes the memory leak due to pointer to RefShape is not deleted |
20 | |
21 | //======================================================================= |
22 | //function : GetID |
23 | //purpose : |
24 | //======================================================================= |
25 | |
26 | const Standard_GUID& TNaming_UsedShapes::GetID() |
27 | { |
28 | static Standard_GUID TNaming_UsedShapesID("c4ef4201-568f-11d1-8940-080009dc3333"); |
29 | return TNaming_UsedShapesID; |
30 | } |
31 | |
32 | //======================================================================= |
33 | //function : |
34 | //purpose : |
35 | //======================================================================= |
36 | |
37 | TNaming_UsedShapes::TNaming_UsedShapes() |
38 | { |
39 | } |
40 | |
41 | |
42 | //======================================================================= |
43 | //function : Destroy |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | void TNaming_UsedShapes::Destroy() |
48 | { |
49 | TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape itr(myMap); |
50 | for (; itr.More(); itr.Next()) { |
51 | if(itr.Value() != NULL) delete itr.Value(); // <== szy: removed "//" |
52 | } |
53 | myMap.Clear(); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : BackupCopy |
58 | //purpose : No Backup |
59 | //======================================================================= |
60 | |
61 | Handle(TDF_Attribute) TNaming_UsedShapes::BackupCopy() const |
62 | { |
63 | Handle(TNaming_UsedShapes) Att; |
64 | return Att; |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : BeforeRemoval |
69 | //purpose : |
70 | //======================================================================= |
71 | |
72 | void TNaming_UsedShapes::BeforeRemoval() |
73 | { |
74 | #ifdef BUC60921 |
75 | Destroy(); |
76 | #else |
77 | myMap.Clear(); |
78 | #endif |
79 | } |
80 | |
81 | |
82 | //======================================================================= |
83 | //function : AfterUndo |
84 | //purpose : After application of a TDF_Delta. |
85 | //======================================================================= |
86 | |
87 | Standard_Boolean TNaming_UsedShapes::AfterUndo |
88 | (const Handle(TDF_AttributeDelta)& anAttDelta, |
89 | const Standard_Boolean forceIt) |
90 | { |
91 | if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) { |
92 | anAttDelta->Attribute()->BeforeRemoval(); |
93 | } |
94 | return Standard_True; |
95 | } |
96 | |
97 | //======================================================================= |
98 | //function : DeltaOnAddition |
99 | //purpose : no delta |
100 | //======================================================================= |
101 | |
102 | Handle(TDF_DeltaOnAddition) TNaming_UsedShapes::DeltaOnAddition() const |
103 | { |
104 | Handle(TDF_DeltaOnAddition) aDelta; |
105 | return aDelta; |
106 | } |
107 | //======================================================================= |
108 | //function : DeltaOnRemoval |
109 | //purpose : no delta |
110 | //======================================================================= |
111 | |
112 | Handle(TDF_DeltaOnRemoval) TNaming_UsedShapes::DeltaOnRemoval() const |
113 | { |
114 | Handle(TDF_DeltaOnRemoval) aDelta; |
115 | return aDelta; |
116 | } |
117 | |
118 | //======================================================================= |
119 | //function : Restore |
120 | //purpose : |
121 | //======================================================================= |
122 | |
123 | void TNaming_UsedShapes::Restore(const Handle(TDF_Attribute)& anAttribute) |
124 | { |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : NewEmpty |
129 | //purpose : |
130 | //======================================================================= |
131 | |
132 | Handle(TDF_Attribute) TNaming_UsedShapes::NewEmpty () const |
133 | { |
134 | return new TNaming_UsedShapes(); |
135 | } |
136 | |
137 | //======================================================================= |
138 | //function : Paste |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | void TNaming_UsedShapes::Paste(const Handle(TDF_Attribute)& into, |
143 | const Handle(TDF_RelocationTable)& Tab) const |
144 | { |
145 | } |
146 | |
147 | //======================================================================= |
148 | //function : Dump |
149 | //purpose : |
150 | //======================================================================= |
151 | |
152 | Standard_OStream& TNaming_UsedShapes::Dump(Standard_OStream& anOS) const |
153 | { |
154 | #ifdef BUC60862 |
155 | anOS<<"The content of UsedShapes attribute:"<<endl; |
156 | TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape itr(myMap); |
157 | for (; itr.More(); itr.Next()) { |
158 | anOS<<" "; |
159 | TopAbs::Print(itr.Key().ShapeType(),anOS); |
160 | anOS<<" "; |
161 | itr.Value()->Label().EntryDump(anOS); |
162 | anOS << " Key_TShape = " <<itr.Key().TShape()->This(); |
163 | anOS << " Value_TShape = " <<itr.Value()->Shape().TShape()->This(); |
164 | anOS<<endl; |
165 | } |
166 | #endif |
167 | return anOS; |
168 | } |
169 | |
170 | //======================================================================= |
171 | //function : References |
172 | //purpose : |
173 | //======================================================================= |
174 | |
175 | void TNaming_UsedShapes::References(const Handle(TDF_DataSet)& aDataSet) const |
176 | { |
177 | } |