0025923: Remove small wires on face read from STEP
[occt.git] / src / MDataStd / MDataStd_BooleanArrayRetrievalDriver.cxx
1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-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 <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>
23
24 //=======================================================================
25 //function : MDataStd_BooleanArrayRetrievalDriver
26 //purpose  : 
27 //=======================================================================
28 MDataStd_BooleanArrayRetrievalDriver::MDataStd_BooleanArrayRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
29 {
30
31 }
32
33 //=======================================================================
34 //function : VersionNumber
35 //purpose  : 
36 //=======================================================================
37 Standard_Integer MDataStd_BooleanArrayRetrievalDriver::VersionNumber() const
38
39   return 0; 
40 }
41
42 //=======================================================================
43 //function : SourceType
44 //purpose  : 
45 //=======================================================================
46 Handle(Standard_Type) MDataStd_BooleanArrayRetrievalDriver::SourceType() const
47 {
48   static Handle(Standard_Type) sourceType = STANDARD_TYPE(PDataStd_BooleanArray);
49   return sourceType;
50 }
51
52 //=======================================================================
53 //function : NewEmpty
54 //purpose  : 
55 //=======================================================================
56 Handle(TDF_Attribute) MDataStd_BooleanArrayRetrievalDriver::NewEmpty () const 
57 {
58   return new TDataStd_BooleanArray();
59 }
60
61 //=======================================================================
62 //function : Paste
63 //purpose  : 
64 //=======================================================================
65 void MDataStd_BooleanArrayRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,
66                                                 const Handle(TDF_Attribute)& Target,
67                                                 const Handle(MDF_RRelocationTable)& ) const
68 {
69   Handle(PDataStd_BooleanArray) S = Handle(PDataStd_BooleanArray)::DownCast (Source);
70   Handle(TDataStd_BooleanArray) T = Handle(TDataStd_BooleanArray)::DownCast (Target);
71
72   if (S->Upper() >= S->Lower())
73   {
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++)
79     {
80       Standard_Byte pvalue = (Standard_Byte) pvalues->Value(i);
81       tvalues->SetValue(i, pvalue);
82     }
83     T->SetInternalArray(tvalues);
84   }
85 }