0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / TDF / TDF_Reference.cxx
1 // Created on: 2000-03-01
2 // Created by: Denis PASCAL
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <TDF_Reference.hxx>
17
18 #include <Standard_Dump.hxx>
19 #include <Standard_GUID.hxx>
20 #include <Standard_Type.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <TDF_DataSet.hxx>
23 #include <TDF_Label.hxx>
24 #include <TDF_RelocationTable.hxx>
25 #include <TDF_Tool.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(TDF_Reference,TDF_Attribute)
28
29 //=======================================================================
30 //function : GetID
31 //purpose  : 
32 //=======================================================================
33 const Standard_GUID& TDF_Reference::GetID () 
34 {
35   static Standard_GUID TDF_ReferenceID("2a96b610-ec8b-11d0-bee7-080009dc3333");
36   return TDF_ReferenceID;
37 }
38
39 //=======================================================================
40 //function : Set
41 //purpose  : 
42 //=======================================================================
43
44 Handle(TDF_Reference) TDF_Reference::Set (const TDF_Label& L,
45                                           const TDF_Label& Origin) 
46 {
47   Handle(TDF_Reference) A;
48   if (!L.FindAttribute (TDF_Reference::GetID (),A)) {
49     A = new TDF_Reference ();
50     L.AddAttribute (A);
51   }
52   A->Set (Origin); 
53   return A;
54 }
55
56 //=======================================================================
57 //function : TDF_Reference
58 //purpose  : Empty Constructor
59 //=======================================================================
60
61 TDF_Reference::TDF_Reference () { }
62
63
64 //=======================================================================
65 //function : Set
66 //purpose  : 
67 //=======================================================================
68
69 void TDF_Reference::Set(const TDF_Label& Origin) 
70 {
71   // OCC2932 correction
72   if(myOrigin == Origin) return;
73
74   Backup();
75   myOrigin = Origin;
76 }
77
78 //=======================================================================
79 //function : Get
80 //purpose  : 
81 //=======================================================================
82
83 TDF_Label TDF_Reference::Get() const
84 {
85   return myOrigin;
86 }
87
88
89 //=======================================================================
90 //function : ID
91 //purpose  : 
92 //=======================================================================
93
94 const Standard_GUID& TDF_Reference::ID() const { return GetID(); }
95
96
97 //=======================================================================
98 //function : NewEmpty
99 //purpose  : 
100 //=======================================================================
101
102 Handle(TDF_Attribute) TDF_Reference::NewEmpty () const
103 {  
104   return new TDF_Reference(); 
105 }
106
107 //=======================================================================
108 //function : Restore
109 //purpose  : 
110 //=======================================================================
111
112 void TDF_Reference::Restore(const Handle(TDF_Attribute)& With) 
113 {
114   myOrigin = Handle(TDF_Reference)::DownCast (With)->Get ();
115 }
116
117 //=======================================================================
118 //function : Paste
119 //purpose  : 
120 //=======================================================================
121
122 void TDF_Reference::Paste (const Handle(TDF_Attribute)& Into,
123                                 const Handle(TDF_RelocationTable)& RT) const
124 {
125   TDF_Label tLab;
126   if (!myOrigin.IsNull()) {
127     if (!RT->HasRelocation(myOrigin,tLab)) tLab = myOrigin;
128   }
129   Handle(TDF_Reference)::DownCast(Into)->Set(tLab);
130 }
131 //=======================================================================
132 //function : References
133 //purpose  : Adds the referenced attributes or labels.
134 //=======================================================================
135
136 void TDF_Reference::References(const Handle(TDF_DataSet)& aDataSet) const
137 {
138   if (!Label().IsImported()) aDataSet->AddLabel( myOrigin); //pour real et entier mais surtout pas les parts ...
139 }
140
141 //=======================================================================
142 //function : Dump
143 //purpose  : 
144 //=======================================================================
145
146 Standard_OStream& TDF_Reference::Dump (Standard_OStream& anOS) const
147 {  
148   anOS << "Reference";
149   return anOS;
150 }
151
152 //=======================================================================
153 //function : DumpJson
154 //purpose  : 
155 //=======================================================================
156 void TDF_Reference::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
157 {
158   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
159
160   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
161
162   TCollection_AsciiString aLabel;
163   TDF_Tool::Entry (myOrigin, aLabel);
164   OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aLabel)
165 }