0024818: CLang warnings -Wlogical-not-parentheses
[occt.git] / src / MAT / MAT_Arc.cxx
1 // Created on: 1993-05-04
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <MAT_Arc.ixx>
18 #include <Standard_DomainError.hxx>
19
20 //========================================================================
21 // function:
22 // purpose :
23 //========================================================================
24 MAT_Arc::MAT_Arc (const Standard_Integer      ArcIndex, 
25                   const Standard_Integer      GeomIndex, 
26                   const Handle(MAT_BasicElt)& FirstElement, 
27                   const Handle(MAT_BasicElt)& SecondElement)
28  : arcIndex(ArcIndex),
29    geomIndex(GeomIndex),
30    firstArcLeft  (0),
31    firstArcRight (0),
32    secondArcRight (0),
33    secondArcLeft (0)   
34 {
35   firstElement  = FirstElement;
36   secondElement = SecondElement;
37 }
38
39 //========================================================================
40 // function: Index
41 // purpose :
42 //========================================================================
43 Standard_Integer  MAT_Arc::Index() const
44 {
45   return arcIndex;
46 }
47
48 //========================================================================
49 // function: GeomIndex
50 // purpose :
51 //========================================================================
52 Standard_Integer  MAT_Arc::GeomIndex() const
53 {
54   return geomIndex;
55 }
56
57 //========================================================================
58 // function: FirstElement
59 // purpose :
60 //========================================================================
61 Handle(MAT_BasicElt)  MAT_Arc::FirstElement() const
62 {
63   return firstElement;
64 }
65
66 //========================================================================
67 // function: SecondElement
68 // purpose :
69 //========================================================================
70 Handle(MAT_BasicElt)  MAT_Arc::SecondElement() const
71 {
72   return secondElement;
73 }
74
75 //========================================================================
76 // function: FirstNode
77 // purpose :
78 //========================================================================
79 Handle(MAT_Node)  MAT_Arc::FirstNode() const
80 {
81   return firstNode; 
82 }
83
84 //========================================================================
85 // function: SecondNode
86 // purpose :
87 //========================================================================
88 Handle(MAT_Node)  MAT_Arc::SecondNode() const
89 {
90   return secondNode;
91 }
92
93 //========================================================================
94 // function: TheOtherNode
95 // purpose :
96 //========================================================================
97 Handle(MAT_Node) MAT_Arc::TheOtherNode(const Handle(MAT_Node)& aNode)const 
98 {
99   if (FirstNode() == aNode)
100     return SecondNode();
101   else if (SecondNode() == aNode)
102     return FirstNode();
103   else {
104     Standard_DomainError::Raise("MAT_Arc::TheOtherNode");
105     return aNode;
106   }
107 }
108
109 //========================================================================
110 // function: HasNeighbour
111 // purpose :
112 //========================================================================
113 Standard_Boolean MAT_Arc::HasNeighbour(const Handle(MAT_Node)& aNode,
114                                        const MAT_Side          aSide ) const
115 {
116   if (aSide == MAT_Left) {
117 //    if (aNode == FirstNode())  return (!firstArcLeft  == NULL);
118     if (aNode == FirstNode())  return (firstArcLeft != 0);
119 //    if (aNode == SecondNode()) return (!secondArcLeft == NULL);
120     if (aNode == SecondNode()) return (secondArcLeft != 0);
121   }
122   else {
123 //    if (aNode == FirstNode())  return (!firstArcRight  == NULL);
124     if (aNode == FirstNode())  return (firstArcRight != 0);
125 //    if (aNode == SecondNode()) return (!secondArcRight == NULL);
126     if (aNode == SecondNode()) return (secondArcRight != 0);
127   }
128   Standard_DomainError::Raise("MAT_Arc::HasNeighbour");
129   return Standard_False;
130 }
131
132 //========================================================================
133 // function: Neighbour
134 // purpose :
135 //========================================================================
136 Handle(MAT_Arc)  MAT_Arc::Neighbour(const Handle(MAT_Node)& aNode,
137                                     const MAT_Side          aSide ) 
138 const
139
140 {
141   if (aSide == MAT_Left) {
142     if (aNode == FirstNode())  return (MAT_Arc*)firstArcLeft;
143     if (aNode == SecondNode()) return (MAT_Arc*)secondArcLeft;
144   }
145   else {
146     if (aNode == FirstNode())  return (MAT_Arc*)firstArcRight;
147     if (aNode == SecondNode()) return (MAT_Arc*)secondArcRight;
148   }
149   Standard_DomainError::Raise("MAT_Arc::Neighbour");
150   return (MAT_Arc*)firstArcLeft;
151 }
152
153 //========================================================================
154 // function: SetIndex
155 // purpose :
156 //========================================================================
157 void  MAT_Arc::SetIndex(const Standard_Integer anInteger)
158 {
159   arcIndex = anInteger;
160 }
161
162 //========================================================================
163 // function: SetGeomIndex
164 // purpose :
165 //========================================================================
166 void  MAT_Arc::SetGeomIndex(const Standard_Integer anInteger)
167 {
168   geomIndex = anInteger;
169 }
170
171 //========================================================================
172 // function: SetFirstElement
173 // purpose :
174 //========================================================================
175 void  MAT_Arc::SetFirstElement(const Handle(MAT_BasicElt)& aBasicElt)
176 {
177   firstElement = aBasicElt;
178 }
179
180 //========================================================================
181 // function: SetSecondElement
182 // purpose :
183 //========================================================================
184 void  MAT_Arc::SetSecondElement(const Handle(MAT_BasicElt)& aBasicElt)
185 {
186   secondElement = aBasicElt;
187 }
188
189 //========================================================================
190 // function: SetFirstNode
191 // purpose :
192 //========================================================================
193 void  MAT_Arc::SetFirstNode(const Handle(MAT_Node)& aNode)
194 {
195   firstNode = aNode;
196 }
197
198 //========================================================================
199 // function: SetSecondNode
200 // purpose :
201 //========================================================================
202 void  MAT_Arc::SetSecondNode(const Handle_MAT_Node& aNode)
203 {
204   secondNode = aNode;
205 }
206
207 //========================================================================
208 // function: SetFirstArc
209 // purpose :
210 //========================================================================
211 void  MAT_Arc::SetFirstArc(const MAT_Side aSide ,
212                            const Handle(MAT_Arc)& anArc)
213 {
214   if (aSide == MAT_Left) 
215     firstArcLeft  = anArc.operator->();
216   else
217     firstArcRight = anArc.operator->();
218 }
219
220 //========================================================================
221 // function: SetSecondArc
222 // purpose :
223 //========================================================================
224 void  MAT_Arc::SetSecondArc(const MAT_Side aSide ,
225                             const Handle(MAT_Arc)& anArc)
226
227   if (aSide == MAT_Left) 
228     secondArcLeft = anArc.operator->();
229   else
230     secondArcRight = anArc.operator->();
231 }
232
233 //========================================================================
234 // function: SetNeighbour
235 // purpose :
236 //========================================================================
237 void  MAT_Arc::SetNeighbour(const MAT_Side aSide, 
238                             const Handle(MAT_Node)& aNode, 
239                             const Handle(MAT_Arc)& anArc)
240 {
241   if (aSide == MAT_Left) {
242     if (aNode == FirstNode())  
243       firstArcLeft  = anArc.operator->();
244     else if (aNode == SecondNode())
245       secondArcLeft = anArc.operator->();
246     else
247      Standard_DomainError::Raise("MAT_Arc::SetNeighbour"); 
248   }
249   else {
250     if (aNode == FirstNode())  
251       firstArcRight  = anArc.operator->();
252     else if (aNode == SecondNode())
253       secondArcRight = anArc.operator->();
254     else
255       Standard_DomainError::Raise("MAT_Arc::SetNeighbour");
256   }
257 }
258
259
260
261
262
263
264
265
266
267
268