summaryrefslogtreecommitdiff
path: root/src/MXCAFDoc/MXCAFDoc_GraphNodeStorageDriver.cxx
blob: 272152aab8487499cea252dae8f7688696fae2fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// File:	MXCAFDoc_GraphNodeStorageDriver.cxx
// Created:	Fri Sep 29 10:46:06 2000
// Author:	data exchange team
//		<det@nordox.nnov.matra-dtv.fr>


#include <MXCAFDoc_GraphNodeStorageDriver.ixx>

#include <XCAFDoc_GraphNode.hxx>
#include <PXCAFDoc_GraphNode.hxx>
#include <Standard_NoSuchObject.hxx>


//=======================================================================
//function : Constructor
//purpose  : 
//=======================================================================

MXCAFDoc_GraphNodeStorageDriver::MXCAFDoc_GraphNodeStorageDriver(const Handle(CDM_MessageDriver)& theMsgDriver) : MDF_ASDriver (theMsgDriver)
{}


//=======================================================================
//function : VersionNumber
//purpose  : 
//=======================================================================

Standard_Integer MXCAFDoc_GraphNodeStorageDriver::VersionNumber() const
{ return 0; }


//=======================================================================
//function : SourceType
//purpose  : 
//=======================================================================

Handle(Standard_Type) MXCAFDoc_GraphNodeStorageDriver::SourceType() const
{ return STANDARD_TYPE(XCAFDoc_GraphNode); }


//=======================================================================
//function : NewEmpty
//purpose  : 
//=======================================================================

Handle(PDF_Attribute) MXCAFDoc_GraphNodeStorageDriver::NewEmpty() const
{ return new PXCAFDoc_GraphNode(); }


//=======================================================================
//function : Paste
//purpose  : 
//=======================================================================

void MXCAFDoc_GraphNodeStorageDriver::Paste(const Handle(TDF_Attribute)&        Source,
					    const Handle(PDF_Attribute)&        Target,
					    const Handle(MDF_SRelocationTable)& RelocTable) const
{
  Handle(XCAFDoc_GraphNode) S = Handle(XCAFDoc_GraphNode)::DownCast (Source);
  Handle(PXCAFDoc_GraphNode) T = Handle(PXCAFDoc_GraphNode)::DownCast (Target);

  Handle (PXCAFDoc_GraphNode) TF;
  Handle (XCAFDoc_GraphNode) F;
  Standard_Integer i;

  for ( i = 1; i <= S->NbFathers(); i++) {
    F = S->GetFather(i);
    if (!F.IsNull ()) {
      if (!RelocTable->HasRelocation(F, TF)) {
	Standard_NoSuchObject::Raise("MXCAFDoc_GraphNodeStorageDriver::Paste");
	}
      T->SetFather(TF);
    }
  }
  
  for ( i = 1; i <= S->NbChildren(); i++) {
    F = S->GetChild(i);
    if (!F.IsNull()) {
      if (!RelocTable->HasRelocation(F, TF)) {
	Standard_NoSuchObject::Raise("MXCAFDoc_GraphNodeStorageDriver::Paste");
	}
      T->SetChild(TF);
    }
  }
  
  T->SetGraphID(S->ID());
}