0022627: Change OCCT memory management defaults
[occt.git] / src / MAT / MAT_Arc.cxx
1 // File:        MAT_Arc.cxx
2 // Created:     Tue May  4 18:11:04 1993
3 // Author:      Yves FRICAUD
4 //              <yfr@phylox>
5
6
7 #include <MAT_Arc.ixx>
8 #include <Standard_DomainError.hxx>
9
10 //========================================================================
11 // function:
12 // purpose :
13 //========================================================================
14 MAT_Arc::MAT_Arc (const Standard_Integer      ArcIndex, 
15                   const Standard_Integer      GeomIndex, 
16                   const Handle(MAT_BasicElt)& FirstElement, 
17                   const Handle(MAT_BasicElt)& SecondElement)
18  : arcIndex(ArcIndex),
19    geomIndex(GeomIndex),
20    firstArcLeft  (0),
21    firstArcRight (0),
22    secondArcRight (0),
23    secondArcLeft (0)   
24 {
25   firstElement  = FirstElement;
26   secondElement = SecondElement;
27 }
28
29 //========================================================================
30 // function: Index
31 // purpose :
32 //========================================================================
33 Standard_Integer  MAT_Arc::Index() const
34 {
35   return arcIndex;
36 }
37
38 //========================================================================
39 // function: GeomIndex
40 // purpose :
41 //========================================================================
42 Standard_Integer  MAT_Arc::GeomIndex() const
43 {
44   return geomIndex;
45 }
46
47 //========================================================================
48 // function: FirstElement
49 // purpose :
50 //========================================================================
51 Handle(MAT_BasicElt)  MAT_Arc::FirstElement() const
52 {
53   return firstElement;
54 }
55
56 //========================================================================
57 // function: SecondElement
58 // purpose :
59 //========================================================================
60 Handle(MAT_BasicElt)  MAT_Arc::SecondElement() const
61 {
62   return secondElement;
63 }
64
65 //========================================================================
66 // function: FirstNode
67 // purpose :
68 //========================================================================
69 Handle(MAT_Node)  MAT_Arc::FirstNode() const
70 {
71   return firstNode; 
72 }
73
74 //========================================================================
75 // function: SecondNode
76 // purpose :
77 //========================================================================
78 Handle(MAT_Node)  MAT_Arc::SecondNode() const
79 {
80   return secondNode;
81 }
82
83 //========================================================================
84 // function: TheOtherNode
85 // purpose :
86 //========================================================================
87 Handle(MAT_Node) MAT_Arc::TheOtherNode(const Handle(MAT_Node)& aNode)const 
88 {
89   if (FirstNode() == aNode)
90     return SecondNode();
91   else if (SecondNode() == aNode)
92     return FirstNode();
93   else {
94     Standard_DomainError::Raise("MAT_Arc::TheOtherNode");
95     return aNode;
96   }
97 }
98
99 //========================================================================
100 // function: HasNeighbour
101 // purpose :
102 //========================================================================
103 Standard_Boolean MAT_Arc::HasNeighbour(const Handle(MAT_Node)& aNode,
104                                        const MAT_Side          aSide ) const
105 {
106   if (aSide == MAT_Left) {
107 //    if (aNode == FirstNode())  return (!firstArcLeft  == NULL);
108     if (aNode == FirstNode())  return (!firstArcLeft  == 0);
109 //    if (aNode == SecondNode()) return (!secondArcLeft == NULL);
110     if (aNode == SecondNode()) return (!secondArcLeft == 0);
111   }
112   else {
113 //    if (aNode == FirstNode())  return (!firstArcRight  == NULL);
114     if (aNode == FirstNode())  return (!firstArcRight  == 0);
115 //    if (aNode == SecondNode()) return (!secondArcRight == NULL);
116     if (aNode == SecondNode()) return (!secondArcRight == 0);
117   }
118   Standard_DomainError::Raise("MAT_Arc::HasNeighbour");
119   return Standard_False;
120 }
121
122 //========================================================================
123 // function: Neighbour
124 // purpose :
125 //========================================================================
126 Handle(MAT_Arc)  MAT_Arc::Neighbour(const Handle(MAT_Node)& aNode,
127                                     const MAT_Side          aSide ) 
128 const
129
130 {
131   if (aSide == MAT_Left) {
132     if (aNode == FirstNode())  return (MAT_Arc*)firstArcLeft;
133     if (aNode == SecondNode()) return (MAT_Arc*)secondArcLeft;
134   }
135   else {
136     if (aNode == FirstNode())  return (MAT_Arc*)firstArcRight;
137     if (aNode == SecondNode()) return (MAT_Arc*)secondArcRight;
138   }
139   Standard_DomainError::Raise("MAT_Arc::Neighbour");
140   return (MAT_Arc*)firstArcLeft;
141 }
142
143 //========================================================================
144 // function: SetIndex
145 // purpose :
146 //========================================================================
147 void  MAT_Arc::SetIndex(const Standard_Integer anInteger)
148 {
149   arcIndex = anInteger;
150 }
151
152 //========================================================================
153 // function: SetGeomIndex
154 // purpose :
155 //========================================================================
156 void  MAT_Arc::SetGeomIndex(const Standard_Integer anInteger)
157 {
158   geomIndex = anInteger;
159 }
160
161 //========================================================================
162 // function: SetFirstElement
163 // purpose :
164 //========================================================================
165 void  MAT_Arc::SetFirstElement(const Handle(MAT_BasicElt)& aBasicElt)
166 {
167   firstElement = aBasicElt;
168 }
169
170 //========================================================================
171 // function: SetSecondElement
172 // purpose :
173 //========================================================================
174 void  MAT_Arc::SetSecondElement(const Handle(MAT_BasicElt)& aBasicElt)
175 {
176   secondElement = aBasicElt;
177 }
178
179 //========================================================================
180 // function: SetFirstNode
181 // purpose :
182 //========================================================================
183 void  MAT_Arc::SetFirstNode(const Handle(MAT_Node)& aNode)
184 {
185   firstNode = aNode;
186 }
187
188 //========================================================================
189 // function: SetSecondNode
190 // purpose :
191 //========================================================================
192 void  MAT_Arc::SetSecondNode(const Handle_MAT_Node& aNode)
193 {
194   secondNode = aNode;
195 }
196
197 //========================================================================
198 // function: SetFirstArc
199 // purpose :
200 //========================================================================
201 void  MAT_Arc::SetFirstArc(const MAT_Side aSide ,
202                            const Handle(MAT_Arc)& anArc)
203 {
204   if (aSide == MAT_Left) 
205     firstArcLeft  = anArc.operator->();
206   else
207     firstArcRight = anArc.operator->();
208 }
209
210 //========================================================================
211 // function: SetSecondArc
212 // purpose :
213 //========================================================================
214 void  MAT_Arc::SetSecondArc(const MAT_Side aSide ,
215                             const Handle(MAT_Arc)& anArc)
216
217   if (aSide == MAT_Left) 
218     secondArcLeft = anArc.operator->();
219   else
220     secondArcRight = anArc.operator->();
221 }
222
223 //========================================================================
224 // function: SetNeighbour
225 // purpose :
226 //========================================================================
227 void  MAT_Arc::SetNeighbour(const MAT_Side aSide, 
228                             const Handle(MAT_Node)& aNode, 
229                             const Handle(MAT_Arc)& anArc)
230 {
231   if (aSide == MAT_Left) {
232     if (aNode == FirstNode())  
233       firstArcLeft  = anArc.operator->();
234     else if (aNode == SecondNode())
235       secondArcLeft = anArc.operator->();
236     else
237      Standard_DomainError::Raise("MAT_Arc::SetNeighbour"); 
238   }
239   else {
240     if (aNode == FirstNode())  
241       firstArcRight  = anArc.operator->();
242     else if (aNode == SecondNode())
243       secondArcRight = anArc.operator->();
244     else
245       Standard_DomainError::Raise("MAT_Arc::SetNeighbour");
246   }
247 }
248
249
250
251
252
253
254
255
256
257
258