b311480e |
1 | // Created on: 2004-05-17 |
2 | // Created by: Sergey ZARITCHNY |
973c2be1 |
3 | // Copyright (c) 2004-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. |
b311480e |
15 | |
7fd59977 |
16 | // modified 13.04.2009 Sergey ZARITCHNY |
17 | |
42cf5bc1 |
18 | #include <BinMPrsStd_PositionDriver.hxx> |
19 | #include <BinObjMgt_Persistent.hxx> |
20 | #include <CDM_MessageDriver.hxx> |
7fd59977 |
21 | #include <gp_Pnt.hxx> |
42cf5bc1 |
22 | #include <Standard_Type.hxx> |
7fd59977 |
23 | #include <TDataXtd_Position.hxx> |
42cf5bc1 |
24 | #include <TDF_Attribute.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(BinMPrsStd_PositionDriver,BinMDF_ADriver) |
27 | |
7fd59977 |
28 | //======================================================================= |
29 | //function : BinMDataStd_PositionDriver |
30 | //purpose : Constructor |
31 | //======================================================================= |
7fd59977 |
32 | BinMPrsStd_PositionDriver::BinMPrsStd_PositionDriver |
33 | (const Handle(CDM_MessageDriver)& theMsgDriver) |
34 | : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataXtd_Position)->Name()) |
35 | { |
36 | } |
37 | |
38 | //======================================================================= |
39 | //function : NewEmpty |
40 | //purpose : |
41 | //======================================================================= |
42 | |
43 | Handle(TDF_Attribute) BinMPrsStd_PositionDriver::NewEmpty() const |
44 | { |
45 | return new TDataXtd_Position(); |
46 | } |
47 | |
48 | //======================================================================= |
49 | //function : Paste |
50 | //purpose : persistent -> transient (retrieve) |
51 | //======================================================================= |
52 | |
53 | Standard_Boolean BinMPrsStd_PositionDriver::Paste |
54 | (const BinObjMgt_Persistent& theSource, |
55 | const Handle(TDF_Attribute)& theTarget, |
56 | BinObjMgt_RRelocationTable& ) const |
57 | { |
58 | Handle(TDataXtd_Position) anAtt = Handle(TDataXtd_Position)::DownCast(theTarget); |
59 | Standard_Real aValue; |
60 | Standard_Boolean ok = theSource >> aValue; |
61 | if (!ok) return ok; |
62 | gp_Pnt aPosition(0., 0., 0.); |
63 | aPosition.SetX(aValue); |
64 | |
65 | ok = theSource >> aValue; |
66 | if (!ok) return ok; |
67 | aPosition.SetY(aValue); |
68 | |
69 | ok = theSource >> aValue; |
70 | if (!ok) return ok; |
71 | aPosition.SetZ(aValue); |
72 | |
73 | anAtt->SetPosition(aPosition); |
74 | |
75 | return ok; |
76 | } |
77 | |
78 | //======================================================================= |
79 | //function : Paste |
80 | //purpose : transient -> persistent (store) |
81 | //======================================================================= |
82 | |
83 | void BinMPrsStd_PositionDriver::Paste (const Handle(TDF_Attribute)& theSource, |
84 | BinObjMgt_Persistent& theTarget, |
85 | BinObjMgt_SRelocationTable& ) const |
86 | { |
87 | Handle(TDataXtd_Position) anAtt = Handle(TDataXtd_Position)::DownCast(theSource); |
88 | |
89 | theTarget << anAtt->GetPosition().X(); |
90 | theTarget << anAtt->GetPosition().Y(); |
91 | theTarget << anAtt->GetPosition().Z(); |
92 | } |