Test for 0022778: Bug in BRepMesh
[occt.git] / src / MDataStd / MDataStd_ExpressionRetrievalDriver.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <MDataStd_ExpressionRetrievalDriver.ixx>
19#include <PDataStd_Expression.hxx>
20#include <TDataStd_Expression.hxx>
21#include <TCollection_ExtendedString.hxx>
22#include <PCollection_HExtendedString.hxx>
23#include <TDF_ListIteratorOfAttributeList.hxx>
24#include <PDF_HAttributeArray1.hxx>
25#include <Standard_NoSuchObject.hxx>
26#include <CDM_MessageDriver.hxx>
27
28//=======================================================================
29//function : MDataStd_ExpressionRetrievalDriver
30//purpose :
31//=======================================================================
32
33MDataStd_ExpressionRetrievalDriver::MDataStd_ExpressionRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
34{
35}
36
37//=======================================================================
38//function : VersionNumber
39//purpose :
40//=======================================================================
41
42Standard_Integer MDataStd_ExpressionRetrievalDriver::VersionNumber() const
43{ return 0; }
44
45//=======================================================================
46//function : SourceType
47//purpose :
48//=======================================================================
49
50Handle(Standard_Type) MDataStd_ExpressionRetrievalDriver::SourceType() const
51{ return STANDARD_TYPE(PDataStd_Expression); }
52
53//=======================================================================
54//function : NewEmpty
55//purpose :
56//=======================================================================
57
58Handle(TDF_Attribute) MDataStd_ExpressionRetrievalDriver::NewEmpty() const
59{ return new TDataStd_Expression (); }
60
61//=======================================================================
62//function : Paste
63//purpose :
64//=======================================================================
65
66void MDataStd_ExpressionRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,const Handle(TDF_Attribute)& Target,const Handle(MDF_RRelocationTable)& RelocTable) const
67{
68 Handle(PDataStd_Expression) S = Handle(PDataStd_Expression)::DownCast (Source);
69 Handle(TDataStd_Expression) T = Handle(TDataStd_Expression)::DownCast (Target);
70 TCollection_ExtendedString Expression = (S->GetName())->Convert ();
71 T->SetExpression (Expression);
72
73 Handle(PDF_Attribute) PV;
74 Handle(TDF_Attribute) TV;
75
76 Handle(PDF_HAttributeArray1) PVARS = S->GetVariables ();
77 if (PVARS.IsNull()) return;
78 for (Standard_Integer i = 1; i <= PVARS->Length (); i++) {
79 PV = PVARS->Value (i);
80 if (!PV.IsNull ()) {
81 Handle(TDF_Attribute) TV;
82 if (!RelocTable->HasRelocation (PV, TV)) {
83 Standard_NoSuchObject::Raise("MDataStd_ConstraintRetrievalDriver::Paste");
84 }
85 T->GetVariables().Append(TV);
86 }
87 }
88}