Test for 0022778: Bug in BRepMesh
[occt.git] / src / MDataStd / MDataStd_IntPackedMapRetrievalDriver_1.cxx
CommitLineData
b311480e 1// Created on: 2008-03-28
2// Created by: Sergey ZARITCHNY
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
22#include <MDataStd_IntPackedMapRetrievalDriver_1.ixx>
23#include <PDataStd_IntPackedMap.hxx>
24#include <PDataStd_IntPackedMap_1.hxx>
25#include <TDataStd_IntPackedMap.hxx>
26#include <CDM_MessageDriver.hxx>
27#include <TColStd_HPackedMapOfInteger.hxx>
28#include <TCollection_ExtendedString.hxx>
29
30//=======================================================================
31//function : MDataStd_IntPackedMapRetrievalDriver_1
32//purpose : Constructor
33//=======================================================================
34MDataStd_IntPackedMapRetrievalDriver_1::MDataStd_IntPackedMapRetrievalDriver_1
35 (const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
36{
37}
38//=======================================================================
39//function : VersionNumber
40//purpose :
41//=======================================================================
42Standard_Integer MDataStd_IntPackedMapRetrievalDriver_1::VersionNumber() const
43{ return 1; }
44
45//=======================================================================
46//function : SourceType
47//purpose :
48//=======================================================================
49Handle(Standard_Type) MDataStd_IntPackedMapRetrievalDriver_1::SourceType() const
50{ return STANDARD_TYPE(PDataStd_IntPackedMap_1); }
51
52//=======================================================================
53//function : NewEmpty
54//purpose :
55//=======================================================================
56Handle(TDF_Attribute) MDataStd_IntPackedMapRetrievalDriver_1::NewEmpty() const
57{ return new TDataStd_IntPackedMap (); }
58
59//=======================================================================
60//function : Paste
61//purpose :
62//=======================================================================
63void MDataStd_IntPackedMapRetrievalDriver_1::Paste(
64 const Handle(PDF_Attribute)& Source,
65 const Handle(TDF_Attribute)& Target,
66 const Handle(MDF_RRelocationTable)& ) const
67{
68 Handle(PDataStd_IntPackedMap_1) aS =
69 Handle(PDataStd_IntPackedMap_1)::DownCast (Source);
70 Handle(TDataStd_IntPackedMap) aT =
71 Handle(TDataStd_IntPackedMap)::DownCast (Target);
72 if(!aS.IsNull() && !aT.IsNull()) {
73 if(!aS->IsEmpty()) {
74 Handle(TColStd_HPackedMapOfInteger) aHMap = new TColStd_HPackedMapOfInteger ();
75 Standard_Integer aKey;
76 for(Standard_Integer i = aS->Lower(); i<= aS->Upper() ; i++) {
77 aKey = aS->GetValue(i);
78 if(!aHMap->ChangeMap().Add( aKey )) {
79 WriteMessage(
80 TCollection_ExtendedString("error retrieving integer mamaber of the attribute TDataStd_IntPackedMap"));
81 return;
82 }
83 }
84 aT->ChangeMap(aHMap);
85 }
86 aT->SetDelta(aS->GetDelta());
87 } else
88 WriteMessage(TCollection_ExtendedString("error retrieving attribute TDataStd_IntPackedMap"));
89}