Test for 0022778: Bug in BRepMesh
[occt.git] / src / MDataStd / MDataStd_RelationRetrievalDriver.cxx
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
18 #include <MDataStd_RelationRetrievalDriver.ixx>
19 #include <PDataStd_Relation.hxx>
20 #include <TDataStd_Relation.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 //=======================================================================
30 //function : MDataStd_RelationRetrievalDriver
31 //purpose  : 
32 //=======================================================================
33
34 MDataStd_RelationRetrievalDriver::MDataStd_RelationRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
35 {
36 }
37
38 //=======================================================================
39 //function : VersionNumber
40 //purpose  : 
41 //=======================================================================
42
43 Standard_Integer MDataStd_RelationRetrievalDriver::VersionNumber() const
44 { return 0; }
45
46 //=======================================================================
47 //function : SourceType
48 //purpose  : 
49 //=======================================================================
50
51 Handle(Standard_Type) MDataStd_RelationRetrievalDriver::SourceType() const
52 {
53   return STANDARD_TYPE(PDataStd_Relation); 
54 }
55
56 //=======================================================================
57 //function : NewEmpty
58 //purpose  : 
59 //=======================================================================
60
61 Handle(TDF_Attribute) MDataStd_RelationRetrievalDriver::NewEmpty() const
62 {
63   return new TDataStd_Relation (); 
64 }
65
66 //=======================================================================
67 //function : Paste
68 //purpose  : 
69 //=======================================================================
70
71 void MDataStd_RelationRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,
72                                              const Handle(TDF_Attribute)& Target,
73                                              const Handle(MDF_RRelocationTable)& RelocTable) const
74 {
75   Handle(PDataStd_Relation) S = Handle(PDataStd_Relation)::DownCast (Source);
76   Handle(TDataStd_Relation) T = Handle(TDataStd_Relation)::DownCast (Target);
77   TCollection_ExtendedString Relation = (S->GetName())->Convert ();
78   T->SetRelation (Relation);
79   
80   Handle(PDF_Attribute) PV; 
81   Handle(TDF_Attribute) TV;
82
83   Handle(PDF_HAttributeArray1) PVARS = S->GetVariables ();
84   if (PVARS.IsNull()) return;
85   for (Standard_Integer i = 1; i <= PVARS->Length (); i++) {
86     PV = PVARS->Value (i);
87     if (!PV.IsNull ()) {
88       if (!RelocTable->HasRelocation (PV, TV)) {
89         Standard_NoSuchObject::Raise("MDataStd_ConstraintRetrievalDriver::Paste");
90       }
91       T->GetVariables().Append(TV);
92     }
93   }
94 }
95