0024927: Getting rid of "Persistent" functionality -- Code
[occt.git] / src / MXCAFDoc / MXCAFDoc_MaterialStorageDriver.cxx
1 // Created on: 2008-12-10
2 // Created by: Pavel TELKOV
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <MXCAFDoc_MaterialStorageDriver.ixx>
17 #include <XCAFDoc_Material.hxx>
18 #include <PXCAFDoc_Material.hxx>
19
20 #include <TCollection_HAsciiString.hxx>
21 #include <TColStd_HArray1OfReal.hxx>
22 #include <PCollection_HAsciiString.hxx>
23 #include <PColStd_HArray1OfReal.hxx>
24
25 //=======================================================================
26 //function : MXCAFDoc_MaterialStorageDriver
27 //purpose  : 
28 //=======================================================================
29
30 MXCAFDoc_MaterialStorageDriver::MXCAFDoc_MaterialStorageDriver
31   (const Handle(CDM_MessageDriver)& theMsgDriver) : MDF_ASDriver (theMsgDriver)
32 {}
33
34 //=======================================================================
35 //function : VersionNumber
36 //purpose  : 
37 //=======================================================================
38
39 Standard_Integer MXCAFDoc_MaterialStorageDriver::VersionNumber() const
40 { return 0; }
41
42 //=======================================================================
43 //function : SourceType
44 //purpose  : 
45 //=======================================================================
46
47 Handle(Standard_Type) MXCAFDoc_MaterialStorageDriver::SourceType() const
48 {
49   static Handle(Standard_Type) sourceType = STANDARD_TYPE(XCAFDoc_Material);
50   return sourceType;
51 }
52
53 //=======================================================================
54 //function : NewEmpty
55 //purpose  : 
56 //=======================================================================
57
58 Handle(PDF_Attribute) MXCAFDoc_MaterialStorageDriver::NewEmpty() const
59 {
60   return new PXCAFDoc_Material();
61 }
62
63 //=======================================================================
64 //function : Paste
65 //purpose  : 
66 //=======================================================================
67
68 void MXCAFDoc_MaterialStorageDriver::Paste(const Handle(TDF_Attribute)& Source,
69                                          const Handle(PDF_Attribute)& Target,
70                                          const Handle(MDF_SRelocationTable)& /*RelocTable*/) const
71 {
72   Handle(XCAFDoc_Material) S = Handle(XCAFDoc_Material)::DownCast (Source);
73   Handle(PXCAFDoc_Material) T = Handle(PXCAFDoc_Material)::DownCast (Target);
74   Handle(TCollection_HAsciiString) aNameStr = S->GetName();
75   Handle(TCollection_HAsciiString) aDescrStr = S->GetDescription();
76   Handle(TCollection_HAsciiString) aDensNameStr = S->GetDensName();
77   Handle(TCollection_HAsciiString) aDensValTypeStr = S->GetDensValType();
78   
79   Handle(PCollection_HAsciiString) aName, aDescr, aDensName, aDensValType;
80   if ( !aNameStr.IsNull() )
81     aName = new PCollection_HAsciiString (aNameStr->String());
82   if ( !aDescrStr.IsNull() )
83     aDescr = new PCollection_HAsciiString (aDescrStr->String());
84   if ( !aDensNameStr.IsNull() )
85     aDensName = new PCollection_HAsciiString (aDensNameStr->String());
86   if ( !aDensValTypeStr.IsNull() )
87     aDensValType = new PCollection_HAsciiString (aDensValTypeStr->String());
88
89   T->Set(aName, aDescr, S->GetDensity(), aDensName, aDensValType);
90 }