0026937: Eliminate NO_CXX_EXCEPTION macro support
[occt.git] / src / TDataXtd / TDataXtd_Shape.cxx
CommitLineData
b311480e 1// Created on: 2009-04-06
2// Created by: Sergey ZARITCHNY
973c2be1 3// Copyright (c) 2009-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
42cf5bc1 16
17#include <BRep_Builder.hxx>
18#include <Standard_GUID.hxx>
19#include <Standard_Type.hxx>
7fd59977 20#include <TDataStd.hxx>
21#include <TDataXtd.hxx>
42cf5bc1 22#include <TDataXtd_Shape.hxx>
23#include <TDF_Attribute.hxx>
24#include <TDF_DataSet.hxx>
7fd59977 25#include <TDF_Label.hxx>
42cf5bc1 26#include <TDF_RelocationTable.hxx>
27#include <TNaming.hxx>
7fd59977 28#include <TNaming_Builder.hxx>
29#include <TNaming_NamedShape.hxx>
30#include <TNaming_Tool.hxx>
42cf5bc1 31#include <TopoDS_Shape.hxx>
32#include <TopoDS_Solid.hxx>
7fd59977 33
92efcf78 34IMPLEMENT_STANDARD_RTTIEXT(TDataXtd_Shape,TDF_Attribute)
35
7fd59977 36//=======================================================================
37//function : Find
38//purpose :
39//=======================================================================
7fd59977 40Standard_Boolean TDataXtd_Shape::Find (const TDF_Label& current,
41 Handle(TDataXtd_Shape)& S)
42{
43 TDF_Label L = current;
44 Handle(TDataXtd_Shape) SA;
45 if (L.IsNull()) return Standard_False;
302f96fb 46 for(;;) {
7fd59977 47 if(L.FindAttribute(TDataXtd_Shape::GetID(), SA)) break;
48 L = L.Father();
49 if (L.IsNull()) break;
50 }
51
52
53 if (!SA.IsNull()) {
54 S = SA;
55 return Standard_True;
56 }
57 return Standard_False;
58}
59
60
61//=======================================================================
62//function : New
63//purpose :
64//=======================================================================
65
66Handle(TDataXtd_Shape) TDataXtd_Shape::New (const TDF_Label& label)
67{
68 if (label.HasAttribute()) {
9775fa61 69 throw Standard_DomainError("TDataXtd_Shape::New : not an empty label");
7fd59977 70 }
71 Handle(TDataXtd_Shape) A = new TDataXtd_Shape ();
72 label.AddAttribute(A);
73 return A;
74}
75
76//=======================================================================
77//function : Set
78//purpose :
79//=======================================================================
80
81Handle(TDataXtd_Shape) TDataXtd_Shape::Set (const TDF_Label& label, const TopoDS_Shape& shape)
82{
83 Handle(TDataXtd_Shape) A;
84 if (!label.FindAttribute(TDataXtd_Shape::GetID(),A)) {
85 A = TDataXtd_Shape::New (label);
86 }
87
7fd59977 88 Handle(TNaming_NamedShape) aNS;
89 if(label.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
90 if(!aNS->Get().IsNull())
91 if(aNS->Get() == shape)
92 return A;
93 }
7fd59977 94
95 TNaming_Builder B(label);
96 B.Generated(shape);
97 return A;
98}
99
100//=======================================================================
101//function : Get
102//purpose :
103//=======================================================================
104
105TopoDS_Shape TDataXtd_Shape::Get (const TDF_Label& label)
106{
107 TopoDS_Shape shape;
108
109 Handle(TNaming_NamedShape) NS;
110 if( label.FindAttribute(TNaming_NamedShape::GetID(), NS)) {
111 shape = TNaming_Tool::GetShape(NS);
112 return shape;
113 }
114
115 shape.Nullify();
116 return shape;
117}
118
119//=======================================================================
120//function : GetID
121//purpose :
122//=======================================================================
123
124const Standard_GUID& TDataXtd_Shape::GetID()
125{
126 static Standard_GUID TDataXtd_ShapeID("2a96b620-ec8b-11d0-bee7-080009dc3333");
127 return TDataXtd_ShapeID;
128}
129
130//=======================================================================
131//function : TDataXtd_Shape
132//purpose :
133//=======================================================================
134
135TDataXtd_Shape::TDataXtd_Shape()
136{
137}
138
139//=======================================================================
140//function : ID
141//purpose :
142//=======================================================================
143
144const Standard_GUID& TDataXtd_Shape::ID() const
145{ return GetID(); }
146
147
148//=======================================================================
149//function : NewEmpty
150//purpose :
151//=======================================================================
152
153Handle(TDF_Attribute) TDataXtd_Shape::NewEmpty () const
154{
155 return new TDataXtd_Shape();
156}
157
158//=======================================================================
159//function : Restore
160//purpose :
161//=======================================================================
162
35e08fe8 163void TDataXtd_Shape::Restore(const Handle(TDF_Attribute)& )
7fd59977 164{
165}
166
167//=======================================================================
168//function : Paste
169//purpose :
170//=======================================================================
171
35e08fe8 172void TDataXtd_Shape::Paste (const Handle(TDF_Attribute)&,
173 const Handle(TDF_RelocationTable)&) const
7fd59977 174{
175}
176
177//=======================================================================
178//function : References
179//purpose :
180//=======================================================================
181
35e08fe8 182void TDataXtd_Shape::References (const Handle(TDF_DataSet)&) const
7fd59977 183{
184}
185
186//=======================================================================
187//function : Dump
188//purpose :
189//=======================================================================
190
191Standard_OStream& TDataXtd_Shape::Dump (Standard_OStream& anOS) const
192{
193 anOS << "Shape";
194 return anOS;
195}