b311480e |
1 | // Created on: 1997-02-18 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1997-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 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
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 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Standard_GUID.hxx> |
19 | #include <Standard_Type.hxx> |
20 | #include <TDF_Attribute.hxx> |
21 | #include <TDF_AttributeDelta.hxx> |
22 | #include <TDF_DataSet.hxx> |
7fd59977 |
23 | #include <TDF_DeltaOnAddition.hxx> |
42cf5bc1 |
24 | #include <TDF_DeltaOnRemoval.hxx> |
25 | #include <TDF_RelocationTable.hxx> |
bc73b006 |
26 | #include <TDF_Tool.hxx> |
42cf5bc1 |
27 | #include <TNaming_Builder.hxx> |
7fd59977 |
28 | #include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx> |
997cf5f2 |
29 | #include <TNaming_PtrNode.hxx> |
42cf5bc1 |
30 | #include <TNaming_RefShape.hxx> |
31 | #include <TNaming_UsedShapes.hxx> |
7fd59977 |
32 | #include <TopoDS_Shape.hxx> |
7fd59977 |
33 | |
92efcf78 |
34 | IMPLEMENT_STANDARD_RTTIEXT(TNaming_UsedShapes,TDF_Attribute) |
35 | |
7fd59977 |
36 | //======================================================================= |
37 | //function : GetID |
38 | //purpose : |
39 | //======================================================================= |
7fd59977 |
40 | const Standard_GUID& TNaming_UsedShapes::GetID() |
41 | { |
42 | static Standard_GUID TNaming_UsedShapesID("c4ef4201-568f-11d1-8940-080009dc3333"); |
43 | return TNaming_UsedShapesID; |
44 | } |
45 | |
46 | //======================================================================= |
47 | //function : |
48 | //purpose : |
49 | //======================================================================= |
50 | |
51 | TNaming_UsedShapes::TNaming_UsedShapes() |
52 | { |
53 | } |
54 | |
55 | |
56 | //======================================================================= |
57 | //function : Destroy |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | void TNaming_UsedShapes::Destroy() |
62 | { |
7fd59977 |
63 | myMap.Clear(); |
64 | } |
65 | |
66 | //======================================================================= |
67 | //function : BackupCopy |
68 | //purpose : No Backup |
69 | //======================================================================= |
70 | |
71 | Handle(TDF_Attribute) TNaming_UsedShapes::BackupCopy() const |
72 | { |
73 | Handle(TNaming_UsedShapes) Att; |
74 | return Att; |
75 | } |
76 | |
77 | //======================================================================= |
78 | //function : BeforeRemoval |
79 | //purpose : |
80 | //======================================================================= |
81 | |
82 | void TNaming_UsedShapes::BeforeRemoval() |
83 | { |
7fd59977 |
84 | Destroy(); |
7fd59977 |
85 | } |
86 | |
87 | |
88 | //======================================================================= |
89 | //function : AfterUndo |
90 | //purpose : After application of a TDF_Delta. |
91 | //======================================================================= |
92 | |
93 | Standard_Boolean TNaming_UsedShapes::AfterUndo |
94 | (const Handle(TDF_AttributeDelta)& anAttDelta, |
35e08fe8 |
95 | const Standard_Boolean /*forceIt*/) |
7fd59977 |
96 | { |
97 | if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) { |
98 | anAttDelta->Attribute()->BeforeRemoval(); |
99 | } |
100 | return Standard_True; |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : DeltaOnAddition |
105 | //purpose : no delta |
106 | //======================================================================= |
107 | |
108 | Handle(TDF_DeltaOnAddition) TNaming_UsedShapes::DeltaOnAddition() const |
109 | { |
110 | Handle(TDF_DeltaOnAddition) aDelta; |
111 | return aDelta; |
112 | } |
113 | //======================================================================= |
114 | //function : DeltaOnRemoval |
115 | //purpose : no delta |
116 | //======================================================================= |
117 | |
118 | Handle(TDF_DeltaOnRemoval) TNaming_UsedShapes::DeltaOnRemoval() const |
119 | { |
120 | Handle(TDF_DeltaOnRemoval) aDelta; |
121 | return aDelta; |
122 | } |
123 | |
124 | //======================================================================= |
125 | //function : Restore |
126 | //purpose : |
127 | //======================================================================= |
128 | |
35e08fe8 |
129 | void TNaming_UsedShapes::Restore(const Handle(TDF_Attribute)& /*anAttribute*/) |
7fd59977 |
130 | { |
131 | } |
132 | |
133 | //======================================================================= |
134 | //function : NewEmpty |
135 | //purpose : |
136 | //======================================================================= |
137 | |
138 | Handle(TDF_Attribute) TNaming_UsedShapes::NewEmpty () const |
139 | { |
140 | return new TNaming_UsedShapes(); |
141 | } |
142 | |
143 | //======================================================================= |
144 | //function : Paste |
145 | //purpose : |
146 | //======================================================================= |
147 | |
35e08fe8 |
148 | void TNaming_UsedShapes::Paste(const Handle(TDF_Attribute)&, |
149 | const Handle(TDF_RelocationTable)&) const |
7fd59977 |
150 | { |
151 | } |
152 | |
153 | //======================================================================= |
154 | //function : Dump |
155 | //purpose : |
156 | //======================================================================= |
157 | |
158 | Standard_OStream& TNaming_UsedShapes::Dump(Standard_OStream& anOS) const |
159 | { |
04232180 |
160 | anOS<<"The content of UsedShapes attribute:"<<std::endl; |
7fd59977 |
161 | TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape itr(myMap); |
162 | for (; itr.More(); itr.Next()) { |
26b004e9 |
163 | if (itr.Key().IsNull()) |
164 | { |
165 | anOS << "Empty Shape at label ="; |
166 | itr.Value()->Label().EntryDump(anOS); |
04232180 |
167 | anOS << std::endl; |
26b004e9 |
168 | continue; |
169 | } |
170 | anOS << " "; |
7fd59977 |
171 | TopAbs::Print(itr.Key().ShapeType(),anOS); |
172 | anOS<<" "; |
173 | itr.Value()->Label().EntryDump(anOS); |
174 | anOS << " Key_TShape = " <<itr.Key().TShape()->This(); |
175 | anOS << " Value_TShape = " <<itr.Value()->Shape().TShape()->This(); |
04232180 |
176 | anOS<<std::endl; |
7fd59977 |
177 | } |
7fd59977 |
178 | return anOS; |
179 | } |
180 | |
181 | //======================================================================= |
182 | //function : References |
183 | //purpose : |
184 | //======================================================================= |
185 | |
35e08fe8 |
186 | void TNaming_UsedShapes::References(const Handle(TDF_DataSet)& ) const |
7fd59977 |
187 | { |
188 | } |
bc73b006 |
189 | |
190 | //======================================================================= |
191 | //function : DumpJson |
192 | //purpose : |
193 | //======================================================================= |
194 | void TNaming_UsedShapes::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
195 | { |
196 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
197 | |
198 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute) |
199 | |
200 | for (TNaming_DataMapOfShapePtrRefShape::Iterator aMapIt (myMap); aMapIt.More(); aMapIt.Next()) |
201 | { |
202 | const TopoDS_Shape& aShape = aMapIt.Key(); |
203 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aShape) |
204 | |
205 | TCollection_AsciiString aLabel; |
206 | TDF_Tool::Entry (aMapIt.Value()->Label(), aLabel); |
207 | OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aLabel) |
208 | |
209 | const TopoDS_Shape& aRefShape = aMapIt.Value()->Shape(); |
210 | |
211 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aRefShape) |
212 | } |
213 | } |