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