summaryrefslogtreecommitdiff
path: root/src/TFunction/TFunction_Function.cxx
blob: cca5d79baf1467c92d9762c81c1a3a45ec424bce (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// File:	TFunction_Function.cxx
// Created:	Thu Jun 10 19:39:27 1999
// Author:	Vladislav ROMASHKO
//		<vro@flox.nnov.matra-dtv.fr>


#include <TFunction_Function.ixx>
#include <TFunction_GraphNode.hxx>
#include <TFunction_Scope.hxx>

#include <TDF_Label.hxx>
#include <Standard_DomainError.hxx>


//=======================================================================
//function : GetID
//purpose  : Static method to get an ID
//=======================================================================

const Standard_GUID&  TFunction_Function::GetID() 
{  
  static Standard_GUID TFunction_FunctionID("5b35ca00-5b78-11d1-8940-080009dc3333");
  return TFunction_FunctionID; 
}


//=======================================================================
//function : Set
//purpose  : Finds or creates a function attribute
//=======================================================================

Handle(TFunction_Function) TFunction_Function::Set(const TDF_Label& L)
{
  Handle(TFunction_Function) F;
  if (!L.FindAttribute(TFunction_Function::GetID(), F)) {
    F = new TFunction_Function();
    L.AddAttribute(F);
  }
  return F;
}

//=======================================================================
//function : Set
//purpose  : Finds or creates a function attribute and initializes 
//         : a driver for it
//=======================================================================

Handle(TFunction_Function) TFunction_Function::Set(const TDF_Label& L, 
						   const Standard_GUID& DriverID)
{
  Handle(TFunction_Function) F;
  if (!L.FindAttribute(TFunction_Function::GetID(), F)) {
    F = new TFunction_Function();  
    L.AddAttribute(F);
  }
  F->SetDriverGUID(DriverID);
  return F;
}

//=======================================================================
//function : ID
//purpose  : Returns GUID of the function
//=======================================================================

const Standard_GUID& TFunction_Function::ID() const
{ return GetID(); }


//=======================================================================
//function : Find
//purpose  : Finds a function if it is on the label
//=======================================================================

// Standard_Boolean TFunction_Function::Find(const TDF_Label& L,
// 					  Handle(TFunction_Function)& F)
// {
//   if (!L.FindAttribute(TFunction_Function::GetID(), F))
//     return Standard_False;
//   return Standard_True;
// }

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

TFunction_Function::TFunction_Function () : myFailure(0)
{}  

//=======================================================================
//function : SetDriverGUID
//purpose  : 
//=======================================================================

void TFunction_Function::SetDriverGUID(const Standard_GUID& guid)
{
  // OCC2932 correction
  if(myDriverGUID == guid) return;

  Backup();
  myDriverGUID = guid;
}

//=======================================================================
//function : SetFailure
//purpose  : Sets the failed status of the function
//=======================================================================

void TFunction_Function::SetFailure (const Standard_Integer mode)
{
  // OCC2932 correction
  if(myFailure == mode) return;

  Backup();
  myFailure = mode;
}


//=======================================================================
//function : Restore
//purpose  : 
//=======================================================================

void TFunction_Function::Restore(const Handle(TDF_Attribute)& other) 
{
  Handle(TFunction_Function) F =  Handle(TFunction_Function)::DownCast(other);
  myFailure    = F->myFailure;
  myDriverGUID = F->myDriverGUID;
}

//=======================================================================
//function : Paste
//purpose  : Method for Copy mechanism
//=======================================================================

void TFunction_Function::Paste(const Handle(TDF_Attribute)& into,
			       const Handle(TDF_RelocationTable)& RT) const
{
  Handle(TFunction_Function) intof = Handle(TFunction_Function)::DownCast(into);
  intof->SetFailure(myFailure);
  intof->SetDriverGUID(myDriverGUID);
}

//=======================================================================
//function : NewEmpty
//purpose  : Returns new empty function attribute
//=======================================================================

Handle(TDF_Attribute) TFunction_Function::NewEmpty() const
{
  return new TFunction_Function();
}

//=======================================================================
//function : References
//purpose  : Collects the references
//=======================================================================

void TFunction_Function::References(const Handle(TDF_DataSet)& aDataSet) const
{
}

//=======================================================================
//function : Dump
//purpose  : Dump of the function
//=======================================================================

Standard_OStream& TFunction_Function::Dump (Standard_OStream& anOS) const
{
  TDF_Attribute::Dump(anOS);
  return anOS;
}