1 // Created on: 1997-02-18
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
23 #include <TNaming_UsedShapes.ixx>
25 #include <TDF_DeltaOnAddition.hxx>
26 #include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx>
27 #include <TNaming_RefShape.hxx>
28 #include <TNaming_PtrNode.hxx>
32 #include <TopoDS_Shape.hxx>
35 #define BUC60921 //SRN 15/05/01 : Fixes the memory leak due to pointer to RefShape is not deleted
37 //=======================================================================
40 //=======================================================================
42 const Standard_GUID& TNaming_UsedShapes::GetID()
44 static Standard_GUID TNaming_UsedShapesID("c4ef4201-568f-11d1-8940-080009dc3333");
45 return TNaming_UsedShapesID;
48 //=======================================================================
51 //=======================================================================
53 TNaming_UsedShapes::TNaming_UsedShapes()
58 //=======================================================================
61 //=======================================================================
63 void TNaming_UsedShapes::Destroy()
68 //=======================================================================
69 //function : BackupCopy
71 //=======================================================================
73 Handle(TDF_Attribute) TNaming_UsedShapes::BackupCopy() const
75 Handle(TNaming_UsedShapes) Att;
79 //=======================================================================
80 //function : BeforeRemoval
82 //=======================================================================
84 void TNaming_UsedShapes::BeforeRemoval()
94 //=======================================================================
95 //function : AfterUndo
96 //purpose : After application of a TDF_Delta.
97 //=======================================================================
99 Standard_Boolean TNaming_UsedShapes::AfterUndo
100 (const Handle(TDF_AttributeDelta)& anAttDelta,
101 const Standard_Boolean /*forceIt*/)
103 if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
104 anAttDelta->Attribute()->BeforeRemoval();
106 return Standard_True;
109 //=======================================================================
110 //function : DeltaOnAddition
112 //=======================================================================
114 Handle(TDF_DeltaOnAddition) TNaming_UsedShapes::DeltaOnAddition() const
116 Handle(TDF_DeltaOnAddition) aDelta;
119 //=======================================================================
120 //function : DeltaOnRemoval
122 //=======================================================================
124 Handle(TDF_DeltaOnRemoval) TNaming_UsedShapes::DeltaOnRemoval() const
126 Handle(TDF_DeltaOnRemoval) aDelta;
130 //=======================================================================
133 //=======================================================================
135 void TNaming_UsedShapes::Restore(const Handle(TDF_Attribute)& /*anAttribute*/)
139 //=======================================================================
140 //function : NewEmpty
142 //=======================================================================
144 Handle(TDF_Attribute) TNaming_UsedShapes::NewEmpty () const
146 return new TNaming_UsedShapes();
149 //=======================================================================
152 //=======================================================================
154 void TNaming_UsedShapes::Paste(const Handle(TDF_Attribute)&,
155 const Handle(TDF_RelocationTable)&) const
159 //=======================================================================
162 //=======================================================================
164 Standard_OStream& TNaming_UsedShapes::Dump(Standard_OStream& anOS) const
167 anOS<<"The content of UsedShapes attribute:"<<endl;
168 TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape itr(myMap);
169 for (; itr.More(); itr.Next()) {
171 TopAbs::Print(itr.Key().ShapeType(),anOS);
173 itr.Value()->Label().EntryDump(anOS);
174 anOS << " Key_TShape = " <<itr.Key().TShape()->This();
175 anOS << " Value_TShape = " <<itr.Value()->Shape().TShape()->This();
182 //=======================================================================
183 //function : References
185 //=======================================================================
187 void TNaming_UsedShapes::References(const Handle(TDF_DataSet)& ) const