0024157: Parallelization of assembly part of BO
[occt.git] / src / BinMXCAFDoc / BinMXCAFDoc_DimTolDriver.cxx
CommitLineData
b311480e 1// Created on: 2008-12-10
2// Created by: Pavel TELKOV
3// Copyright (c) 2008-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21#include <BinMXCAFDoc_DimTolDriver.ixx>
22#include <XCAFDoc_DimTol.hxx>
23
24#include <TCollection_HAsciiString.hxx>
25#include <TColStd_Array1OfReal.hxx>
26#include <TColStd_HArray1OfReal.hxx>
27
28//=======================================================================
29//function : Constructor
30//purpose :
31//=======================================================================
32BinMXCAFDoc_DimTolDriver::BinMXCAFDoc_DimTolDriver
33 (const Handle(CDM_MessageDriver)& theMsgDriver)
34: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_DimTol)->Name())
35{
36}
37
38//=======================================================================
39//function : NewEmpty
40//purpose :
41//=======================================================================
42Handle(TDF_Attribute) BinMXCAFDoc_DimTolDriver::NewEmpty() const
43{
44 return new XCAFDoc_DimTol();
45}
46
47//=======================================================================
48//function : Paste
49//purpose :
50//=======================================================================
51Standard_Boolean BinMXCAFDoc_DimTolDriver::Paste(const BinObjMgt_Persistent& theSource,
52 const Handle(TDF_Attribute)& theTarget,
53 BinObjMgt_RRelocationTable& /*theRelocTable*/) const
54{
55 Handle(XCAFDoc_DimTol) anAtt = Handle(XCAFDoc_DimTol)::DownCast(theTarget);
56 Standard_Integer aKind, aFirstInd, aLastInd;
57 TCollection_AsciiString aName, aDescr;
58 if ( !(theSource >> aKind >> aName >> aDescr >> aFirstInd >> aLastInd) )
59 return Standard_False;
60
61 Handle(TColStd_HArray1OfReal) aHArr;
62 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
63 if (aLength > 0 ) {
64 aHArr = new TColStd_HArray1OfReal( aFirstInd, aLastInd );
65
66 TColStd_Array1OfReal& aTargetArray = aHArr->ChangeArray1();
67 if(!theSource.GetRealArray (&aTargetArray(aFirstInd), aLength))
68 return Standard_False;
69 }
70 anAtt->Set(aKind, aHArr,
71 new TCollection_HAsciiString( aName ),
72 new TCollection_HAsciiString( aDescr ));
73 return Standard_True;
74}
75
76//=======================================================================
77//function : Paste
78//purpose :
79//=======================================================================
80void BinMXCAFDoc_DimTolDriver::Paste(const Handle(TDF_Attribute)& theSource,
81 BinObjMgt_Persistent& theTarget,
82 BinObjMgt_SRelocationTable& /*theRelocTable*/) const
83{
84 Handle(XCAFDoc_DimTol) anAtt = Handle(XCAFDoc_DimTol)::DownCast(theSource);
85 theTarget << anAtt->GetKind();
86 if ( !anAtt->GetName().IsNull() )
87 theTarget << anAtt->GetName()->String();
88 else
89 theTarget << TCollection_AsciiString("");
90 if ( !anAtt->GetDescription().IsNull() )
91 theTarget << anAtt->GetDescription()->String();
92 else
93 theTarget << TCollection_AsciiString("");
94
95 Handle(TColStd_HArray1OfReal) aHArr = anAtt->GetVal();
96 Standard_Integer aFirstInd = 1, aLastInd = 0;
97 if ( !aHArr.IsNull() ) {
98 aFirstInd = aHArr->Lower();
99 aLastInd = aHArr->Upper();
100 }
101 theTarget << aFirstInd << aLastInd;
102 if ( !aHArr.IsNull() ) {
103 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
104 const TColStd_Array1OfReal& anArr = aHArr->Array1();
105 Standard_Real *aPtr = (Standard_Real *) &anArr(aFirstInd);
106 theTarget.PutRealArray (aPtr, aLength);
107 }
108}