Integration of OCCT 6.5.0 from SVN
[occt.git] / src / BinTObjDrivers / BinTObjDrivers_XYZDriver.cxx
1 // File      : BinTObjDrivers_XYZDriver.cxx
2 // Created   : Wed Nov 24 11:23:54 2004
3 // Author    : Michael SAZONOV
4 // Copyright:   Open CASCADE  2007
5 // The original implementation Copyright: (C) RINA S.p.A
6
7
8 #include <BinTObjDrivers_XYZDriver.hxx>
9 #include <CDM_MessageDriver.hxx>
10 #include <TDF_Attribute.hxx>
11 #include <BinObjMgt_Persistent.hxx>
12 #include <TObj_TXYZ.hxx>
13
14 IMPLEMENT_STANDARD_HANDLE(BinTObjDrivers_XYZDriver,BinMDF_ADriver)
15 IMPLEMENT_STANDARD_RTTIEXT(BinTObjDrivers_XYZDriver,BinMDF_ADriver)
16
17 //=======================================================================
18 //function : BinTObjDrivers_XYZDriver
19 //purpose  : constructor
20 //=======================================================================
21
22 BinTObjDrivers_XYZDriver::BinTObjDrivers_XYZDriver
23                          (const Handle(CDM_MessageDriver)& theMessageDriver)
24 : BinMDF_ADriver( theMessageDriver, NULL)
25 {
26 }
27
28 //=======================================================================
29 //function : NewEmpty
30 //purpose  : Creates a new attribute
31 //=======================================================================
32
33 Handle(TDF_Attribute) BinTObjDrivers_XYZDriver::NewEmpty() const
34 {
35   return new TObj_TXYZ;
36 }
37
38 //=======================================================================
39 //function : Paste
40 //purpose  : Retrieve. Translate the contents of <theSource> and put it
41 //           into <theTarget>.
42 //=======================================================================
43
44 Standard_Boolean BinTObjDrivers_XYZDriver::Paste
45                          (const BinObjMgt_Persistent&  theSource,
46                           const Handle(TDF_Attribute)& theTarget,
47                           BinObjMgt_RRelocationTable&) const
48 {
49   Handle(TObj_TXYZ) aTarget = Handle(TObj_TXYZ)::DownCast(theTarget);
50   Standard_Real aX, aY, aZ;
51   if (! (theSource >> aX >> aY >> aZ))
52     return Standard_False;
53   aTarget->Set (gp_XYZ (aX, aY, aZ));
54   return Standard_True;
55 }
56
57 //=======================================================================
58 //function : Paste
59 //purpose  : Store. Translate the contents of <theSource> and put it
60 //           into <theTarget>
61 //=======================================================================
62
63 void BinTObjDrivers_XYZDriver::Paste
64                          (const Handle(TDF_Attribute)& theSource,
65                           BinObjMgt_Persistent&        theTarget,
66                           BinObjMgt_SRelocationTable&) const
67 {
68   Handle(TObj_TXYZ) aSource = Handle(TObj_TXYZ)::DownCast (theSource);
69   gp_XYZ aXYZ = aSource->Get();
70   theTarget << aXYZ.X() << aXYZ.Y() << aXYZ.Z();
71 }