1 // Created on: 2009-04-06
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2009-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <BRep_Builder.hxx>
18 #include <Standard_GUID.hxx>
19 #include <Standard_Type.hxx>
20 #include <TDataStd.hxx>
21 #include <TDataXtd.hxx>
22 #include <TDataXtd_Shape.hxx>
23 #include <TDF_Attribute.hxx>
24 #include <TDF_DataSet.hxx>
25 #include <TDF_Label.hxx>
26 #include <TDF_RelocationTable.hxx>
27 #include <TNaming.hxx>
28 #include <TNaming_Builder.hxx>
29 #include <TNaming_NamedShape.hxx>
30 #include <TNaming_Tool.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Solid.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(TDataXtd_Shape,TDF_Attribute)
36 //=======================================================================
39 //=======================================================================
40 Standard_Boolean TDataXtd_Shape::Find (const TDF_Label& current,
41 Handle(TDataXtd_Shape)& S)
43 TDF_Label L = current;
44 Handle(TDataXtd_Shape) SA;
45 if (L.IsNull()) return Standard_False;
47 if(L.FindAttribute(TDataXtd_Shape::GetID(), SA)) break;
49 if (L.IsNull()) break;
57 return Standard_False;
61 //=======================================================================
64 //=======================================================================
66 Handle(TDataXtd_Shape) TDataXtd_Shape::New (const TDF_Label& label)
68 if (label.HasAttribute()) {
69 throw Standard_DomainError("TDataXtd_Shape::New : not an empty label");
71 Handle(TDataXtd_Shape) A = new TDataXtd_Shape ();
72 label.AddAttribute(A);
76 //=======================================================================
79 //=======================================================================
81 Handle(TDataXtd_Shape) TDataXtd_Shape::Set (const TDF_Label& label, const TopoDS_Shape& shape)
83 Handle(TDataXtd_Shape) A;
84 if (!label.FindAttribute(TDataXtd_Shape::GetID(),A)) {
85 A = TDataXtd_Shape::New (label);
88 Handle(TNaming_NamedShape) aNS;
89 if(label.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
90 if(!aNS->Get().IsNull())
91 if(aNS->Get() == shape)
95 TNaming_Builder B(label);
100 //=======================================================================
103 //=======================================================================
105 TopoDS_Shape TDataXtd_Shape::Get (const TDF_Label& label)
109 Handle(TNaming_NamedShape) NS;
110 if( label.FindAttribute(TNaming_NamedShape::GetID(), NS)) {
111 shape = TNaming_Tool::GetShape(NS);
119 //=======================================================================
122 //=======================================================================
124 const Standard_GUID& TDataXtd_Shape::GetID()
126 static Standard_GUID TDataXtd_ShapeID("2a96b620-ec8b-11d0-bee7-080009dc3333");
127 return TDataXtd_ShapeID;
130 //=======================================================================
131 //function : TDataXtd_Shape
133 //=======================================================================
135 TDataXtd_Shape::TDataXtd_Shape()
139 //=======================================================================
142 //=======================================================================
144 const Standard_GUID& TDataXtd_Shape::ID() const
148 //=======================================================================
149 //function : NewEmpty
151 //=======================================================================
153 Handle(TDF_Attribute) TDataXtd_Shape::NewEmpty () const
155 return new TDataXtd_Shape();
158 //=======================================================================
161 //=======================================================================
163 void TDataXtd_Shape::Restore(const Handle(TDF_Attribute)& )
167 //=======================================================================
170 //=======================================================================
172 void TDataXtd_Shape::Paste (const Handle(TDF_Attribute)&,
173 const Handle(TDF_RelocationTable)&) const
177 //=======================================================================
178 //function : References
180 //=======================================================================
182 void TDataXtd_Shape::References (const Handle(TDF_DataSet)&) const
186 //=======================================================================
189 //=======================================================================
191 Standard_OStream& TDataXtd_Shape::Dump (Standard_OStream& anOS) const