0029743: Samples - Inspector tool - crash by selecting TNaming_UsedShapes tree item
[occt.git] / src / TNaming / TNaming_UsedShapes.cxx
CommitLineData
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>
26#include <TNaming_Builder.hxx>
7fd59977 27#include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx>
997cf5f2 28#include <TNaming_PtrNode.hxx>
42cf5bc1 29#include <TNaming_RefShape.hxx>
30#include <TNaming_UsedShapes.hxx>
7fd59977 31#include <TopoDS_Shape.hxx>
7fd59977 32
92efcf78 33IMPLEMENT_STANDARD_RTTIEXT(TNaming_UsedShapes,TDF_Attribute)
34
7fd59977 35//=======================================================================
36//function : GetID
37//purpose :
38//=======================================================================
7fd59977 39const Standard_GUID& TNaming_UsedShapes::GetID()
40{
41 static Standard_GUID TNaming_UsedShapesID("c4ef4201-568f-11d1-8940-080009dc3333");
42 return TNaming_UsedShapesID;
43}
44
45//=======================================================================
46//function :
47//purpose :
48//=======================================================================
49
50TNaming_UsedShapes::TNaming_UsedShapes()
51{
52}
53
54
55//=======================================================================
56//function : Destroy
57//purpose :
58//=======================================================================
59
60void TNaming_UsedShapes::Destroy()
61{
7fd59977 62 myMap.Clear();
63}
64
65//=======================================================================
66//function : BackupCopy
67//purpose : No Backup
68//=======================================================================
69
70Handle(TDF_Attribute) TNaming_UsedShapes::BackupCopy() const
71{
72 Handle(TNaming_UsedShapes) Att;
73 return Att;
74}
75
76//=======================================================================
77//function : BeforeRemoval
78//purpose :
79//=======================================================================
80
81void TNaming_UsedShapes::BeforeRemoval()
82{
7fd59977 83 Destroy();
7fd59977 84}
85
86
87//=======================================================================
88//function : AfterUndo
89//purpose : After application of a TDF_Delta.
90//=======================================================================
91
92Standard_Boolean TNaming_UsedShapes::AfterUndo
93(const Handle(TDF_AttributeDelta)& anAttDelta,
35e08fe8 94 const Standard_Boolean /*forceIt*/)
7fd59977 95{
96 if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {
97 anAttDelta->Attribute()->BeforeRemoval();
98 }
99 return Standard_True;
100}
101
102//=======================================================================
103//function : DeltaOnAddition
104//purpose : no delta
105//=======================================================================
106
107Handle(TDF_DeltaOnAddition) TNaming_UsedShapes::DeltaOnAddition() const
108{
109 Handle(TDF_DeltaOnAddition) aDelta;
110 return aDelta;
111}
112//=======================================================================
113//function : DeltaOnRemoval
114//purpose : no delta
115//=======================================================================
116
117Handle(TDF_DeltaOnRemoval) TNaming_UsedShapes::DeltaOnRemoval() const
118{
119 Handle(TDF_DeltaOnRemoval) aDelta;
120 return aDelta;
121}
122
123//=======================================================================
124//function : Restore
125//purpose :
126//=======================================================================
127
35e08fe8 128void TNaming_UsedShapes::Restore(const Handle(TDF_Attribute)& /*anAttribute*/)
7fd59977 129{
130}
131
132//=======================================================================
133//function : NewEmpty
134//purpose :
135//=======================================================================
136
137Handle(TDF_Attribute) TNaming_UsedShapes::NewEmpty () const
138{
139 return new TNaming_UsedShapes();
140}
141
142//=======================================================================
143//function : Paste
144//purpose :
145//=======================================================================
146
35e08fe8 147void TNaming_UsedShapes::Paste(const Handle(TDF_Attribute)&,
148 const Handle(TDF_RelocationTable)&) const
7fd59977 149{
150}
151
152//=======================================================================
153//function : Dump
154//purpose :
155//=======================================================================
156
157Standard_OStream& TNaming_UsedShapes::Dump(Standard_OStream& anOS) const
158{
7fd59977 159 anOS<<"The content of UsedShapes attribute:"<<endl;
160 TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape itr(myMap);
161 for (; itr.More(); itr.Next()) {
26b004e9 162 if (itr.Key().IsNull())
163 {
164 anOS << "Empty Shape at label =";
165 itr.Value()->Label().EntryDump(anOS);
166 anOS << endl;
167 continue;
168 }
169 anOS << " ";
7fd59977 170 TopAbs::Print(itr.Key().ShapeType(),anOS);
171 anOS<<" ";
172 itr.Value()->Label().EntryDump(anOS);
173 anOS << " Key_TShape = " <<itr.Key().TShape()->This();
174 anOS << " Value_TShape = " <<itr.Value()->Shape().TShape()->This();
175 anOS<<endl;
176 }
7fd59977 177 return anOS;
178}
179
180//=======================================================================
181//function : References
182//purpose :
183//=======================================================================
184
35e08fe8 185void TNaming_UsedShapes::References(const Handle(TDF_DataSet)& ) const
7fd59977 186{
187}