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.
18 #include <Standard_GUID.hxx>
19 #include <Standard_Type.hxx>
20 #include <TDataXtd_Position.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <TDF_Label.hxx>
23 #include <TDF_RelocationTable.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(TDataXtd_Position,TDF_Attribute)
27 //=======================================================================
28 //function : Set (class method)
30 //=======================================================================
31 void TDataXtd_Position::Set(const TDF_Label& aLabel, const gp_Pnt& aPos)
33 Handle(TDataXtd_Position) pos;
34 if (!aLabel.FindAttribute(TDataXtd_Position::GetID(), pos)) {
35 pos = new TDataXtd_Position();
36 aLabel.AddAttribute(pos);
38 pos->SetPosition( aPos );
41 //=======================================================================
44 //=======================================================================
45 Handle(TDataXtd_Position) TDataXtd_Position::Set (const TDF_Label& L)
47 Handle(TDataXtd_Position) POS;
48 if (!L.FindAttribute (TDataXtd_Position::GetID (), POS)) {
49 POS = new TDataXtd_Position;
55 //=======================================================================
56 //function : Get (class method)
58 //=======================================================================
59 Standard_Boolean TDataXtd_Position::Get(const TDF_Label& aLabel, gp_Pnt& aPos)
61 Handle(TDataXtd_Position) pos;
62 if( aLabel.FindAttribute( TDataXtd_Position::GetID(), pos) ) {
63 aPos = pos->GetPosition();
66 return Standard_False;
69 //=======================================================================
72 //=======================================================================
73 const Standard_GUID& TDataXtd_Position::GetID()
75 static Standard_GUID TDataXtd_Position_guid("55553252-ce0c-11d1-b5d8-00a0c9064368");
76 return TDataXtd_Position_guid;
79 //=======================================================================
80 //function : TDataXtd_Position
82 //=======================================================================
83 TDataXtd_Position::TDataXtd_Position()
84 :myPosition(gp_Pnt(0.,0.,0.))
88 //=======================================================================
89 //function : GetPosition
91 //=======================================================================
92 const gp_Pnt& TDataXtd_Position::GetPosition() const
97 //=======================================================================
100 //=======================================================================
101 void TDataXtd_Position::SetPosition(const gp_Pnt& aPos)
103 // OCC2932 correction
104 if(myPosition.X() == aPos.X() &&
105 myPosition.Y() == aPos.Y() &&
106 myPosition.Z() == aPos.Z())
115 //=======================================================================
118 //=======================================================================
119 const Standard_GUID& TDataXtd_Position::ID() const
124 //=======================================================================
127 //=======================================================================
128 void TDataXtd_Position::Restore(const Handle(TDF_Attribute)& anAttribute)
130 myPosition = Handle(TDataXtd_Position)::DownCast(anAttribute)->GetPosition();
133 //=======================================================================
134 //function : NewEmpty
136 //=======================================================================
137 Handle(TDF_Attribute) TDataXtd_Position::NewEmpty() const
139 return new TDataXtd_Position;
142 //=======================================================================
145 //=======================================================================
146 void TDataXtd_Position::Paste(const Handle(TDF_Attribute)& intoAttribute,
147 const Handle(TDF_RelocationTable)&) const
149 Handle(TDataXtd_Position)::DownCast(intoAttribute)->SetPosition(myPosition);