0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / MXCAFDoc / MXCAFDoc_GraphNodeStorageDriver.cxx
1 // File:        MXCAFDoc_GraphNodeStorageDriver.cxx
2 // Created:     Fri Sep 29 10:46:06 2000
3 // Author:      data exchange team
4 //              <det@nordox.nnov.matra-dtv.fr>
5
6
7 #include <MXCAFDoc_GraphNodeStorageDriver.ixx>
8
9 #include <XCAFDoc_GraphNode.hxx>
10 #include <PXCAFDoc_GraphNode.hxx>
11 #include <Standard_NoSuchObject.hxx>
12
13
14 //=======================================================================
15 //function : Constructor
16 //purpose  : 
17 //=======================================================================
18
19 MXCAFDoc_GraphNodeStorageDriver::MXCAFDoc_GraphNodeStorageDriver(const Handle(CDM_MessageDriver)& theMsgDriver) : MDF_ASDriver (theMsgDriver)
20 {}
21
22
23 //=======================================================================
24 //function : VersionNumber
25 //purpose  : 
26 //=======================================================================
27
28 Standard_Integer MXCAFDoc_GraphNodeStorageDriver::VersionNumber() const
29 { return 0; }
30
31
32 //=======================================================================
33 //function : SourceType
34 //purpose  : 
35 //=======================================================================
36
37 Handle(Standard_Type) MXCAFDoc_GraphNodeStorageDriver::SourceType() const
38 { return STANDARD_TYPE(XCAFDoc_GraphNode); }
39
40
41 //=======================================================================
42 //function : NewEmpty
43 //purpose  : 
44 //=======================================================================
45
46 Handle(PDF_Attribute) MXCAFDoc_GraphNodeStorageDriver::NewEmpty() const
47 { return new PXCAFDoc_GraphNode(); }
48
49
50 //=======================================================================
51 //function : Paste
52 //purpose  : 
53 //=======================================================================
54
55 void MXCAFDoc_GraphNodeStorageDriver::Paste(const Handle(TDF_Attribute)&        Source,
56                                             const Handle(PDF_Attribute)&        Target,
57                                             const Handle(MDF_SRelocationTable)& RelocTable) const
58 {
59   Handle(XCAFDoc_GraphNode) S = Handle(XCAFDoc_GraphNode)::DownCast (Source);
60   Handle(PXCAFDoc_GraphNode) T = Handle(PXCAFDoc_GraphNode)::DownCast (Target);
61
62   Handle (PXCAFDoc_GraphNode) TF;
63   Handle (XCAFDoc_GraphNode) F;
64   Standard_Integer i;
65
66   for ( i = 1; i <= S->NbFathers(); i++) {
67     F = S->GetFather(i);
68     if (!F.IsNull ()) {
69       if (!RelocTable->HasRelocation(F, TF)) {
70         Standard_NoSuchObject::Raise("MXCAFDoc_GraphNodeStorageDriver::Paste");
71         }
72       T->SetFather(TF);
73     }
74   }
75   
76   for ( i = 1; i <= S->NbChildren(); i++) {
77     F = S->GetChild(i);
78     if (!F.IsNull()) {
79       if (!RelocTable->HasRelocation(F, TF)) {
80         Standard_NoSuchObject::Raise("MXCAFDoc_GraphNodeStorageDriver::Paste");
81         }
82       T->SetChild(TF);
83     }
84   }
85   
86   T->SetGraphID(S->ID());
87 }