0023934: Compiler warnings in MS VC++ 10
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_Curve.cxx
1 // Created on: 1993-06-23
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23
24 #include <TopOpeBRepDS_Curve.ixx>
25 #include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
26 #include <TopOpeBRepDS_Dumper.hxx>
27 #include <Precision.hxx>
28
29
30 //=======================================================================
31 //function : TopOpeBRepDS_Curve
32 //purpose  : 
33 //=======================================================================
34
35 TopOpeBRepDS_Curve::TopOpeBRepDS_Curve() :
36 myFirst(0.0), myLast(0.0),
37 myRangeDefined(Standard_False),
38 myTolerance(Precision::Confusion()),
39 myIsWalk(Standard_False),
40 myKeep(Standard_True),
41 myMother(0),
42 myDSIndex(0)
43 {
44 }
45
46 //=======================================================================
47 //function : TopOpeBRepDS_Curve
48 //purpose  : 
49 //=======================================================================
50
51 TopOpeBRepDS_Curve::TopOpeBRepDS_Curve
52 (const Handle(Geom_Curve)& C, 
53  const Standard_Real T,
54  const Standard_Boolean IsWalk) :
55  myFirst(0.0), myLast(0.0),
56  myRangeDefined(Standard_False),
57  myKeep(Standard_True),
58  myMother(0),
59  myDSIndex(0)
60 {
61   DefineCurve(C,T,IsWalk);
62 }
63
64 //=======================================================================
65 //function : DefineCurve
66 //purpose  : 
67 //=======================================================================
68
69 void TopOpeBRepDS_Curve::DefineCurve
70 (const Handle(Geom_Curve)& C,
71  const Standard_Real T,
72  const Standard_Boolean IsWalk)
73 {
74   myCurve = C;
75   myTolerance = T;
76   myIsWalk = IsWalk;
77 }
78
79 //=======================================================================
80 //function : Tolerance
81 //purpose  : 
82 //=======================================================================
83
84 void TopOpeBRepDS_Curve::Tolerance(const Standard_Real T)
85 {
86   myTolerance = T;
87 }
88
89 //=======================================================================
90 //function : SetSCI
91 //purpose  : 
92 //=======================================================================
93
94 void TopOpeBRepDS_Curve::SetSCI(const Handle(TopOpeBRepDS_Interference)& SCI1,
95                                 const Handle(TopOpeBRepDS_Interference)& SCI2)
96 {
97   mySCI1 = SCI1;
98   mySCI2 = SCI2;
99 }
100
101 //=======================================================================
102 //function : GetSCI
103 //purpose  : 
104 //=======================================================================
105
106 void TopOpeBRepDS_Curve::GetSCI(Handle(TopOpeBRepDS_Interference)& SCI1,
107                                 Handle(TopOpeBRepDS_Interference)& SCI2) const
108 {
109   SCI1 = mySCI1;  
110   SCI2 = mySCI2;
111 }
112
113 //=======================================================================
114 //function : GetSCI1
115 //purpose  : 
116 //=======================================================================
117
118 const Handle(TopOpeBRepDS_Interference)& TopOpeBRepDS_Curve::GetSCI1() const
119 {
120   return mySCI1;
121 }
122
123 //=======================================================================
124 //function : GetSCI2
125 //purpose  : 
126 //=======================================================================
127
128 const Handle(TopOpeBRepDS_Interference)& TopOpeBRepDS_Curve::GetSCI2() const
129 {
130   return mySCI2;
131 }
132
133 //=======================================================================
134 //function : SetShapes
135 //purpose  : 
136 //=======================================================================
137
138 void TopOpeBRepDS_Curve::SetShapes(const TopoDS_Shape& S1,
139                                    const TopoDS_Shape& S2)
140 {
141   myS1 = S1; 
142   myS2 = S2;
143 }
144
145 //=======================================================================
146 //function : GetShapes
147 //purpose  : 
148 //=======================================================================
149
150 void TopOpeBRepDS_Curve::GetShapes(TopoDS_Shape& S1,
151                                    TopoDS_Shape& S2) const
152 {
153   S1 = myS1; 
154   S2 = myS2;
155 }
156
157 //=======================================================================
158 //function : Shape1
159 //purpose  : 
160 //=======================================================================
161
162 const TopoDS_Shape& TopOpeBRepDS_Curve::Shape1() const
163 {
164   return myS1;
165 }
166
167 //=======================================================================
168 //function : ChangeShape1
169 //purpose  : 
170 //=======================================================================
171
172 TopoDS_Shape& TopOpeBRepDS_Curve::ChangeShape1()
173 {
174   return myS1;
175 }
176
177 //=======================================================================
178 //function : Shape2
179 //purpose  : 
180 //=======================================================================
181
182 const TopoDS_Shape& TopOpeBRepDS_Curve::Shape2() const
183 {
184   return myS2;
185 }
186
187 //=======================================================================
188 //function : ChangeShape2
189 //purpose  : 
190 //=======================================================================
191
192 TopoDS_Shape& TopOpeBRepDS_Curve::ChangeShape2()
193 {
194   return myS2;
195 }
196
197 //=======================================================================
198 //function : ChangeCurve
199 //purpose  : 
200 //=======================================================================
201
202 Handle(Geom_Curve)& TopOpeBRepDS_Curve::ChangeCurve()
203 {
204   return myCurve;
205 }
206
207 //=======================================================================
208 //function : Curve
209 //purpose  : 
210 //=======================================================================
211
212 const Handle(Geom_Curve)&  TopOpeBRepDS_Curve::Curve()const 
213 {
214   return myCurve;
215 }
216
217 //=======================================================================
218 //function : SetRange
219 //purpose  : 
220 //=======================================================================
221
222 void TopOpeBRepDS_Curve::SetRange(const Standard_Real First,
223                                   const Standard_Real Last)
224 {
225   myFirst = First;
226   myLast = Last;
227   myRangeDefined = Standard_True;
228 }
229
230
231 //=======================================================================
232 //function : Range
233 //purpose  : 
234 //=======================================================================
235
236 Standard_Boolean TopOpeBRepDS_Curve::Range(Standard_Real& First,
237                                            Standard_Real& Last) const
238 {
239   if (myRangeDefined) {
240     First = myFirst;
241     Last = myLast;
242   }
243   return myRangeDefined;
244 }
245     
246
247 //=======================================================================
248 //function : Tolerance
249 //purpose  : 
250 //=======================================================================
251
252 Standard_Real  TopOpeBRepDS_Curve::Tolerance()const 
253 {
254   return myTolerance;
255 }
256
257 //=======================================================================
258 //function : Curve
259 //purpose  : 
260 //=======================================================================
261
262 void TopOpeBRepDS_Curve::Curve(const Handle(Geom_Curve)& C3D,
263                                const Standard_Real Tol)
264 {
265   myCurve = C3D;
266   myTolerance = Tol;
267 }
268
269
270 //=======================================================================
271 //function : Curve1
272 //purpose  : 
273 //=======================================================================
274
275 const Handle(Geom2d_Curve)&  TopOpeBRepDS_Curve::Curve1()const 
276 {
277   if ( ! mySCI1.IsNull() ) {
278     return 
279       (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI1))->PCurve();
280   }
281   else {
282     static Handle(Geom2d_Curve) STALOC_Geom2dCurveNull1;
283     return STALOC_Geom2dCurveNull1;
284   }
285 }
286
287 //=======================================================================
288 //function : Curve1
289 //purpose  : 
290 //=======================================================================
291
292 void TopOpeBRepDS_Curve::Curve1(const Handle(Geom2d_Curve)& PC1)
293 {
294   if ( ! mySCI1.IsNull() ) {
295     (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI1))->PCurve(PC1);
296   }
297 }
298
299
300 //=======================================================================
301 //function : Curve2
302 //purpose  : 
303 //=======================================================================
304
305 const Handle(Geom2d_Curve)&  TopOpeBRepDS_Curve::Curve2()const 
306 {
307   if ( ! mySCI2.IsNull() ) {
308     return 
309       (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI2))->PCurve();
310   }
311   else {
312     static Handle(Geom2d_Curve) STALOC_Geom2dCurveNull2;
313     return STALOC_Geom2dCurveNull2;
314   }
315 }
316
317 //=======================================================================
318 //function : Curve2
319 //purpose  : 
320 //=======================================================================
321
322 void TopOpeBRepDS_Curve::Curve2(const Handle(Geom2d_Curve)& PC2)
323 {
324   if ( ! mySCI2.IsNull() ) {
325     (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI2))->PCurve(PC2);
326   }
327 }
328
329
330 //=======================================================================
331 //function : IsWalk
332 //purpose  : 
333 //=======================================================================
334
335 Standard_Boolean TopOpeBRepDS_Curve::IsWalk() const
336 {
337   return myIsWalk;
338 }
339
340 //=======================================================================
341 //function : ChangeIsWalk
342 //purpose  : 
343 //=======================================================================
344
345 void TopOpeBRepDS_Curve::ChangeIsWalk(const Standard_Boolean B)
346 {
347   myIsWalk = B;
348 }
349
350
351 //=======================================================================
352 //function : Dump
353 //purpose  : 
354 //=======================================================================
355
356 #ifdef DEB
357 Standard_OStream& TopOpeBRepDS_Curve::Dump (Standard_OStream& OS,
358                                             const Standard_Integer index,
359                                             const Standard_Boolean compact)const
360 {
361   OS<<"Curve : "; if (index != 0) OS<<index<<" ";
362   if (!Curve().IsNull()) {
363     TopOpeBRepDS_Dumper::Print(Curve(),OS,compact);
364     Standard_Real f,l;
365     if (Range(f,l)) OS<<"has range of "<<f<<","<<l<<endl;
366     else            OS<<"has no range defined"<<endl;
367   }
368   else OS<<" is null";
369   OS<<endl;
370   
371 #define DSCI(tut) (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&(tut)))
372
373   Handle(TopOpeBRepDS_Interference) I1,I2; 
374   GetSCI(I1,I2);
375
376   OS<<"SCI1 : ";
377   if (!I1.IsNull()) DSCI(I1)->DumpPCurve(OS,compact);
378   else OS<<" is null";
379   OS<<endl;
380   
381   OS<<"SCI2 : ";
382   if (!I2.IsNull()) DSCI(I2)->DumpPCurve(OS,compact);
383   else OS<<" is null";
384   OS<<endl;
385
386   return OS;
387 }
388 #else
389 Standard_OStream& TopOpeBRepDS_Curve::Dump (Standard_OStream& OS,
390                                             const Standard_Integer,
391                                             const Standard_Boolean)const
392 {
393   return OS;
394 }
395 #endif
396
397
398 //=======================================================================
399 //function : Keep
400 //purpose  : 
401 //=======================================================================
402
403 Standard_Boolean TopOpeBRepDS_Curve::Keep() const
404 {
405   return myKeep;
406 }
407
408
409 //=======================================================================
410 //function : ChangeKeep
411 //purpose  : 
412 //=======================================================================
413
414 void TopOpeBRepDS_Curve::ChangeKeep(const Standard_Boolean b)
415 {
416   myKeep = b;
417 }
418
419
420 //=======================================================================
421 //function : Mother
422 //purpose  : 
423 //=======================================================================
424
425 Standard_Integer TopOpeBRepDS_Curve::Mother() const
426 {
427   return myMother;
428 }
429
430
431 //=======================================================================
432 //function : ChangeMother
433 //purpose  : 
434 //=======================================================================
435
436 void TopOpeBRepDS_Curve::ChangeMother(const Standard_Integer b)
437 {
438   myMother = b;
439 }
440
441 //=======================================================================
442 //function : DSIndex
443 //purpose  : 
444 //=======================================================================
445
446 Standard_Integer TopOpeBRepDS_Curve::DSIndex() const
447 {
448   return myDSIndex;
449 }
450
451
452 //=======================================================================
453 //function : ChangeDSIndex
454 //purpose  : 
455 //=======================================================================
456
457 void TopOpeBRepDS_Curve::ChangeDSIndex(const Standard_Integer b)
458 {
459   myDSIndex = b;
460 }