0023024: Update headers of OCCT files
[occt.git] / src / MDataXtd / MDataXtd_ConstraintRetrievalDriver.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 <MDataXtd_ConstraintRetrievalDriver.ixx>
19#include <MDataXtd.hxx>
20#include <PDataXtd_Constraint.hxx>
21#include <TDataXtd_Constraint.hxx>
22#include <TDataXtd_ConstraintEnum.hxx>
23#include <TNaming_NamedShape.hxx>
24#include <PNaming_NamedShape.hxx>
25#include <PDF_HAttributeArray1.hxx>
26#include <Standard_NoSuchObject.hxx>
27#include <Standard_DomainError.hxx>
28#include <CDM_MessageDriver.hxx>
29
30
31//=======================================================================
32//function : MDataXtd_ConstraintRetrievalDriver
33//purpose :
34//=======================================================================
35
36MDataXtd_ConstraintRetrievalDriver::MDataXtd_ConstraintRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
37{
38}
39
40//=======================================================================
41//function : VersionNumber
42//purpose :
43//=======================================================================
44
45Standard_Integer MDataXtd_ConstraintRetrievalDriver::VersionNumber() const
46{ return 0; }
47
48
49//=======================================================================
50//function : SourceType
51//purpose :
52//=======================================================================
53
54Handle(Standard_Type) MDataXtd_ConstraintRetrievalDriver::SourceType() const
55{ return STANDARD_TYPE(PDataXtd_Constraint); }
56
57
58
59
60//=======================================================================
61//function : NewEmpty
62//purpose :
63//=======================================================================
64
65Handle(TDF_Attribute) MDataXtd_ConstraintRetrievalDriver::NewEmpty() const
66{ return new TDataXtd_Constraint (); }
67
68
69
70//=======================================================================
71//function : Paste
72//purpose :
73//=======================================================================
74
75void MDataXtd_ConstraintRetrievalDriver::Paste (
76 const Handle(PDF_Attribute)& Source,
77 const Handle(TDF_Attribute)& Target,
78 const Handle(MDF_RRelocationTable)& RelocTable) const
79{
80 Handle(PDataXtd_Constraint) S =
81 Handle(PDataXtd_Constraint)::DownCast (Source);
82 Handle(TDataXtd_Constraint) T =
83 Handle(TDataXtd_Constraint)::DownCast (Target);
84
85 Handle(TDataStd_Real) TValue;
86 Handle(PDataStd_Real) Value = S->GetValue ();
87 if (!Value.IsNull ()) {
88 if (!RelocTable->HasRelocation(Value, TValue )) {
89 Standard_NoSuchObject::Raise("MDataXtd_ConstraintRetrievalDriver::Paste");
90 }
91 T->SetValue(TValue);
92 }
93
94 Handle(PDF_HAttributeArray1) PGeometries = S->GetGeometries ();
95 if (!PGeometries.IsNull()) {
96 for (Standard_Integer i = 1; i <= PGeometries->Length (); i++) {
97 Handle(PDF_Attribute) PG = PGeometries->Value (i);
98 if (!PG.IsNull ()) {
99 Handle(TNaming_NamedShape) G;
100 if (!RelocTable->HasRelocation (PG, G)) {
101 Standard_NoSuchObject::Raise("MDataXtd_ConstraintRetrievalDriver::Paste");
102 }
103 T->SetGeometry (i, G);
104 }
105 }
106 }
107
108
109 Handle(PNaming_NamedShape) PPlane = S->GetPlane();
110 Handle(TNaming_NamedShape) TPlane;
111 if (!PPlane.IsNull()) {
112 if (!RelocTable->HasRelocation (PPlane, TPlane )) {
113 Standard_NoSuchObject::Raise("MDataXtd_ConstraintStorageDriver::Paste");
114 }
115 T->SetPlane(TPlane);
116 }
117 T->SetType (MDataXtd::IntegerToConstraintType (S->GetType ()));
118 T->Verified(S->Verified());
119 T->Inverted(S->Inverted());
120 T->Reversed(S->Reversed());
121}
122
123
124