0026961: Recover possibility to read files in old persistence format
[occt.git] / src / StdPersistent / StdPersistent_DataXtd_Constraint.cxx
1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <StdPersistent_DataXtd_Constraint.hxx>
15
16 #include <TNaming_NamedShape.hxx>
17 #include <TDataStd_Real.hxx>
18
19
20 //=======================================================================
21 //function : Import
22 //purpose  : Import transient attribuite from the persistent data
23 //=======================================================================
24 void StdPersistent_DataXtd_Constraint::Import
25   (const Handle(TDataXtd_Constraint)& theAttribute) const
26 {
27   theAttribute->SetType  (myType);
28   theAttribute->Reversed (myIsReversed);
29   theAttribute->Inverted (myIsInverted);
30   theAttribute->Verified (myIsVerified);
31
32   if (myGeometries)
33   {
34     Handle(StdLPersistent_HArray1OfPersistent) aGeometries = myGeometries->Array();
35     for (Standard_Integer i = 1; i <= aGeometries->Length(); i++)
36     {
37       Handle(StdObjMgt_Persistent) aPGeometry = aGeometries->Value(i);
38       if (aPGeometry)
39       {
40         Handle(TDF_Attribute) aTGeometry = aPGeometry->GetAttribute();
41         theAttribute->SetGeometry
42           (i, Handle(TNaming_NamedShape)::DownCast (aTGeometry));
43       }
44     }
45   }
46
47   if (myValue)
48   {
49     Handle(TDF_Attribute) aValue = myValue->GetAttribute();
50     theAttribute->SetValue (Handle(TDataStd_Real)::DownCast (aValue));
51   }
52
53   if (myPlane)
54   {
55     Handle(TDF_Attribute) aPlane = myPlane->GetAttribute();
56     theAttribute->SetPlane (Handle(TNaming_NamedShape)::DownCast (aPlane));
57   }
58 }