1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-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.
16 #include <MDataStd_BooleanArrayRetrievalDriver.ixx>
17 #include <PDataStd_BooleanArray.hxx>
18 #include <TDataStd_BooleanArray.hxx>
19 #include <MDataStd.hxx>
20 #include <CDM_MessageDriver.hxx>
21 #include <TColStd_HArray1OfByte.hxx>
22 #include <PColStd_HArray1OfInteger.hxx>
24 //=======================================================================
25 //function : MDataStd_BooleanArrayRetrievalDriver
27 //=======================================================================
28 MDataStd_BooleanArrayRetrievalDriver::MDataStd_BooleanArrayRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
33 //=======================================================================
34 //function : VersionNumber
36 //=======================================================================
37 Standard_Integer MDataStd_BooleanArrayRetrievalDriver::VersionNumber() const
42 //=======================================================================
43 //function : SourceType
45 //=======================================================================
46 Handle(Standard_Type) MDataStd_BooleanArrayRetrievalDriver::SourceType() const
48 static Handle(Standard_Type) sourceType = STANDARD_TYPE(PDataStd_BooleanArray);
52 //=======================================================================
55 //=======================================================================
56 Handle(TDF_Attribute) MDataStd_BooleanArrayRetrievalDriver::NewEmpty () const
58 return new TDataStd_BooleanArray();
61 //=======================================================================
64 //=======================================================================
65 void MDataStd_BooleanArrayRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,
66 const Handle(TDF_Attribute)& Target,
67 const Handle(MDF_RRelocationTable)& ) const
69 Handle(PDataStd_BooleanArray) S = Handle(PDataStd_BooleanArray)::DownCast (Source);
70 Handle(TDataStd_BooleanArray) T = Handle(TDataStd_BooleanArray)::DownCast (Target);
72 if (S->Upper() >= S->Lower())
74 T->Init(S->Lower(), S->Upper());
75 const Handle(PColStd_HArray1OfInteger)& pvalues = S->Get();
76 Handle(TColStd_HArray1OfByte) tvalues = new TColStd_HArray1OfByte(pvalues->Lower(), pvalues->Upper());
77 Standard_Integer i = pvalues->Lower(), upper = pvalues->Upper();
78 for (; i <= upper; i++)
80 Standard_Byte pvalue = (Standard_Byte) pvalues->Value(i);
81 tvalues->SetValue(i, pvalue);
83 T->SetInternalArray(tvalues);