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